Socket
Socket
Sign inDemoInstall

@fastify/swagger

Package Overview
Dependencies
9
Maintainers
19
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.2.0 to 8.2.1

17

lib/spec/openapi/utils.js

@@ -130,7 +130,2 @@ 'use strict'

jsonSchema[key] = jsonSchema[key].replace('definitions', 'components/schemas')
} else if (key === 'examples' && Array.isArray(jsonSchema[key]) && (jsonSchema[key].length > 1)) {
jsonSchema.examples = convertExamplesArrayToObject(jsonSchema.examples)
} else if (key === 'examples' && Array.isArray(jsonSchema[key]) && (jsonSchema[key].length === 1)) {
jsonSchema.example = jsonSchema[key][0]
delete jsonSchema[key]
} else if (key === '$id' || key === '$schema') {

@@ -255,5 +250,7 @@ delete jsonSchema[key]

if (schema.examples) {
media.examples = schema.examples
if (schema.examples?.length === 1) {
media.example = schema.examples[0]
delete schema.examples
} else if (schema.examples?.length > 1) {
media.examples = convertExamplesArrayToObject(schema.examples)
// examples is invalid property of media object schema

@@ -263,6 +260,2 @@ delete schema.examples

if (schema.example) {
media.example = schema.example
}
if (schema[xExamples]) {

@@ -269,0 +262,0 @@ media.examples = schema[xExamples]

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

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

"tap": "^16.2.0",
"tsd": "^0.24.1"
"tsd": "^0.25.0"
},

@@ -54,0 +54,0 @@ "dependencies": {

@@ -783,3 +783,3 @@ # @fastify/swagger

},
"example": { "foo": "bar", "bar": "baz" }
"examples": [{ "foo": "bar", "bar": "baz" }]
}

@@ -786,0 +786,0 @@ }

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

test('transforms examples in example if single string example', async (t) => {
t.plan(3)
t.plan(2)
const fastify = Fastify()

@@ -426,8 +426,7 @@

t.ok(schema)
t.notOk(schema.properties.hello.examples)
t.equal(schema.properties.hello.example, 'world')
t.same(schema.properties.hello.examples, ['world'])
})
test('transforms examples in example if single object example', async (t) => {
t.plan(3)
t.plan(2)
const fastify = Fastify()

@@ -465,4 +464,3 @@

t.ok(schema)
t.notOk(schema.properties.hello.examples)
t.same(schema.properties.hello.example, { lorem: 'ipsum' })
t.same(schema.properties.hello.examples, [{ lorem: 'ipsum' }])
})

@@ -559,3 +557,3 @@

t.ok(schema.properties)
t.same(schema.example, { hello: 'world' })
t.notOk(schema.example)
t.same(content.example, { hello: 'world' })

@@ -565,3 +563,3 @@ })

test('copy example of response from component to media', async (t) => {
t.plan(4)
t.plan(3)
const fastify = Fastify()

@@ -597,3 +595,2 @@

t.ok(schema.properties)
t.same(schema.example, { hello: 'world' })
t.same(content.example, { hello: 'world' })

@@ -807,10 +804,3 @@ })

t.ok(schema.properties.hello.examples)
t.same(schema.properties.hello.examples, {
hello: {
value: 'hello'
},
world: {
value: 'world'
}
})
t.same(schema.properties.hello.examples, ['hello', 'world'])
})

@@ -848,10 +838,3 @@

t.ok(schema.properties.hello.examples)
t.same(schema.properties.hello.examples, {
1: {
value: 1
},
2: {
value: 2
}
})
t.same(schema.properties.hello.examples, [1, 2])
})

@@ -894,14 +877,6 @@

t.ok(schema.properties.hello.examples)
t.same(schema.properties.hello.examples, {
example1: {
value: {
lorem: 'ipsum'
}
},
example2: {
value: {
hello: 'world'
}
}
})
t.same(schema.properties.hello.examples, [
{ lorem: 'ipsum' },
{ hello: 'world' }
])
})

@@ -942,18 +917,6 @@

t.ok(schema.properties.hello.examples)
t.same(schema.properties.hello.examples, {
example1: {
value: [
'a',
'b',
'c'
]
},
example2: {
value: [
'd',
'f',
'g'
]
}
})
t.same(schema.properties.hello.examples, [
['a', 'b', 'c'],
['d', 'f', 'g']
])
})

@@ -960,0 +923,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc