Skip to content

Commit

Permalink
Add the custom ajv to the api
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterwigboldus-visma committed Jan 24, 2025
1 parent 0db174a commit 7b39437
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trojs/openapi-server",
"description": "OpenAPI Server",
"version": "1.7.0",
"version": "1.7.1",
"author": {
"name": "Pieter Wigboldus",
"url": "https://trojs.org/"
Expand Down
9 changes: 7 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setupRouter } from './router.js'
/**
* @typedef {import('openapi-backend').Handler} Handler
* @typedef {import('ajv').Options} AjvOpts
* @typedef {import('openapi-backend').AjvCustomizer} AjvCustomizer
* @typedef {object} Logger
* @property {Function} error
* @property {Function} warn
Expand All @@ -27,6 +28,7 @@ import { setupRouter } from './router.js'
* @property {boolean=} swagger
* @property {boolean=} apiDocs
* @property {AjvOpts=} ajvOptions
* @property {AjvCustomizer=} customizeAjv
*/

/**
Expand All @@ -53,7 +55,8 @@ export class Api {
unauthorizedHandler,
swagger,
apiDocs,
ajvOptions
ajvOptions,
customizeAjv
}) {
this.version = version
this.specification = specification
Expand All @@ -68,6 +71,7 @@ export class Api {
this.swagger = swagger ?? true
this.apiDocs = apiDocs ?? true
this.ajvOptions = ajvOptions ?? { allErrors: false }
this.customizeAjv = customizeAjv
}

setup() {
Expand Down Expand Up @@ -96,7 +100,8 @@ export class Api {
meta: this.meta,
securityHandlers: this.securityHandlers,
unauthorizedHandler: this.unauthorizedHandler,
ajvOptions: this.ajvOptions
ajvOptions: this.ajvOptions,
customizeAjv: this.customizeAjv
})
api.init()

Expand Down

0 comments on commit 7b39437

Please sign in to comment.