fastify-swagger
Advanced tools
Comparing version 4.3.1 to 4.3.2
@@ -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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10574601
12720
16
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedencoding-negotiator@2.0.1(transitive)
+ Addedfastify-static@4.6.14.7.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedprocess-warning@1.0.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedfastify-static@3.4.0(transitive)
Updatedfastify-static@^4.0.0