fastify-swagger
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -85,3 +85,3 @@ 'use strict' | ||
if (jsonSchema.patternProperties) { | ||
jsonSchema.additionalProperties = { type: 'string' } | ||
jsonSchema.additionalProperties = Object.values(jsonSchema.patternProperties)[0]; | ||
delete jsonSchema.patternProperties | ||
@@ -88,0 +88,0 @@ } else if (jsonSchema.const) { |
{ | ||
"name": "fastify-swagger", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -56,4 +56,4 @@ "main": "index.js", | ||
"swagger-parser": "^10.0.2", | ||
"swagger-ui-dist": "4.5.2", | ||
"tap": "^15.0.1", | ||
"swagger-ui-dist": "4.6.2", | ||
"tap": "^16.0.0", | ||
"tsd": "^0.19.0" | ||
@@ -60,0 +60,0 @@ }, |
@@ -12,3 +12,3 @@ # fastify-swagger | ||
If you are looking for a plugin to generate routes from an existing OpenAPI schema, check out [fastify-swaggergen](https://github.com/seriousme/fastify-swaggergen). | ||
If you are looking for a plugin to generate routes from an existing OpenAPI schema, check out [fastify-openapi-glue](https://github.com/seriousme/fastify-openapi-glue). | ||
@@ -271,4 +271,4 @@ <a name="install"></a> | ||
response, | ||
...transformedSchema | ||
} = schema | ||
const transformedSchema = Object.assign({}, schema) //shallow copy of schema | ||
let transformedUrl = url | ||
@@ -275,0 +275,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"script":["'sha256-2yQBTLGLI1sDcBILfj/o6b5ufMv6CEwPYOk3RZI/WjE='","'sha256-GeDavzSZ8O71Jggf/pQkKbt52dfZkrdNMQ3e+Ox+AkI='"],"style":["'sha256-pyVPiLlnqL9OWVoJPs/E6VVF5hBecRzM2gBiarnaqAo='"]} | ||
{"script":["'sha256-2yQBTLGLI1sDcBILfj/o6b5ufMv6CEwPYOk3RZI/WjE='","'sha256-g6TK8Crx7YtGVUN10j0q8wD3cvwyzlvBMzQx4UjBPg4='"],"style":["'sha256-pyVPiLlnqL9OWVoJPs/E6VVF5hBecRzM2gBiarnaqAo='"]} |
@@ -477,2 +477,67 @@ 'use strict' | ||
test('properly support "patternProperties" parameter', async t => { | ||
const opt = { | ||
schema: { | ||
response: { | ||
200: { | ||
description: 'Expected Response', | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'object', | ||
patternProperties: { | ||
'^[a-z]{2,3}-[a-zA-Z]{2}$': { | ||
type: 'object', | ||
properties: { | ||
foo: { type: 'number' } | ||
} | ||
} | ||
}, | ||
additionalProperties: false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
const fastify = Fastify() | ||
fastify.register(fastifySwagger, { | ||
openapi: true, | ||
routePrefix: '/docs', | ||
exposeRoute: true | ||
}) | ||
fastify.get('/', opt, () => { }) | ||
await fastify.ready() | ||
const swaggerObject = fastify.swagger() | ||
const api = await Swagger.validate(swaggerObject) | ||
const definedPath = api.paths['/'].get | ||
t.same(definedPath.responses[200], { | ||
description: 'Expected Response', | ||
content: { | ||
'application/json': { | ||
schema: { | ||
description: 'Expected Response', | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'object', | ||
additionalProperties: { | ||
type: 'object', | ||
properties: { | ||
foo: { type: 'number' } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
test('support "const" keyword', async t => { | ||
@@ -479,0 +544,0 @@ const opt = { |
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 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
16182
5479414