diff --git a/src/framework/ajv/index.ts b/src/framework/ajv/index.ts index 3e204b79..bb297080 100644 --- a/src/framework/ajv/index.ts +++ b/src/framework/ajv/index.ts @@ -61,9 +61,6 @@ function createAjv( for (let [formatName, formatDefinition] of Object.entries(options.formats)) { ajv.addFormat(formatName, formatDefinition); } - ajv.removeKeyword('propertyNames'); - ajv.removeKeyword('contains'); - ajv.removeKeyword('const'); if (options.serDesMap) { // Alias for `type` that can execute AFTER x-eov-res-serdes diff --git a/src/framework/types.ts b/src/framework/types.ts index 08b3c35c..b75adc31 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -194,7 +194,7 @@ export interface NormalizedOpenApiValidatorOpts extends OpenApiValidatorOpts { export namespace OpenAPIV3 { export interface DocumentV3 { - openapi: string; + openapi: `3.0.${string}`; info: InfoObject; servers?: ServerObject[]; paths: PathsObject; @@ -208,7 +208,8 @@ export namespace OpenAPIV3 { pathItems?: { [path: string]: PathItemObject | ReferenceObject } } - export interface DocumentV3_1 extends Omit { + export interface DocumentV3_1 extends Omit { + openapi: `3.1.${string}`; paths?: DocumentV3['paths']; info: InfoObjectV3_1; components: ComponentsV3_1; diff --git a/src/middlewares/openapi.request.validator.ts b/src/middlewares/openapi.request.validator.ts index 3b795724..c675e0d6 100644 --- a/src/middlewares/openapi.request.validator.ts +++ b/src/middlewares/openapi.request.validator.ts @@ -343,8 +343,8 @@ class Security { apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, schema: OperationObject, ): string[] { - const hasPathSecurity = schema.security?.length > 0 ?? false; - const hasRootSecurity = apiDocs.security?.length > 0 ?? false; + const hasPathSecurity = schema.security ? schema.security.length > 0 : false; + const hasRootSecurity = apiDocs.security ? apiDocs.security.length > 0 : false; let usedSecuritySchema: SecurityRequirementObject[] = []; if (hasPathSecurity) {