Skip to content

Commit

Permalink
Merge next into master (#805)
Browse files Browse the repository at this point in the history
* Updates for Fastify v5  (#788)

* chore: update fastify workflow version

* chore: update dependencies

* chore: update dependencies

* chore: update test and snapshots

---------

Co-authored-by: Giovanni Ruzzi <giovanni.ruzzi@nearform.com>

* Updates for Fastify v5  (#788)

* chore: update fastify workflow version

* chore: update dependencies

* chore: update dependencies

* chore: update test and snapshots

---------

Co-authored-by: Giovanni Ruzzi <giovanni.ruzzi@nearform.com>

* update fastify deps

* update fastify deps

* Updates for Fastify v5  (#788)

* chore: update fastify workflow version

* chore: update dependencies

* chore: update dependencies

* chore: update test and snapshots

---------

Co-authored-by: Giovanni Ruzzi <giovanni.ruzzi@nearform.com>

* Update .github/workflows/ci.yml

Co-authored-by: KaKa <23028015+climba03003@users.noreply.github.com>
Signed-off-by: James Sumners <321201+jsumners@users.noreply.github.com>

---------

Signed-off-by: James Sumners <321201+jsumners@users.noreply.github.com>
Co-authored-by: Giovanni Ruzzi <gruzzi@gmail.com>
Co-authored-by: Giovanni Ruzzi <giovanni.ruzzi@nearform.com>
Co-authored-by: KaKa <23028015+climba03003@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 15, 2024
1 parent f8591cd commit 10f7851
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v5.0.0
with:
license-check: true
lint: true
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@
"homepage": "https://github.com/fastify/fastify-swagger#readme",
"devDependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
"@fastify/cookie": "^9.0.4",
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"fastify": "^4.0.0",
"@fastify/cookie": "^10.0.0-pre.fv5.1",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^20.12.8",
"fastify": "^5.0.0-alpha.3",
"fluent-json-schema": "^5.0.0",
"joi": "^17.6.0",
"joi-to-json": "^4.0.0",
"qs": "^6.10.3",
"standard": "^17.0.0",
"tap": "^16.2.0",
"joi": "^17.13.1",
"joi-to-json": "^4.2.1",
"qs": "^6.12.1",
"standard": "^17.1.0",
"tap": "18.7.2",
"tsd": "^0.31.0"
},
"dependencies": {
"fastify-plugin": "^4.0.0",
"fastify-plugin": "^5.0.0-pre.fv5.1",
"json-schema-resolver": "^2.0.0",
"openapi-types": "^12.0.0",
"rfdc": "^1.3.0",
"yaml": "^2.2.2"
"openapi-types": "^12.1.3",
"rfdc": "^1.3.1",
"yaml": "^2.4.2"
},
"standard": {
"ignore": [
Expand Down
24 changes: 7 additions & 17 deletions tap-snapshots/test/mode/static.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/mode/static.js TAP postProcessor works, swagger route returns updated yaml > must match snapshot 1`] = `
exports[`test/mode/static.js > TAP > postProcessor works, swagger route returns updated yaml > must match snapshot 1`] = `
openapi: 3.0.0
info:
description: Test swagger specification
Expand Down Expand Up @@ -40,36 +40,26 @@ paths:
`

exports[`test/mode/static.js TAP specification validation check works > must match snapshot 1`] = `
exports[`test/mode/static.js > TAP > specification validation check works > must match snapshot 1`] = `
Error: specification is missing in the module options
`

exports[`test/mode/static.js TAP specification validation check works > must match snapshot 2`] = `
exports[`test/mode/static.js > TAP > specification validation check works > must match snapshot 2`] = `
Error: specification is not an object
`

exports[`test/mode/static.js TAP specification validation check works > must match snapshot 3`] = `
exports[`test/mode/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/mode/static.js TAP specification validation check works > must match snapshot 4`] = `
exports[`test/mode/static.js > TAP > specification validation check works > must match snapshot 4`] = `
Error: specification.path is not a string
`

exports[`test/mode/static.js TAP specification validation check works > must match snapshot 5`] = `
exports[`test/mode/static.js > TAP > specification validation check works > must match snapshot 5`] = `
Error: /hello/lionel.richie does not exist
`

exports[`test/mode/static.js TAP specification validation check works > must match snapshot 6`] = `
exports[`test/mode/static.js > TAP > specification validation check works > must match snapshot 6`] = `
Error: specification.postProcessor should be a function
`

exports[`test/mode/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"
}
}
`
2 changes: 1 addition & 1 deletion test/mode/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test('non-object specification.document throws an error', async (t) => {
t.plan(1)
const fastify = new Fastify()

t.rejects(fastify.register(fastifySwagger, config), new Error('specification.document is not an object'))
t.rejects(async () => await fastify.register(fastifySwagger, config), new Error('specification.document is not an object'))
})

test('object specification.document', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/openapi/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ test('openapi components', async (t) => {
await fastify.ready()

const openapiObject = fastify.swagger()
t.same(openapiObject.components.schemas, openapiOption.openapi.components.schemas)
t.match(openapiObject.components.schemas, openapiOption.openapi.components.schemas)
delete openapiOption.openapi.components.schemas // remove what we just added
})

Expand Down
8 changes: 4 additions & 4 deletions test/spec/openapi/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ test('route options - produces', async (t) => {
const api = await Swagger.validate(openapiObject)
const definedPath = api.paths['/'].get
t.ok(definedPath)
t.same(definedPath.responses[200].content, {
t.match(definedPath.responses[200].content, {
'*/*': {
schema: {
type: 'object',
Expand Down Expand Up @@ -234,7 +234,7 @@ test('parses form parameters when all api consumes application/x-www-form-urlenc
const api = await Swagger.validate(openapiObject)
const definedPath = api.paths['/'].post
t.ok(definedPath)
t.same(definedPath.requestBody.content, {
t.match(definedPath.requestBody.content, {
'application/x-www-form-urlencoded': {
schema: {
type: 'object',
Expand Down Expand Up @@ -423,7 +423,7 @@ test('cookie and query with serialization type', async (t) => {

const cookiesPath = api.paths['/'].get
t.ok(cookiesPath)
t.same(cookiesPath.parameters, [
t.match(cookiesPath.parameters, [
{
required: false,
in: 'cookie',
Expand All @@ -445,7 +445,7 @@ test('cookie and query with serialization type', async (t) => {

const querystringPath = api.paths['/example'].get
t.ok(querystringPath)
t.same(querystringPath.parameters, [
t.match(querystringPath.parameters, [
{
required: false,
in: 'query',
Expand Down
20 changes: 10 additions & 10 deletions test/spec/openapi/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ test('support multiple content types as response', async t => {
const api = await Swagger.validate(swaggerObject)
const definedPath = api.paths['/'].get
t.same(definedPath.responses['200'].description, 'Description and all status-code based properties are working')
t.strictSame(definedPath.responses['200'].content, {
t.match(definedPath.responses['200'].content, {
'application/json': {
schema: {
type: 'object',
Expand All @@ -175,7 +175,7 @@ test('support multiple content types as response', async t => {
}
})
t.same(definedPath.responses['4XX'].description, 'Default Response')
t.strictSame(definedPath.responses['4XX'].content, {
t.match(definedPath.responses['4XX'].content, {
'application/json': {
schema: {
type: 'object',
Expand All @@ -185,7 +185,7 @@ test('support multiple content types as response', async t => {
}
}
})
t.strictSame(definedPath.responses[300].content, {
t.match(definedPath.responses[300].content, {
'application/json': {
schema: {
type: 'object',
Expand Down Expand Up @@ -486,7 +486,7 @@ test('support "default" parameter', async t => {

const definedPath = api.paths['/'].get

t.same(definedPath.responses.default, {
t.match(definedPath.responses.default, {
description: 'Default Response',
content: {
'application/json': {
Expand Down Expand Up @@ -564,7 +564,7 @@ test('support "patternProperties" parameter', async t => {

const definedPath = api.paths['/'].get

t.same(definedPath.responses[200], {
t.match(definedPath.responses[200], {
description: 'Expected Response',
content: {
'application/json': {
Expand Down Expand Up @@ -622,7 +622,7 @@ test('properly support "patternProperties" parameter', async t => {

const definedPath = api.paths['/'].get

t.same(definedPath.responses[200], {
t.match(definedPath.responses[200], {
description: 'Expected Response',
content: {
'application/json': {
Expand Down Expand Up @@ -678,7 +678,7 @@ test('support "const" keyword', async t => {
const api = await Swagger.validate(swaggerObject)

const definedPath = api.paths['/'].post
t.same(definedPath.requestBody, {
t.match(definedPath.requestBody, {
content: {
'application/json': {
schema: {
Expand Down Expand Up @@ -740,7 +740,7 @@ test('support object properties named "const"', async t => {
const api = await Swagger.validate(swaggerObject)

const definedPath = api.paths['/'].post
t.same(definedPath.requestBody, {
t.match(definedPath.requestBody, {
content: {
'application/json': {
schema: {
Expand Down Expand Up @@ -799,7 +799,7 @@ test('support object properties with special names', async t => {
const api = await Swagger.validate(swaggerObject)

const definedPath = api.paths['/'].post
t.same(definedPath.requestBody, {
t.match(definedPath.requestBody, {
content: {
'application/json': {
schema: {
Expand Down Expand Up @@ -853,7 +853,7 @@ test('support "description" keyword', async t => {
const api = await Swagger.validate(swaggerObject)

const definedPath = api.paths['/'].post
t.same(definedPath.requestBody, {
t.match(definedPath.requestBody, {
description: 'Body description',
content: {
'application/json': {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/swagger/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ test('swagger definitions', async (t) => {
await fastify.ready()

const swaggerObject = fastify.swagger()
t.same(swaggerObject.definitions, swaggerOption.swagger.definitions)
t.match(swaggerObject.definitions, swaggerOption.swagger.definitions)
delete swaggerOption.swagger.definitions // remove what we just added
})

Expand Down
14 changes: 7 additions & 7 deletions test/spec/swagger/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ test('support "default" parameter', async t => {

const definedPath = api.paths['/'].get

t.same(definedPath.responses.default, {
t.match(definedPath.responses.default, {
description: 'Default Response',
schema: {
description: 'Default Response',
Expand Down Expand Up @@ -421,12 +421,12 @@ test('support "patternProperties" in json schema', async t => {

const definedPath = api.paths['/'].post

t.same(definedPath.parameters[0].schema, {
t.match(definedPath.parameters[0].schema, {
type: 'object',
additionalProperties: { type: 'string' }
})

t.same(definedPath.responses[200], {
t.match(definedPath.responses[200], {
description: 'Expected Response',
schema: {
description: 'Expected Response',
Expand Down Expand Up @@ -471,7 +471,7 @@ test('support "const" keyword', async t => {
const api = await Swagger.validate(swaggerObject)

const definedPath = api.paths['/'].post
t.same(definedPath.parameters[0].schema, {
t.match(definedPath.parameters[0].schema, {
type: 'object',
properties: {
obj: {
Expand Down Expand Up @@ -523,7 +523,7 @@ test('support "description" keyword', async t => {

const definedPath = api.paths['/'].post
t.same(definedPath.parameters[0].description, 'Body description')
t.same(definedPath.parameters[0].schema, {
t.match(definedPath.parameters[0].schema, {
type: 'object',
description: 'Body description',
properties: {
Expand Down Expand Up @@ -696,7 +696,7 @@ test('add default properties for url params when missing schema.params', async t

const definedPath = api.paths['/{userId}'].post

t.strictSame(definedPath.parameters[0].schema, {
t.match(definedPath.parameters[0].schema, {
type: 'object',
properties: {
bio: {
Expand Down Expand Up @@ -743,7 +743,7 @@ test('avoid overwriting params when schema.params is provided', async t => {

const definedPath = swaggerObject.paths['/{userId}'].post

t.strictSame(definedPath.parameters[0].schema, {
t.match(definedPath.parameters[0].schema, {
type: 'object',
properties: {
bio: {
Expand Down

0 comments on commit 10f7851

Please sign in to comment.