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

fastify-swagger

Package Overview
Dependencies
Maintainers
17
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 5.1.0 to 5.1.1

2

lib/spec/openapi/utils.js

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

if (jsonSchema.patternProperties) {
jsonSchema.additionalProperties = Object.values(jsonSchema.patternProperties)[0];
jsonSchema.additionalProperties = Object.values(jsonSchema.patternProperties)[0]
delete jsonSchema.patternProperties

@@ -88,0 +88,0 @@ } else if (jsonSchema.const) {

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

const Ref = require('json-schema-resolver')
const cloner = require('rfdc')({ proto: true, circles: false })
const { rawRequired } = require('../symbols')

@@ -38,3 +39,3 @@ const { xConsume } = require('../constants')

Ref () {
const externalSchemas = Array.from(sharedSchemasMap.values())
const externalSchemas = cloner(Array.from(sharedSchemasMap.values()))
return Ref(Object.assign(

@@ -41,0 +42,0 @@ { applicationUri: 'todo.com' },

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

@@ -65,3 +65,4 @@ "main": "index.js",

"json-schema-resolver": "^1.3.0",
"openapi-types": "^10.0.0"
"openapi-types": "^10.0.0",
"rfdc": "^1.3.0"
},

@@ -68,0 +69,0 @@ "standard": {

@@ -138,2 +138,32 @@ 'use strict'

test('support $ref for enums in other schemas', async (t) => {
const fastify = Fastify()
const enumSchema = { $id: 'order', anyOf: [{ type: 'string', const: 'foo' }, { type: 'string', const: 'bar' }] }
const enumRef = { $ref: 'order' }
const objectWithEnumSchema = { $id: 'object', type: 'object', properties: { type: enumRef }, required: ['type'] }
await fastify.register(fastifySwagger, openapiOption)
await fastify.register(async (instance) => {
instance.addSchema(enumSchema)
instance.addSchema(objectWithEnumSchema)
instance.post('/', { schema: { body: { type: 'object', properties: { order: { $ref: 'order' } } } } }, async () => ({ result: 'OK' }))
})
await fastify.ready()
const responseBeforeSwagger = await fastify.inject({ method: 'POST', url: '/', payload: { order: 'foo' } })
t.equal(responseBeforeSwagger.statusCode, 200)
const openapiObject = fastify.swagger()
t.equal(typeof openapiObject, 'object')
await Swagger.validate(openapiObject)
const responseAfterSwagger = await fastify.inject({ method: 'POST', url: '/', payload: { order: 'foo' } })
t.equal(responseAfterSwagger.statusCode, 200)
})
test('support nested $ref schema : complex case without modifying buildLocalReference', async (t) => {

@@ -140,0 +170,0 @@ const fastify = Fastify()

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