@fastify/swagger
Advanced tools
Comparing version 7.5.0 to 7.5.1
@@ -190,6 +190,9 @@ 'use strict' | ||
// $ref is in the format: #/definitions/<resolved definition>/<optional fragment> | ||
const localRef = jsonSchema.$ref.split('/')[2] | ||
if (externalSchemas[localRef]) return resolveLocalRef(externalSchemas[localRef], externalSchemas) | ||
// $ref is in the format: #/components/schemas/<resolved definition> | ||
return resolveLocalRef(externalSchemas[jsonSchema.$ref.split('/')[3]], externalSchemas) | ||
if (jsonSchema.$ref) { | ||
const localRef = jsonSchema.$ref.split('/')[2] | ||
if (externalSchemas[localRef]) return resolveLocalRef(externalSchemas[localRef], externalSchemas) | ||
// $ref is in the format: #/components/schemas/<resolved definition> | ||
return resolveLocalRef(externalSchemas[jsonSchema.$ref.split('/')[3]], externalSchemas) | ||
} | ||
return jsonSchema | ||
} | ||
@@ -196,0 +199,0 @@ |
{ | ||
"name": "@fastify/swagger", | ||
"version": "7.5.0", | ||
"version": "7.5.1", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"typescript": "tsd", | ||
"unit": "tap -J \"test/**/*.js\"", | ||
"unit": "tap", | ||
"unit:report": "npm run unit -- --coverage-report=html", | ||
@@ -81,3 +81,7 @@ "unit:verbose": "npm run unit -- -Rspec" | ||
"access": "public" | ||
} | ||
}, | ||
"pre-commit": [ | ||
"lint", | ||
"test" | ||
] | ||
} |
@@ -1,1 +0,1 @@ | ||
{"script":["'sha256-4IiDsMH+GkJlxivIDNfi6qk0O5HPtzyvNwVT3Wt8TIw='"],"style":[]} | ||
{"script":["'sha256-g6TK8Crx7YtGVUN10j0q8wD3cvwyzlvBMzQx4UjBPg4='"],"style":[]} |
@@ -241,1 +241,45 @@ 'use strict' | ||
}) | ||
test('uses examples if has property required in body', async (t) => { | ||
t.plan(3) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger, openapiOption) | ||
fastify.get('/', { | ||
schema: { | ||
query: { | ||
type: 'object', | ||
oneOf: [ | ||
{ | ||
properties: { | ||
bar: { type: 'number' } | ||
} | ||
}, | ||
{ | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
] | ||
}, | ||
response: { | ||
200: { | ||
type: 'object', | ||
properties: { | ||
result: { type: 'string' } | ||
} | ||
} | ||
} | ||
} | ||
}, (req, reply) => ({ result: 'OK' })) | ||
await fastify.ready() | ||
const openapiObject = fastify.swagger() | ||
const schema = openapiObject.paths['/'].get | ||
t.ok(schema) | ||
t.ok(schema.parameters) | ||
t.same(schema.parameters[0].in, 'query') | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4798992
15341