From 6ebe4cb7d3a2fcf01cbcbfa3c191cb3ceaf0bc0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jun 2022 01:02:48 +0000 Subject: [PATCH 1/4] build(deps-dev): bump tsd from 0.20.0 to 0.21.0 (#15) Bumps [tsd](https://github.com/SamVerschueren/tsd) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/SamVerschueren/tsd/releases) - [Commits](https://github.com/SamVerschueren/tsd/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: tsd dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fd96d6..fccd9e5 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "fastify": "^4.0.0", "standard": "^17.0.0", "tap": "^16.0.0", - "tsd": "^0.20.0" + "tsd": "^0.21.0" }, "dependencies": { "fast-json-stringify": "^4.2.0" From 336f5c1342fbbbc6c0896765a01f64b90d0ddbad Mon Sep 17 00:00:00 2001 From: Ivan Tymoshenko <bugagashenkj@gmail.com> Date: Wed, 22 Jun 2022 17:11:36 +0300 Subject: [PATCH 2/4] Remove schema from external schemas (#14) * Remove schema from external schemas * test: add test for input schema duplicate --- index.js | 4 ++++ test/duplicate-schema.test.js | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/duplicate-schema.test.js diff --git a/index.js b/index.js index 2f14dd0..836b4c7 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,10 @@ function SerializerSelector () { } function responseSchemaCompiler (fjsOpts, { schema /* method, url, httpStatus */ }) { + if (fjsOpts.schema && schema.$id && fjsOpts.schema[schema.$id]) { + fjsOpts.schema = { ...fjsOpts.schema } + delete fjsOpts.schema[schema.$id] + } return fastJsonStringify(schema, fjsOpts) } diff --git a/test/duplicate-schema.test.js b/test/duplicate-schema.test.js new file mode 100644 index 0000000..d6904ed --- /dev/null +++ b/test/duplicate-schema.test.js @@ -0,0 +1,26 @@ +'use strict' + +const t = require('tap') +const FjsCompiler = require('../index') + +t.test('Use input schema duplicate in the externalSchemas', async t => { + t.plan(1) + const externalSchemas = { + schema1: { + $id: 'schema1', + type: 'number' + }, + schema2: { + $id: 'schema2', + type: 'string' + } + } + + const factory = FjsCompiler() + const compiler = factory(externalSchemas) + + compiler({ schema: externalSchemas.schema1 }) + compiler({ schema: externalSchemas.schema2 }) + + t.pass() +}) From f5e4f7d61b03dc6f5a6cca6cf402343a869fb247 Mon Sep 17 00:00:00 2001 From: Matteo Collina <hello@matteocollina.com> Date: Wed, 22 Jun 2022 16:13:56 +0200 Subject: [PATCH 3/4] Update fast-json-stringify v5.0.0 Signed-off-by: Matteo Collina <hello@matteocollina.com> --- README.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9958b64..6047f98 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This package is responsible for compiling the application's `response` JSON sche | v1.x | v3.x | ^3.x | | v2.x | v3.x | ^4.x | | v3.x | v4.x | ^4.x | +| v3.x | v5.x | ^4.x | ### fast-json-stringify Configuration diff --git a/package.json b/package.json index fccd9e5..2e6ee98 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "tsd": "^0.21.0" }, "dependencies": { - "fast-json-stringify": "^4.2.0" + "fast-json-stringify": "^5.0.0" }, "tsd": { "directory": "test/types" From 4e5f516f411a4af0cf86059c09bbd07fd8315084 Mon Sep 17 00:00:00 2001 From: Matteo Collina <hello@matteocollina.com> Date: Wed, 22 Jun 2022 16:14:15 +0200 Subject: [PATCH 4/4] Bumped v4.0.0 Signed-off-by: Matteo Collina <hello@matteocollina.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e6ee98..d52874a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@fastify/fast-json-stringify-compiler", "description": "Build and manage the fast-json-stringify instances for the fastify framework", - "version": "3.0.1", + "version": "4.0.0", "main": "index.js", "types": "index.d.ts", "scripts": {