diff --git a/package.json b/package.json index 45449db..82987e5 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "dependencies": { "@stoplight/json": "^3.18.1", "@stoplight/json-schema-generator": "1.0.1", - "@stoplight/types": "^13.5.0", + "@stoplight/types": "^13.6.0", "@types/json-schema": "7.0.11", "@types/swagger-schema-official": "~2.0.22", "@types/type-is": "^1.6.3", diff --git a/src/oas/service.ts b/src/oas/service.ts index 15a3ba0..d0773be 100644 --- a/src/oas/service.ts +++ b/src/oas/service.ts @@ -4,7 +4,7 @@ import pickBy = require('lodash.pickby'); import { OpenAPIObject } from 'openapi3-ts'; import { Spec } from 'swagger-schema-official'; -import { isNonNullable, isString } from '../guards'; +import { isBoolean, isNonNullable, isString } from '../guards'; import { TranslateFunction } from '../types'; import { hasXLogo } from './guards'; import { translateTagDefinition } from './tags'; @@ -37,6 +37,13 @@ export const transformOasService: TranslateFunction | }, isPlainObject, ), + + ...pickBy( + { + internal: document['x-internal'], + }, + isBoolean, + ), }; if (isPlainObject(document.info) && hasXLogo(document.info)) { diff --git a/src/oas2/__tests__/service.test.ts b/src/oas2/__tests__/service.test.ts index e54d7d9..8eca11c 100644 --- a/src/oas2/__tests__/service.test.ts +++ b/src/oas2/__tests__/service.test.ts @@ -92,6 +92,28 @@ describe('oas2 service', () => { const transformed = transformOas2Service({ document }); expect(transformed).toHaveProperty(['security', 0, 'flows', 'implicit', 'scopes'], { scope_1: '' }); }); + + it('should handle x-internal property', () => { + const document: Partial & Fragment & { 'x-internal': boolean } = { + 'x-stoplight': { id: 'abc' }, + info: { + title: '', + version: '1.0', + }, + 'x-internal': true, + }; + + expect( + transformOas2Service({ + document, + }), + ).toStrictEqual({ + id: 'abc', + name: '', + version: '1.0', + internal: true, + }); + }); describe('x-logo support', () => { it('should support x-logo', () => { const document: Partial = { diff --git a/src/oas3/__tests__/service.test.ts b/src/oas3/__tests__/service.test.ts index 87961ff..96cb5c8 100644 --- a/src/oas3/__tests__/service.test.ts +++ b/src/oas3/__tests__/service.test.ts @@ -216,6 +216,23 @@ describe('oas3 service', () => { }); }); + it('should handle x-internal property', () => { + const document: Partial & { 'x-internal': boolean } = { + info: { + title: '', + version: '1.0', + }, + 'x-internal': true, + }; + + expect(transformOas3Service({ document })).toStrictEqual({ + id: 'abc', + internal: true, + name: '', + version: '1.0', + }); + }); + it('should filter out scopes', () => { const document: Partial = { openapi: '3.0.0', diff --git a/yarn.lock b/yarn.lock index a8f3c34..24119aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1491,10 +1491,10 @@ "@types/json-schema" "^7.0.4" utility-types "^3.10.0" -"@stoplight/types@^13.5.0": - version "13.5.0" - resolved "https://registry.yarnpkg.com/@stoplight/types/-/types-13.5.0.tgz#a17990ab4ff3fc60325dc64d758c4670b872ac8b" - integrity sha512-8UFgYj4Y/vcc3a2ZuJJ+ltiJlFsXa7/huZkmjhaHq+jPHIR2Va+aFaExENV/cWtxUVTXE15KSzPOX/ikucUFbw== +"@stoplight/types@^13.6.0": + version "13.6.0" + resolved "https://registry.yarnpkg.com/@stoplight/types/-/types-13.6.0.tgz#96c6aaae05858b36f589821cd52c95aa9b205ce7" + integrity sha512-dzyuzvUjv3m1wmhPfq82lCVYGcXG0xUYgqnWfCq3PCVR4BKFhjdkHrnJ+jIDoMKvXb05AZP/ObQF6+NpDo29IQ== dependencies: "@types/json-schema" "^7.0.4" utility-types "^3.10.0"