From 341e8ead12c9bf6a32ef6b0fc4484357ec083b0a Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Wed, 22 Feb 2023 13:10:29 +0100 Subject: [PATCH] feat: extend refs in openapi (#3170) --- package.json | 2 +- src/lib/openapi/validate.ts | 1 - src/lib/services/openapi-service.ts | 2 +- src/lib/types/openapi.d.ts | 2 +- yarn.lock | 8 ++++---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 566343e862..f686be5d19 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@unleash/express-openapi": "^0.2.1", + "@unleash/express-openapi": "^0.2.2", "ajv": "^8.11.0", "ajv-formats": "^2.1.1", "async": "^3.2.4", diff --git a/src/lib/openapi/validate.ts b/src/lib/openapi/validate.ts index d9a9cec271..256fa63e9d 100644 --- a/src/lib/openapi/validate.ts +++ b/src/lib/openapi/validate.ts @@ -11,7 +11,6 @@ const ajv = new Ajv({ schemas: Object.values(schemas).map((schema) => omitKeys(schema, 'components'), ), - // example was superseded by examples in openapi 3.1, but we're still on 3.0, so // let's add it back in! keywords: ['example'], diff --git a/src/lib/services/openapi-service.ts b/src/lib/services/openapi-service.ts index dfee790164..b85af02ec6 100644 --- a/src/lib/services/openapi-service.ts +++ b/src/lib/services/openapi-service.ts @@ -29,7 +29,7 @@ export class OpenApiService { this.api = openapi( this.docsPath(), createOpenApiSchema(config.server), - { coerce: true }, + { coerce: true, extendRefs: true }, ); } diff --git a/src/lib/types/openapi.d.ts b/src/lib/types/openapi.d.ts index e4ebb04a0f..82b5984b33 100644 --- a/src/lib/types/openapi.d.ts +++ b/src/lib/types/openapi.d.ts @@ -12,6 +12,6 @@ declare module '@unleash/express-openapi' { export default function openapi( docsPath: string, document: Omit, - options?: { coerce: boolean }, + options?: { coerce: boolean; extendRefs: boolean }, ): IExpressOpenApi; } diff --git a/yarn.lock b/yarn.lock index 0c7e05219d..36c41be664 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1353,10 +1353,10 @@ "@typescript-eslint/types" "5.52.0" eslint-visitor-keys "^3.3.0" -"@unleash/express-openapi@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@unleash/express-openapi/-/express-openapi-0.2.1.tgz#ecbba742dad0a05c1563f35e3272ee3671dc478d" - integrity sha512-wvwgSrzMGo3khB2E/xPLXlB/uT6FruszIsUDThJpttILtxBmj1SDWb0L6SG1CQ2tlnC786/6+0iSBwcz0fViOg== +"@unleash/express-openapi@^0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@unleash/express-openapi/-/express-openapi-0.2.2.tgz#b6e6a3d0fb93f8f52fc7d8f375e9bb52a3d3a46e" + integrity sha512-Evn1gVB5v7QMAs/mGjTc3NihX9wZnMdyBPvpd/JqMI8NDH9z/q46cYnh2t7bFPQj7FBghWwZlcJNm7PU0bxe7A== dependencies: ajv "^6.10.2" http-errors "^1.7.3"