@trojs/openapi-server 3.6.0 → 3.6.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trojs/openapi-server",
3
3
  "description": "OpenAPI Server",
4
- "version": "3.6.0",
4
+ "version": "3.6.1",
5
5
  "author": {
6
6
  "name": "Pieter Wigboldus",
7
7
  "url": "https://trojs.org/"
@@ -40,7 +40,7 @@
40
40
  "@trojs/lint": "^0.4.0",
41
41
  "@types/node": "^24.0.0",
42
42
  "@types/express-serve-static-core": "^5.0.0",
43
- "eslint": "^9.15.0",
43
+ "eslint": "^10.0.0",
44
44
  "globals": "^17.0.0",
45
45
  "jscpd": "^4.0.5",
46
46
  "prettier": "^3.3.3",
@@ -1,13 +1,17 @@
1
- export default (logger) => (context, request, response) => {
1
+ export default (logger, validateResponse) => (context, request, response) => {
2
2
  const responseDoesntNeedValidation = response.statusCode >= 400
3
3
  if (responseDoesntNeedValidation) {
4
4
  return response.json(context.response)
5
5
  }
6
6
 
7
- const valid = context.api.validateResponse(
8
- context.response,
9
- context.operation
10
- )
7
+ const valid = validateResponse
8
+ ? (
9
+ context.api.validateResponse(
10
+ context.response,
11
+ context.operation
12
+ )
13
+ )
14
+ : null
11
15
  if (valid?.errors) {
12
16
  if (logger) {
13
17
  logger.error({
package/src/router.js CHANGED
@@ -66,9 +66,7 @@ export const setupRouter = ({
66
66
  notFound
67
67
  }
68
68
 
69
- if (validateResponse) {
70
- handlers.postResponseHandler = makeResponseValidation(logger)
71
- }
69
+ handlers.postResponseHandler = makeResponseValidation(logger, validateResponse)
72
70
 
73
71
  api.register(handlers)
74
72
 
@@ -1,3 +1,3 @@
1
- declare function _default(logger: any): (context: any, request: any, response: any) => any;
1
+ declare function _default(logger: any, validateResponse: any): (context: any, request: any, response: any) => any;
2
2
  export default _default;
3
3
  //# sourceMappingURL=response-validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"response-validation.d.ts","sourceRoot":"","sources":["../../src/handlers/response-validation.js"],"names":[],"mappings":"AAAe,yCAAa,YAAO,EAAE,YAAO,EAAE,aAAQ,SAsCrD"}
1
+ {"version":3,"file":"response-validation.d.ts","sourceRoot":"","sources":["../../src/handlers/response-validation.js"],"names":[],"mappings":"AAAe,gEAA+B,YAAO,EAAE,YAAO,EAAE,aAAQ,SA0CvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.js"],"names":[],"mappings":"AAmCO,sNAfJ;IAAuB,oBAAoB,EAAnC,MAAM;IACS,WAAW,EAA1B,MAAM;IACU,OAAO,GAAvB,MAAM,YAAC;IACU,mBAAmB,GAApC,OAAO,YAAC;IACS,YAAY,GAA7B,OAAO,YAAC;IACQ,MAAM,GAAtB,MAAM,YAAC;IACS,IAAI,GAApB,MAAM,YAAC;IACoB,gBAAgB,GAA3C,eAAe,EAAE,YAAC;IACD,mBAAmB,GAApC,OAAO,YAAC;IACS,gBAAgB,GAAjC,OAAO,YAAC;IACS,UAAU,GAA3B,OAAO,YAAC;IACe,YAAY,GAAnC,aAAa,YAAC;IACG,IAAI,GAArB,OAAO,YAAC;CAChB,GAAU;IAAE,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CA0EtE;qBAjGY,OAAO,UAAU,EAAE,MAAM;8BACzB,OAAO,UAAU,EAAE,eAAe;sBAClC,OAAO,UAAU,EAAE,OAAO;sBAC1B,OAAO,KAAK,EAAE,OAAO;4BACrB,OAAO,iBAAiB,EAAE,aAAa;+BAdrB,iBAAiB"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.js"],"names":[],"mappings":"AAmCO,sNAfJ;IAAuB,oBAAoB,EAAnC,MAAM;IACS,WAAW,EAA1B,MAAM;IACU,OAAO,GAAvB,MAAM,YAAC;IACU,mBAAmB,GAApC,OAAO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