fastify-swagger
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -85,3 +85,3 @@ 'use strict' | ||
if (jsonSchema.patternProperties) { | ||
jsonSchema.additionalProperties = Object.values(jsonSchema.patternProperties)[0]; | ||
jsonSchema.additionalProperties = Object.values(jsonSchema.patternProperties)[0] | ||
delete jsonSchema.patternProperties | ||
@@ -88,0 +88,0 @@ } else if (jsonSchema.const) { |
@@ -6,2 +6,3 @@ 'use strict' | ||
const Ref = require('json-schema-resolver') | ||
const cloner = require('rfdc')({ proto: true, circles: false }) | ||
const { rawRequired } = require('../symbols') | ||
@@ -38,3 +39,3 @@ const { xConsume } = require('../constants') | ||
Ref () { | ||
const externalSchemas = Array.from(sharedSchemasMap.values()) | ||
const externalSchemas = cloner(Array.from(sharedSchemasMap.values())) | ||
return Ref(Object.assign( | ||
@@ -41,0 +42,0 @@ { applicationUri: 'todo.com' }, |
{ | ||
"name": "fastify-swagger", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -65,3 +65,4 @@ "main": "index.js", | ||
"json-schema-resolver": "^1.3.0", | ||
"openapi-types": "^10.0.0" | ||
"openapi-types": "^10.0.0", | ||
"rfdc": "^1.3.0" | ||
}, | ||
@@ -68,0 +69,0 @@ "standard": { |
@@ -138,2 +138,32 @@ 'use strict' | ||
test('support $ref for enums in other schemas', async (t) => { | ||
const fastify = Fastify() | ||
const enumSchema = { $id: 'order', anyOf: [{ type: 'string', const: 'foo' }, { type: 'string', const: 'bar' }] } | ||
const enumRef = { $ref: 'order' } | ||
const objectWithEnumSchema = { $id: 'object', type: 'object', properties: { type: enumRef }, required: ['type'] } | ||
await fastify.register(fastifySwagger, openapiOption) | ||
await fastify.register(async (instance) => { | ||
instance.addSchema(enumSchema) | ||
instance.addSchema(objectWithEnumSchema) | ||
instance.post('/', { schema: { body: { type: 'object', properties: { order: { $ref: 'order' } } } } }, async () => ({ result: 'OK' })) | ||
}) | ||
await fastify.ready() | ||
const responseBeforeSwagger = await fastify.inject({ method: 'POST', url: '/', payload: { order: 'foo' } }) | ||
t.equal(responseBeforeSwagger.statusCode, 200) | ||
const openapiObject = fastify.swagger() | ||
t.equal(typeof openapiObject, 'object') | ||
await Swagger.validate(openapiObject) | ||
const responseAfterSwagger = await fastify.inject({ method: 'POST', url: '/', payload: { order: 'foo' } }) | ||
t.equal(responseAfterSwagger.statusCode, 200) | ||
}) | ||
test('support nested $ref schema : complex case without modifying buildLocalReference', async (t) => { | ||
@@ -140,0 +170,0 @@ const fastify = Fastify() |
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
5480669
16203
6
+ Addedrfdc@^1.3.0