diff --git a/test/fixtures/security-fields/specs.yaml b/test/fixtures/security-fields/specs.yaml new file mode 100644 index 0000000..0f2fd53 --- /dev/null +++ b/test/fixtures/security-fields/specs.yaml @@ -0,0 +1,30 @@ +openapi: 3.0.0 +info: + title: Minimal OpenAPI specification to reproduce an issue + version: 1.0.0 +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + + schemas: + HelloWorld: + type: object + properties: + message: + type: string + required: + - message +paths: + '/hello': + get: + security: + - bearerAuth: [] + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/HelloWorld' diff --git a/test/securityFields.test.ts b/test/securityFields.test.ts new file mode 100644 index 0000000..7c5bb29 --- /dev/null +++ b/test/securityFields.test.ts @@ -0,0 +1,17 @@ +import path from 'path'; +import { describe, it, expect } from 'vitest'; +import { fixtures, makeTestOutputPath } from './test-utils'; +import { openapiToTsJsonSchema } from '../src'; + +describe('OpenApi security fields', () => { + it('handles schema correctly', async () => { + await expect( + openapiToTsJsonSchema({ + openApiSchema: path.resolve(fixtures, 'security-fields/specs.yaml'), + outputPath: makeTestOutputPath('security-fields'), + definitionPathsToGenerateFrom: ['components.schemas', 'paths'], + silent: true, + }), + ).resolves.not.toThrow(); + }); +});