Skip to content

re-enable keywords now properly supported #1031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/framework/ajv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ function createAjv(
for (let [formatName, formatDefinition] of Object.entries(options.formats)) {
ajv.addFormat(formatName, formatDefinition);
}
ajv.removeKeyword('propertyNames');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't these still be necessary for clients using openapi 3.0.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to load an openapi 3.0.x spec, that uses e.g. const, I get a validation at middleware construction time. And even if this was bypassed somehow, Ajv would understand the keywords. So imho there is no harm at allowing them at this level (Ajv).

ajv.removeKeyword('contains');
ajv.removeKeyword('const');

if (options.serDesMap) {
// Alias for `type` that can execute AFTER x-eov-res-serdes
Expand Down
5 changes: 3 additions & 2 deletions src/framework/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -208,7 +208,8 @@ export namespace OpenAPIV3 {
pathItems?: { [path: string]: PathItemObject | ReferenceObject }
}

export interface DocumentV3_1 extends Omit<DocumentV3, 'paths' | 'info' | 'components'> {
export interface DocumentV3_1 extends Omit<DocumentV3, 'paths' | 'info' | 'components'| "openapi" > {
openapi: `3.1.${string}`;
paths?: DocumentV3['paths'];
info: InfoObjectV3_1;
components: ComponentsV3_1;
Expand Down
4 changes: 2 additions & 2 deletions src/middlewares/openapi.request.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading