diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52d40d4b..38ab9178 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0 with: license-check: true lint: true diff --git a/package.json b/package.json index d7d13845..0d2fcefe 100644 --- a/package.json +++ b/package.json @@ -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", - "fluent-json-schema": "^4.0.0", - "joi": "^17.6.0", - "joi-to-json": "^4.0.0", - "qs": "^6.10.3", - "standard": "^17.0.0", - "tap": "^16.2.0", - "tsd": "^0.30.1" + "@fastify/cookie": "^9.3.1", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.8", + "fastify": "^4.26.2", + "fluent-json-schema": "^4.2.1", + "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": "^4.5.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": [ diff --git a/tap-snapshots/test/mode/static.js.test.cjs b/tap-snapshots/test/mode/static.js.test.cjs index b3b7650e..cdc864e8 100644 --- a/tap-snapshots/test/mode/static.js.test.cjs +++ b/tap-snapshots/test/mode/static.js.test.cjs @@ -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 @@ -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" - } -} -` diff --git a/test/mode/static.js b/test/mode/static.js index ce8ff837..84f9ddb9 100644 --- a/test/mode/static.js +++ b/test/mode/static.js @@ -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) => { diff --git a/test/spec/openapi/option.js b/test/spec/openapi/option.js index b54690a6..30cee3b5 100644 --- a/test/spec/openapi/option.js +++ b/test/spec/openapi/option.js @@ -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 }) diff --git a/test/spec/openapi/route.js b/test/spec/openapi/route.js index 53b954d0..92b3bf5a 100644 --- a/test/spec/openapi/route.js +++ b/test/spec/openapi/route.js @@ -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', @@ -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', @@ -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', @@ -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', diff --git a/test/spec/openapi/schema.js b/test/spec/openapi/schema.js index 4062b081..c13bc1ae 100644 --- a/test/spec/openapi/schema.js +++ b/test/spec/openapi/schema.js @@ -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', @@ -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', @@ -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', @@ -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': { @@ -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': { @@ -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': { @@ -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: { @@ -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: { @@ -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: { @@ -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': { diff --git a/test/spec/swagger/option.js b/test/spec/swagger/option.js index f09a0c65..697a2564 100644 --- a/test/spec/swagger/option.js +++ b/test/spec/swagger/option.js @@ -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 }) diff --git a/test/spec/swagger/schema.js b/test/spec/swagger/schema.js index 5d40d54e..37be7be1 100644 --- a/test/spec/swagger/schema.js +++ b/test/spec/swagger/schema.js @@ -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', @@ -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', @@ -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: { @@ -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: { @@ -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: { @@ -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: {