Skip to content
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

add ajvKeywords and useDefaults as options #932

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/framework/ajv/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AjvOptions {
}

private baseOptions(): Options {
const { coerceTypes, formats, validateFormats, serDes, ajvFormats } =
const { coerceTypes, formats, validateFormats, serDes, ajvFormats, ajvKeywords, useDefaults } =
this.options;
const serDesMap = {};
for (const serDesObject of serDes) {
Expand All @@ -67,12 +67,13 @@ export class AjvOptions {
allowUnionTypes: false,
validateSchema: false, // this is true for startup validation, thus it can be bypassed here
coerceTypes,
useDefaults: true,
useDefaults: useDefaults ?? true,
removeAdditional: false,
validateFormats: validateFormats,
formats,
serDesMap,
ajvFormats,
keywords: ajvKeywords
};

return options;
Expand Down
2 changes: 2 additions & 0 deletions src/framework/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export interface OpenApiValidatorOpts {
unknownFormats?: true | string[] | 'ignore';
serDes?: SerDes[];
formats?: Format[] | Record<string, ajv.Format>;
ajvKeywords?: ajv.Vocabulary;
useDefaults?: boolean | 'empty';
ajvFormats?: FormatsPluginOptions;
fileUploader?: boolean | multer.Options;
multerOpts?: multer.Options;
Expand Down