@trojs/openapi-server 1.0.4 → 1.0.6

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
@@ -42,7 +42,8 @@ const api = new Api({
42
42
  specification: openAPISpecification,
43
43
  controllers,
44
44
  secret: 'test',
45
- logger: console
45
+ logger: console,
46
+ allErrors: true
46
47
  })
47
48
  const { app } = await setupServer({
48
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.4",
4
+ "version": "1.0.6",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@hckrnews/eslint-config": "^3.0.0",
37
37
  "@types/express-serve-static-core": "^4.17.41",
38
- "c8": "^9.0.0",
38
+ "c8": "^10.0.0",
39
39
  "eslint": "^8.23.0",
40
40
  "eslint-config-standard": "^17.1.0",
41
41
  "eslint-plugin-import": "^2.26.0",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/hckrnews/openapi-server"
51
+ "url": "https://github.com/trojs/openapi-server"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">= 18.13"
package/src/api.js CHANGED
@@ -25,6 +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
29
  */
29
30
 
30
31
  /**
@@ -35,7 +36,7 @@ export class Api {
35
36
  /**
36
37
  * @param {ApiSchema} params
37
38
  */
38
- constructor ({ version, specification, controllers, secret, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers, swagger, apiDocs }) {
39
+ constructor ({ version, specification, controllers, secret, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers, swagger, apiDocs, allErrors }) {
39
40
  this.version = version
40
41
  this.specification = specification
41
42
  this.controllers = controllers
@@ -48,6 +49,7 @@ export class Api {
48
49
  this.securityHandlers = securityHandlers || []
49
50
  this.swagger = swagger ?? true
50
51
  this.apiDocs = apiDocs ?? true
52
+ this.allErrors = allErrors ?? false
51
53
  }
52
54
 
53
55
  setup () {
@@ -71,7 +73,8 @@ export class Api {
71
73
  errorDetails: this.errorDetails,
72
74
  logger: this.logger,
73
75
  meta: this.meta,
74
- securityHandlers: this.securityHandlers
76
+ securityHandlers: this.securityHandlers,
77
+ allErrors: this.allErrors
75
78
  })
76
79
  api.init()
77
80
 
package/src/router.js CHANGED
@@ -21,13 +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
25
  * @returns {{ api, openAPISpecification: object }}
25
26
  */
26
- export const setupRouter = ({ secret, openAPISpecification, controllers, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers = [] }) => {
27
+ export const setupRouter = ({ secret, openAPISpecification, controllers, apiRoot, strictSpecification, errorDetails, logger, meta, securityHandlers = [], allErrors = false }) => {
27
28
  const api = new OpenAPIBackend({
28
29
  definition: openAPISpecification,
29
30
  apiRoot,
30
31
  strict: strictSpecification,
32
+ ajvOpts: { allErrors },
31
33
  customizeAjv: (originalAjv) => {
32
34
  addFormats(originalAjv)
33
35
  return originalAjv