Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-swagger

Package Overview
Dependencies
Maintainers
13
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-swagger - npm Package Compare versions

Comparing version 4.10.0 to 4.11.0

7

examples/dynamic-openapi.js

@@ -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 @@ }

9

lib/spec/openapi/utils.js

@@ -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'
}
}
}
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc