fastify-swagger
Advanced tools
Comparing version 4.9.0 to 4.9.1
@@ -68,4 +68,5 @@ 'use strict' | ||
// => '/user/{id}' | ||
// custom verbs at the end of a url are okay => /user::watch but should be rendered as /user:watch in swagger | ||
function formatParamUrl (url) { | ||
const regex = /:([a-zA-Z0-9_]+)/g | ||
const regex = /(?<!:):([a-zA-Z0-9_]+)/g | ||
let found = regex.exec(url) | ||
@@ -77,3 +78,4 @@ while (found !== null) { | ||
} | ||
return url | ||
return url.replace(/::/g, ':') | ||
} | ||
@@ -80,0 +82,0 @@ |
{ | ||
"name": "fastify-swagger", | ||
"version": "4.9.0", | ||
"version": "4.9.1", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -303,2 +303,41 @@ 'use strict' | ||
test('custom verbs should not be interpreted as path params', t => { | ||
t.plan(3) | ||
const opts = { | ||
schema: { | ||
params: { | ||
type: 'object', | ||
properties: { | ||
id: { type: 'string' } | ||
} | ||
} | ||
} | ||
} | ||
const fastify = Fastify() | ||
fastify.register(fastifySwagger, swaggerOption) | ||
fastify.get('/resource/:id/sub-resource::watch', opts, () => {}) | ||
fastify.ready(err => { | ||
t.error(err) | ||
const swaggerObject = fastify.swagger() | ||
Swagger.validate(swaggerObject) | ||
.then((api) => { | ||
const definedPath = api.paths['/resource/{id}/sub-resource:watch'].get | ||
t.ok(definedPath) | ||
t.same(definedPath.parameters, [{ | ||
in: 'path', | ||
name: 'id', | ||
type: 'string', | ||
required: true | ||
}]) | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
t.error(err) | ||
}) | ||
}) | ||
}) | ||
test('swagger json output should not omit consume in querystring schema', async (t) => { | ||
@@ -305,0 +344,0 @@ t.plan(1) |
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
10795575
14429