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

@fastify/swagger

Package Overview
Dependencies
Maintainers
19
Versions
41
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 8.5.1 to 8.6.0

10

index.d.ts

@@ -37,9 +37,9 @@ import { FastifyPluginCallback, FastifySchema, onRequestHookHandler, preHandlerHookHandler } from 'fastify';

deprecated?: boolean;
tags?: string[];
tags?: readonly string[];
description?: string;
summary?: string;
consumes?: string[];
produces?: string[];
consumes?: readonly string[];
produces?: readonly string[];
externalDocs?: OpenAPIV2.ExternalDocumentationObject | OpenAPIV3.ExternalDocumentationObject;
security?: Array<{ [securityLabel: string]: string[] }>;
security?: ReadonlyArray<{ [securityLabel: string]: readonly string[] }>;
/**

@@ -128,3 +128,3 @@ * OpenAPI operation unique identifier

*/
transform?: <S extends FastifySchema = FastifySchema>({ schema, url }: { schema: S, url: string }) => { schema: JSONObject, url: string };
transform?: <S extends FastifySchema = FastifySchema>({ schema, url }: { schema: S, url: string }) => { schema: FastifySchema, url: string };

@@ -131,0 +131,0 @@ refResolver?: {

@@ -260,2 +260,6 @@ 'use strict'

}
if (resolved && resolved.description) {
body.description = resolved.description
}
}

@@ -262,0 +266,0 @@

@@ -188,2 +188,3 @@ 'use strict'

in: 'body',
description: resolved && resolved.description ? resolved.description : undefined,
schema: resolved

@@ -190,0 +191,0 @@ })

{
"name": "@fastify/swagger",
"version": "8.5.1",
"version": "8.6.0",
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -814,2 +814,46 @@ 'use strict'

test('support "description" keyword', async t => {
const opt = {
schema: {
body: {
type: 'object',
description: 'Body description',
properties: {
foo: {
type: 'number'
}
}
}
}
}
const fastify = Fastify()
await fastify.register(fastifySwagger, {
openapi: true
})
fastify.post('/', opt, () => { })
await fastify.ready()
const swaggerObject = fastify.swagger()
const api = await Swagger.validate(swaggerObject)
const definedPath = api.paths['/'].post
t.same(definedPath.requestBody, {
description: 'Body description',
content: {
'application/json': {
schema: {
description: 'Body description',
type: 'object',
properties: {
foo: {
type: 'number'
}
}
}
}
}
})
})
test('support query serialization params', async t => {

@@ -816,0 +860,0 @@ const opt = {

@@ -485,2 +485,38 @@ 'use strict'

test('support "description" keyword', async t => {
const opt = {
schema: {
body: {
type: 'object',
description: 'Body description',
properties: {
foo: {
type: 'number'
}
}
}
}
}
const fastify = Fastify()
await fastify.register(fastifySwagger)
fastify.post('/', opt, () => { })
await fastify.ready()
const swaggerObject = fastify.swagger()
const api = await Swagger.validate(swaggerObject)
const definedPath = api.paths['/'].post
t.same(definedPath.parameters[0].description, 'Body description')
t.same(definedPath.parameters[0].schema, {
type: 'object',
description: 'Body description',
properties: {
foo: {
type: 'number'
}
}
})
})
test('no head routes by default', async (t) => {

@@ -487,0 +523,0 @@ const fastify = Fastify({ exposeHeadRoutes: true })

import fastify from 'fastify';
import fastifySwagger, {JSONObject} from '../..';
import fastifySwagger from '../..';
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

@@ -12,3 +12,3 @@

app.register(fastifySwagger, { transform: ({schema, url}) => ({
schema: schema as unknown as JSONObject,
schema: schema,
url: url,

@@ -15,0 +15,0 @@ })});

@@ -6,3 +6,3 @@ import fastify from 'fastify';

FastifySwaggerUiConfigOptions,
FastifySwaggerUiHooksOptions, JSONObject,
FastifySwaggerUiHooksOptions,
} from "../.."

@@ -34,3 +34,3 @@ import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

app.register(fastifySwagger, { transform: ({schema, url}) => ({
schema: schema as unknown as JSONObject,
schema: schema,
url: url,

@@ -116,2 +116,15 @@ })});

app.get('/public/readonly-schema-route', {
schema: {
description: 'returns 200 OK',
tags: ['foo'],
summary: 'qwerty',
security: [],
response: { 200: {} }
},
links: {
200: {'some-route': { operationId: 'opeId'}}
}
} as const, (req, reply) => {});
app

@@ -118,0 +131,0 @@ .register(fastifySwagger, {

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