fastify-swagger
Advanced tools
Comparing version 4.10.0 to 4.11.0
@@ -63,2 +63,9 @@ 'use strict' | ||
} | ||
}, | ||
default: { | ||
description: 'Default response', | ||
type: 'object', | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
@@ -65,0 +72,0 @@ } |
@@ -68,2 +68,9 @@ 'use strict' | ||
} | ||
}, | ||
default: { | ||
description: 'Default response', | ||
type: 'object', | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
@@ -70,0 +77,0 @@ } |
@@ -229,4 +229,9 @@ 'use strict' | ||
// 2xx require to be all upper-case | ||
statusCode = statusCode.toUpperCase() | ||
/** | ||
* 2xx require to be all upper-case | ||
* converts statusCode to upper case only when it is not "default" | ||
*/ | ||
if (statusCode !== 'default') { | ||
statusCode = statusCode.toUpperCase() | ||
} | ||
@@ -233,0 +238,0 @@ const response = { |
@@ -203,4 +203,8 @@ 'use strict' | ||
} | ||
statusCode = deXXStatusCode | ||
// converts statusCode to upper case only when it is not "default" | ||
if (statusCode !== 'default') { | ||
statusCode = deXXStatusCode | ||
} | ||
const response = { | ||
@@ -207,0 +211,0 @@ description: rawJsonSchema[xResponseDescription] || rawJsonSchema.description || 'Default Response' |
{ | ||
"name": "fastify-swagger", | ||
"version": "4.10.0", | ||
"version": "4.11.0", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -110,2 +110,9 @@ # fastify-swagger | ||
} | ||
}, | ||
default: { | ||
description: 'Default response', | ||
type: 'object', | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
@@ -381,3 +388,3 @@ }, | ||
'2xx': { | ||
description: '2xx' | ||
description: '2xx', | ||
type: 'object' | ||
@@ -393,3 +400,3 @@ } | ||
schema: { | ||
description: '2xx' | ||
description: '2xx', | ||
type: 'object' | ||
@@ -396,0 +403,0 @@ } |
@@ -333,1 +333,60 @@ 'use strict' | ||
}) | ||
test('support "default" parameter', async t => { | ||
const opt = { | ||
schema: { | ||
response: { | ||
200: { | ||
description: 'Expected Response', | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
default: { | ||
description: 'Default Response', | ||
type: 'object', | ||
properties: { | ||
bar: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
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.default, { | ||
description: 'Default Response', | ||
content: { | ||
'application/json': { | ||
schema: { | ||
description: 'Default Response', | ||
type: 'object', | ||
properties: { | ||
bar: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}) |
@@ -337,1 +337,55 @@ 'use strict' | ||
}) | ||
test('support "default" parameter', async t => { | ||
const opt = { | ||
schema: { | ||
response: { | ||
200: { | ||
description: 'Expected Response', | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
default: { | ||
description: 'Default Response', | ||
type: 'object', | ||
properties: { | ||
bar: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
const fastify = Fastify() | ||
fastify.register(fastifySwagger, { | ||
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.default, { | ||
description: 'Default Response', | ||
schema: { | ||
description: 'Default Response', | ||
type: 'object', | ||
properties: { | ||
bar: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
}) | ||
}) |
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
10800702
14572
705