@trojs/openapi-server 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,7 +43,7 @@ const api = new Api({
43
43
  controllers,
44
44
  secret: 'test',
45
45
  logger: console,
46
- allErrors: true
46
+ ajvOptions: { allErrors: true }
47
47
  })
48
48
  const { app } = await setupServer({
49
49
  env: process.env,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trojs/openapi-server",
3
3
  "description": "OpenAPI Server",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
package/src/api.js CHANGED
@@ -25,7 +25,7 @@ import { setupRouter } from './router.js'
25
25
  * @property {SecurityHandler[]=} securityHandlers
26
26
  * @property {boolean=} swagger
27
27
  * @property {boolean=} apiDocs
28
- * @property {boolean=} allErrors
28
+ * @property {object=} ajvOptions
29
29
  */
30
30
 
31
31
  /**
@@ -36,7 +36,7 @@ export class Api {
36
36
  /**
37
37
  * @param {ApiSchema} params
38
38
  */
39
- constructor ({ version, specification, controllers, secret, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers, swagger, apiDocs, allErrors }) {
39
+ constructor ({ version, specification, controllers, secret, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers, swagger, apiDocs, ajvOptions }) {
40
40
  this.version = version
41
41
  this.specification = specification
42
42
  this.controllers = controllers
@@ -49,7 +49,7 @@ export class Api {
49
49
  this.securityHandlers = securityHandlers || []
50
50
  this.swagger = swagger ?? true
51
51
  this.apiDocs = apiDocs ?? true
52
- this.allErrors = allErrors ?? false
52
+ this.ajvOptions = ajvOptions ?? { allErrors: false }
53
53
  }
54
54
 
55
55
  setup () {
@@ -74,7 +74,7 @@ export class Api {
74
74
  logger: this.logger,
75
75
  meta: this.meta,
76
76
  securityHandlers: this.securityHandlers,
77
- allErrors: this.allErrors
77
+ ajvOptions: this.ajvOptions
78
78
  })
79
79
  api.init()
80
80
 
package/src/router.js CHANGED
@@ -21,15 +21,15 @@ import { unauthorized } from './handlers/unauthorized.js'
21
21
  * @param {Logger=} params.logger
22
22
  * @param {object=} params.meta
23
23
  * @param {SecurityHandler[]=} params.securityHandlers
24
- * @param {boolean=} params.allErrors
24
+ * @param {object=} params.ajvOptions
25
25
  * @returns {{ api, openAPISpecification: object }}
26
26
  */
27
- export const setupRouter = ({ secret, openAPISpecification, controllers, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers = [], allErrors = false }) => {
27
+ export const setupRouter = ({ secret, openAPISpecification, controllers, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers = [], ajvOptions = {} }) => {
28
28
  const api = new OpenAPIBackend({
29
29
  definition: openAPISpecification,
30
30
  apiRoot,
31
31
  strict: strictSpecification,
32
- ajvOpts: { allErrors },
32
+ ajvOpts: ajvOptions,
33
33
  customizeAjv: (originalAjv) => {
34
34
  addFormats(originalAjv)
35
35
  return originalAjv