@trojs/openapi-server 1.6.0 → 1.7.0

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.
Files changed (2) hide show
  1. package/package.json +5 -12
  2. package/src/router.js +8 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trojs/openapi-server",
3
3
  "description": "OpenAPI Server",
4
- "version": "1.6.0",
4
+ "version": "1.7.0",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -40,7 +40,7 @@
40
40
  "@types/node": "^22.0.0",
41
41
  "c8": "^10.0.0",
42
42
  "eslint": "^9.15.0",
43
- "eslint-config-prettier": "^9.1.0",
43
+ "eslint-config-prettier": "^10.0.0",
44
44
  "eslint-plugin-import": "^2.31.0",
45
45
  "eslint-plugin-jsdoc": "^50.5.0",
46
46
  "eslint-plugin-n": "^17.14.0",
@@ -80,15 +80,8 @@
80
80
  "url": "https://github.com/sponsors/w3nl"
81
81
  },
82
82
  "overrides": {
83
- "semver": "^7.5.3",
84
- "send": "^0.19.0",
85
- "cookie@<=0.7.0": "0.7.0",
86
- "eslint-plugin-sonarjs": {
87
- "eslint": "^9.15.0",
88
- "@typescript-eslint/eslint-plugin": "^8.0.0",
89
- "@typescript-eslint/utils": "^8.0.0",
90
- "eslint-plugin-import": "^2.31.0",
91
- "eslint-plugin-react-hooks": "^5.0.0"
92
- }
83
+ "semver@<=7.5.3": "^7.5.3",
84
+ "send@<=0.19.0": "^0.19.0",
85
+ "cookie@<=0.7.0": "0.7.0"
93
86
  }
94
87
  }
package/src/router.js CHANGED
@@ -12,6 +12,7 @@ import { unauthorized } from './handlers/unauthorized.js'
12
12
  * @typedef {import('./api.js').SecurityHandler} SecurityHandler
13
13
  * @typedef {import('./api.js').Handler} Handler
14
14
  * @typedef {import('ajv').Options} AjvOpts
15
+ * @typedef {import('openapi-backend').AjvCustomizer} AjvCustomizer
15
16
  */
16
17
 
17
18
  /**
@@ -27,6 +28,7 @@ import { unauthorized } from './handlers/unauthorized.js'
27
28
  * @param {SecurityHandler[]=} params.securityHandlers
28
29
  * @param {Handler=} params.unauthorizedHandler
29
30
  * @param {AjvOpts=} params.ajvOptions
31
+ * @param {AjvCustomizer=} params.customizeAjv
30
32
  * @param {boolean=} params.mock
31
33
  * @returns {{ api: OpenAPIBackend<any>, openAPISpecification: object }}
32
34
  */
@@ -41,17 +43,19 @@ export const setupRouter = ({
41
43
  securityHandlers = [],
42
44
  unauthorizedHandler,
43
45
  ajvOptions = {},
46
+ customizeAjv,
44
47
  mock
45
48
  }) => {
49
+ const ajvWithExtraFormats = (originalAjv) => {
50
+ addFormats(originalAjv)
51
+ return originalAjv
52
+ }
46
53
  const api = new OpenAPIBackend({
47
54
  definition: openAPISpecification,
48
55
  apiRoot,
49
56
  strict: strictSpecification,
50
57
  ajvOpts: ajvOptions,
51
- customizeAjv: (originalAjv) => {
52
- addFormats(originalAjv)
53
- return originalAjv
54
- }
58
+ customizeAjv: customizeAjv || ajvWithExtraFormats
55
59
  })
56
60
 
57
61
  api.register({