Skip to content

Commit

Permalink
Merge pull request #114 from ngot/add-oasValidatorOptions
Browse files Browse the repository at this point in the history
add oasValidatorOptions for oas-validator
  • Loading branch information
ngot authored Nov 15, 2021
2 parents ce0e5a1 + 2b55cd3 commit 8bc7fe6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-spiders-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"koa-oas3": minor
---

add oasValidatorOptions for oas-validator
8 changes: 7 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export interface Config {
* Optional options for sending to oas3-chow-chow/AJV
*/
validationOptions?: Partial<ChowOptions>;
/**
* Optional options for sending to oas-validator.
* https://github.com/Mermade/oas-kit/blob/main/docs/options.md
*/
oasValidatorOptions?: object;
qsParseOptions?: qs.IParseOptions;
}

Expand Down Expand Up @@ -105,6 +110,7 @@ export function validateConfig(cfg: Partial<Config>): Config {
enableTypes: ['form']
})
},
validationOptions: cfg.validationOptions
validationOptions: cfg.validationOptions,
oasValidatorOptions: cfg.oasValidatorOptions
};
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ async function loadFromFile(file?: string): Promise<any> {
async function compileOas(config: Config) {
let openApiObject: any = config.spec || await loadFromFile(config.file);
try {
await oasValidator.validateInner(openApiObject, {});
await oasValidator.validateInner(openApiObject, config.oasValidatorOptions || {});
} catch (err) {
throw new Error('Invalid Openapi document');
throw new Error('Invalid Openapi document' + err.message);
}

return {
Expand Down

0 comments on commit 8bc7fe6

Please sign in to comment.