You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fastify.swagger() crashes when a route's querystring/params/headers/cookies is a reference to a global schema. e.g.:
headers: {'$ref': 'http://example.com/headers#'}
Error: TypeError: Cannot read property 'schemas' of undefined. lib/util/common.js:96:
// $ref is in the format: #/definitions/<resolved definition>/<optional fragment>constlocalRef=jsonSchema.$ref.split('/')[2]returnresolveLocalRef(externalSchemas[localRef],externalSchemas)
At this point, $ref is #/components/schemas/def-1 and externalSchemas (openapiObject.definitions) is undefined.
I assume that this is not really supported at the moment but would like to help make it work if possible in an attempt to migrate a set of services from fastify-oas to this module. Any pointer would be appreciated. Will open a PR shortly.
/node-sandbox/node_modules/fastify-swagger/lib/util/common.js:98
return resolveLocalRef(externalSchemas[localRef], externalSchemas)
^
TypeError: Cannot read property 'schemas' of undefined
at resolveLocalRef (/node-sandbox/node_modules/fastify-swagger/lib/util/common.js:98:41)
at plainJsonObjectToOpenapi3 (/node-sandbox/node_modules/fastify-swagger/lib/spec/openapi/utils.js:95:41)
at resolveCommonParams (/node-sandbox/node_modules/fastify-swagger/lib/spec/openapi/utils.js:185:15)
at prepareOpenapiMethod (/node-sandbox/node_modules/fastify-swagger/lib/spec/openapi/utils.js:271:25)
at Object.swagger (/node-sandbox/node_modules/fastify-swagger/lib/spec/openapi/index.js:45:29)
at /node-sandbox/index.js:55:38
at Server.wrap (/node-sandbox/node_modules/fastify/lib/server.js:80:9)
at Object.onceWrapper (events.js:421:28)
at Server.emit (events.js:315:20)
at emitListeningNT (net.js:1352:10)
Expected behavior
A clear and concise description of what you expected to happen.
🐛 Bug Report
fastify.swagger()
crashes when a route's querystring/params/headers/cookies is a reference to a global schema. e.g.:Error:
TypeError: Cannot read property 'schemas' of undefined
.lib/util/common.js:96:
At this point,
$ref
is#/components/schemas/def-1
andexternalSchemas
(openapiObject.definitions
) isundefined
.I assume that this is not really supported at the moment but would like to help make it work if possible in an attempt to migrate a set of services from fastify-oas to this module. Any pointer would be appreciated. Will open a PR shortly.
May be related to #252
To Reproduce
Steps to reproduce the behavior:
Result:
Expected behavior
A clear and concise description of what you expected to happen.
Your Environment
The text was updated successfully, but these errors were encountered: