fastify-swagger
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -212,2 +212,8 @@ 'use strict' | ||
} | ||
for (const key of Object.keys(schema)) { | ||
if (key.startsWith('x-')) { | ||
swaggerMethod[key] = schema[key] | ||
} | ||
} | ||
} | ||
@@ -214,0 +220,0 @@ |
{ | ||
"name": "fastify-swagger", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Generate Swagger files automatically for Fastify.", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"@types/node": "^14.0.1", | ||
"fastify": "^3.0.0-rc.2", | ||
"fastify": "^3.0.0-rc.4", | ||
"fs-extra": "^9.0.0", | ||
@@ -42,4 +42,4 @@ "joi": "^14.3.1", | ||
"swagger-parser": "^9.0.1", | ||
"swagger-ui-dist": "3.25.4", | ||
"tap": "^12.7.0", | ||
"swagger-ui-dist": "3.26.2", | ||
"tap": "^14.10.7", | ||
"tsd": "^0.11.0" | ||
@@ -57,10 +57,5 @@ }, | ||
"static", | ||
"tap" | ||
"tap-snapshots/*" | ||
] | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"tap" | ||
] | ||
}, | ||
"tsd": { | ||
@@ -67,0 +62,0 @@ "directory": "test/types" |
@@ -8,28 +8,73 @@ /* IMPORTANT | ||
'use strict' | ||
exports['test/static.js TAP specification validation check works > undefined 1'] = ` | ||
exports[`test/static.js TAP postProcessor works, swagger route returns updated yaml > must match snapshot 1`] = ` | ||
openapi: 3.0.0 | ||
info: | ||
description: Test swagger specification | ||
version: 1.0.0 | ||
title: Test swagger specification | ||
contact: | ||
email: super.developer@gmail.com | ||
servers: | ||
- url: 'http://localhost:4000/' | ||
description: Localhost (uses test data) | ||
paths: | ||
/status: | ||
get: | ||
description: 'Status route, so we can check if server is alive' | ||
tags: | ||
- Status | ||
responses: | ||
'200': | ||
description: Server is alive | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
health: | ||
type: boolean | ||
date: | ||
type: string | ||
example: | ||
health: true | ||
date: '2018-02-19T15:36:46.758Z' | ||
` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 1`] = ` | ||
Error: specification is missing in the module options | ||
` | ||
exports['test/static.js TAP specification validation check works > undefined 2'] = ` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 2`] = ` | ||
Error: specification is not an object | ||
` | ||
exports['test/static.js TAP specification validation check works > undefined 3'] = ` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 3`] = ` | ||
Error: both specification.path and specification.document are missing, should be path to the file or swagger document spec | ||
` | ||
exports['test/static.js TAP specification validation check works > undefined 4'] = ` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 4`] = ` | ||
Error: specification.path is not a string | ||
` | ||
exports['test/static.js TAP specification validation check works > undefined 5'] = ` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 5`] = ` | ||
Error: /hello/lionel.richie does not exist | ||
` | ||
exports['test/static.js TAP specification validation check works > undefined 6'] = ` | ||
exports[`test/static.js TAP specification validation check works > must match snapshot 6`] = ` | ||
Error: specification.postProcessor should be a function | ||
` | ||
exports['test/static.js TAP swagger route returns json > undefined 1'] = ` | ||
exports[`test/static.js TAP swagger route returns explicitly passed doc > must match snapshot 1`] = ` | ||
{ | ||
"info": { | ||
"title": "Test swagger", | ||
"description": "testing the fastify swagger api", | ||
"version": "0.1.0" | ||
} | ||
} | ||
` | ||
exports[`test/static.js TAP swagger route returns json > must match snapshot 1`] = ` | ||
{ | ||
"openapi": "3.0.0", | ||
@@ -86,46 +131,1 @@ "info": { | ||
` | ||
exports['test/static.js TAP postProcessor works, swagger route returns updated yaml > undefined 1'] = ` | ||
openapi: 3.0.0 | ||
info: | ||
description: Test swagger specification | ||
version: 1.0.0 | ||
title: Test swagger specification | ||
contact: | ||
email: super.developer@gmail.com | ||
servers: | ||
- url: 'http://localhost:4000/' | ||
description: Localhost (uses test data) | ||
paths: | ||
/status: | ||
get: | ||
description: 'Status route, so we can check if server is alive' | ||
tags: | ||
- Status | ||
responses: | ||
'200': | ||
description: Server is alive | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
health: | ||
type: boolean | ||
date: | ||
type: string | ||
example: | ||
health: true | ||
date: '2018-02-19T15:36:46.758Z' | ||
` | ||
exports['test/static.js TAP swagger route returns explicitly passed doc > undefined 1'] = ` | ||
{ | ||
"info": { | ||
"title": "Test swagger", | ||
"description": "testing the fastify swagger api", | ||
"version": "0.1.0" | ||
} | ||
} | ||
` |
@@ -64,3 +64,2 @@ 'use strict' | ||
const res = await fastify.inject('/docs/json') | ||
require('fs').writeFileSync('./out.json', JSON.stringify(res.json(), null, 2)) | ||
@@ -67,0 +66,0 @@ await Swagger.validate(res.json()) |
@@ -158,2 +158,8 @@ 'use strict' | ||
const opts8 = { | ||
schema: { | ||
'x-tension': true | ||
} | ||
} | ||
test('fastify.swagger should exist', t => { | ||
@@ -506,2 +512,24 @@ t.plan(2) | ||
test('includes swagger extensions', t => { | ||
t.plan(3) | ||
const fastify = Fastify() | ||
fastify.register(fastifySwagger, swaggerInfo) | ||
fastify.get('/', opts8, () => {}) | ||
fastify.ready(err => { | ||
t.error(err) | ||
const swaggerObject = fastify.swagger() | ||
Swagger.validate(swaggerObject) | ||
.then(function (api) { | ||
const definedPath = api.paths['/'].get | ||
t.ok(definedPath) | ||
t.same(definedPath['x-tension'], true) | ||
}) | ||
.catch(function (err) { | ||
t.fail(err) | ||
}) | ||
}) | ||
}) | ||
test('required query params', t => { | ||
@@ -508,0 +536,0 @@ t.plan(3) |
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 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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
9308507
68254
9789
7
38
31