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.3.1 to 4.3.2

16

lib/spec/openapi/utils.js

@@ -99,3 +99,3 @@ 'use strict'

toOpenapiProp = function (propertyName, jsonSchemaElement) {
return {
const result = {
in: container,

@@ -106,2 +106,5 @@ name: propertyName,

}
// description should be optional
if (jsonSchemaElement.description) result.description = jsonSchemaElement.description
return result
}

@@ -111,3 +114,3 @@ break

toOpenapiProp = function (propertyName, jsonSchemaElement) {
return {
const result = {
in: container,

@@ -118,2 +121,5 @@ name: propertyName,

}
// description should be optional
if (jsonSchemaElement.description) result.description = jsonSchemaElement.description
return result
}

@@ -138,4 +144,6 @@ break

const jsonSchema = toOpenapiProp(propKey, obj[propKey])
// it is needed as required in schema is invalid prop
delete jsonSchema.schema.required
// it is needed as required in schema is invalid prop - delete only if needed
if (typeof jsonSchema.schema.required !== 'undefined') delete jsonSchema.schema.required
// it is needed as description in schema is invalid prop - delete only if needed
if (typeof jsonSchema.schema.description !== 'undefined') delete jsonSchema.schema.description
return jsonSchema

@@ -142,0 +150,0 @@ })

{
"name": "fastify-swagger",
"version": "4.3.1",
"version": "4.3.2",
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation",

@@ -47,3 +47,3 @@ "main": "index.js",

"swagger-parser": "^10.0.2",
"swagger-ui-dist": "3.43.0",
"swagger-ui-dist": "3.44.0",
"tap": "^14.11.0",

@@ -54,3 +54,3 @@ "tsd": "^0.14.0"

"fastify-plugin": "^3.0.0",
"fastify-static": "^3.3.0",
"fastify-static": "^4.0.0",
"js-yaml": "^4.0.0",

@@ -57,0 +57,0 @@ "json-schema-resolver": "^1.2.0",

@@ -1,1 +0,1 @@

{"script":["'sha256-z6bRHhPJcp/iWXjpPmZT9EdfIEfeEpyjXxRwqH6YYQM='","'sha256-4QxrjJTb/i1Es6bZkaRtGWBZu2NLzIDCG8t5G8WmVH0='"],"style":["'sha256-pyVPiLlnqL9OWVoJPs/E6VVF5hBecRzM2gBiarnaqAo='"]}
{"script":["'sha256-z6bRHhPJcp/iWXjpPmZT9EdfIEfeEpyjXxRwqH6YYQM='","'sha256-GeDavzSZ8O71Jggf/pQkKbt52dfZkrdNMQ3e+Ox+AkI='"],"style":["'sha256-pyVPiLlnqL9OWVoJPs/E6VVF5hBecRzM2gBiarnaqAo='"]}

@@ -329,1 +329,94 @@ 'use strict'

})
test('cookie, query, path description', t => {
t.plan(7)
const fastify = Fastify()
fastify.register(fastifySwagger, openapiOption)
const schemaCookies = {
schema: {
cookies: {
type: 'object',
properties: {
bar: { type: 'string', description: 'Bar' }
}
}
}
}
const schemaQuerystring = {
schema: {
querystring: {
type: 'object',
properties: {
hello: { type: 'string', description: 'Hello' }
}
}
}
}
// test without description as other test case for params already have description
const schemaParams = {
schema: {
params: {
type: 'object',
properties: {
id: { type: 'string' }
}
}
}
}
fastify.get('/', schemaCookies, () => {})
fastify.get('/example', schemaQuerystring, () => {})
fastify.get('/parameters/:id', schemaParams, () => {})
fastify.ready(err => {
t.error(err)
const openapiObject = fastify.swagger()
Swagger.validate(openapiObject)
.then(function (api) {
const cookiesPath = api.paths['/'].get
t.ok(cookiesPath)
t.same(cookiesPath.parameters, [
{
required: false,
in: 'cookie',
name: 'bar',
description: 'Bar',
schema: {
type: 'string'
}
}
])
const querystringPath = api.paths['/example'].get
t.ok(querystringPath)
t.same(querystringPath.parameters, [
{
required: false,
in: 'query',
name: 'hello',
description: 'Hello',
schema: {
type: 'string'
}
}
])
const paramPath = api.paths['/parameters/{id}'].get
t.ok(paramPath)
t.same(paramPath.parameters, [
{
required: true,
in: 'path',
name: 'id',
schema: {
type: 'string'
}
}
])
})
.catch(function (err) {
t.fail(err)
})
})
})

@@ -12,3 +12,3 @@ 'use strict'

test('suport - oneOf, anyOf, allOf', t => {
test('support - oneOf, anyOf, allOf', t => {
t.plan(3)

@@ -15,0 +15,0 @@ const fastify = Fastify()

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 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 too big to display

Sorry, the diff of this file is not supported yet

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