Skip to content

Commit ac8da6c

Browse files
authored
re-enable keywords now properly supported (#1031)
1 parent 8a30a1d commit ac8da6c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/framework/ajv/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ function createAjv(
6161
for (let [formatName, formatDefinition] of Object.entries(options.formats)) {
6262
ajv.addFormat(formatName, formatDefinition);
6363
}
64-
ajv.removeKeyword('propertyNames');
65-
ajv.removeKeyword('contains');
66-
ajv.removeKeyword('const');
6764

6865
if (options.serDesMap) {
6966
// Alias for `type` that can execute AFTER x-eov-res-serdes

src/framework/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export interface NormalizedOpenApiValidatorOpts extends OpenApiValidatorOpts {
194194

195195
export namespace OpenAPIV3 {
196196
export interface DocumentV3 {
197-
openapi: string;
197+
openapi: `3.0.${string}`;
198198
info: InfoObject;
199199
servers?: ServerObject[];
200200
paths: PathsObject;
@@ -208,7 +208,8 @@ export namespace OpenAPIV3 {
208208
pathItems?: { [path: string]: PathItemObject | ReferenceObject }
209209
}
210210

211-
export interface DocumentV3_1 extends Omit<DocumentV3, 'paths' | 'info' | 'components'> {
211+
export interface DocumentV3_1 extends Omit<DocumentV3, 'paths' | 'info' | 'components'| "openapi" > {
212+
openapi: `3.1.${string}`;
212213
paths?: DocumentV3['paths'];
213214
info: InfoObjectV3_1;
214215
components: ComponentsV3_1;

src/middlewares/openapi.request.validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ class Security {
343343
apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1,
344344
schema: OperationObject,
345345
): string[] {
346-
const hasPathSecurity = schema.security?.length > 0 ?? false;
347-
const hasRootSecurity = apiDocs.security?.length > 0 ?? false;
346+
const hasPathSecurity = schema.security ? schema.security.length > 0 : false;
347+
const hasRootSecurity = apiDocs.security ? apiDocs.security.length > 0 : false;
348348

349349
let usedSecuritySchema: SecurityRequirementObject[] = [];
350350
if (hasPathSecurity) {

0 commit comments

Comments
 (0)