diff --git a/packages/openapi-code-generator/src/core/openapi-validator.spec.ts b/packages/openapi-code-generator/src/core/openapi-validator.spec.ts index 0330ac2d..c12487c6 100644 --- a/packages/openapi-code-generator/src/core/openapi-validator.spec.ts +++ b/packages/openapi-code-generator/src/core/openapi-validator.spec.ts @@ -89,6 +89,40 @@ describe("core/openapi-validator", () => { ).resolves.toBeUndefined() }) + it("should accept anonymous security alternatives", async () => { + const validator = await OpenapiValidator.create() + await expect( + validator.validate( + "optional-security.yaml", + { + openapi: "3.1.0", + info: { + title: "Optional Security", + version: "1.0.0", + }, + paths: { + "/public-or-keyed": { + get: { + security: [{ApiKeyAuth: []}, {}], + responses: {default: {description: "ok"}}, + }, + }, + }, + components: { + securitySchemes: { + ApiKeyAuth: { + type: "apiKey", + in: "header", + name: "X-API-Key", + }, + }, + }, + }, + true, + ), + ).resolves.toBeUndefined() + }) + it.skip("should reject an invalid specification", async () => { const validator = await OpenapiValidator.create() await expect(