From 03279abf2f20474d36a81728e2cd1f5421277f62 Mon Sep 17 00:00:00 2001 From: Vladimir Khrebtov Date: Fri, 4 Jul 2025 11:14:58 +0300 Subject: [PATCH 1/2] chore: bump @apidevtools/swagger-parser@latest --- package-lock.json | 91 ++++++++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7139bd..3543df2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "@diplodoc/openapi-extension", "version": "2.8.0", "dependencies": { - "@apidevtools/swagger-parser": "^10.1.0", + "@apidevtools/swagger-parser": "^12.0.0", "@diplodoc/transform": "^4.31.3", "bem-cn-lite": "^4.1.0", "html-escaper": "^3.0.3", @@ -72,25 +72,19 @@ } }, "node_modules/@apidevtools/json-schema-ref-parser": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.6.tgz", - "integrity": "sha512-M3YgsLjI0lZxvrpeGVk9Ap032W6TPQkH6pRAZz81Ac3WUNF79VQooAFnp8umjvVzUmD93NkogxEwbSce7qMsUg==", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "call-me-maybe": "^1.0.1", - "js-yaml": "^3.13.1" - } - }, - "node_modules/@apidevtools/json-schema-ref-parser/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-14.0.1.tgz", + "integrity": "sha512-Oc96zvmxx1fqoSEdUmfmvvb59/KDOnUoJ7s2t7bISyAn0XEz57LCCw8k2Y4Pf3mwKaZLMciESALORLgfe2frCw==", + "license": "MIT", "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "@types/json-schema": "^7.0.15", + "js-yaml": "^4.1.0" }, - "bin": { - "js-yaml": "bin/js-yaml.js" + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" } }, "node_modules/@apidevtools/openapi-schemas": { @@ -107,17 +101,17 @@ "integrity": "sha512-QAkD5kK2b1WfjDS/UQn/qQkbwF31uqRjPTrsCs5ZG9BQGAkjwvqGFjjPqAuzac/IYzpPtRzjCP1WrTuAIjMrXg==" }, "node_modules/@apidevtools/swagger-parser": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@apidevtools/swagger-parser/-/swagger-parser-10.1.0.tgz", - "integrity": "sha512-9Kt7EuS/7WbMAUv2gSziqjvxwDbFSg3Xeyfuj5laUODX8o/k/CpsAKiQ8W7/R88eXFTMbJYg6+7uAmOWNKmwnw==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@apidevtools/swagger-parser/-/swagger-parser-12.0.0.tgz", + "integrity": "sha512-WLJIWcfOXrSKlZEM+yhA2Xzatgl488qr1FoOxixYmtWapBzwSC0gVGq4WObr4hHClMIiFFdOBdixNkvWqkWIWA==", + "license": "MIT", "dependencies": { - "@apidevtools/json-schema-ref-parser": "9.0.6", + "@apidevtools/json-schema-ref-parser": "14.0.1", "@apidevtools/openapi-schemas": "^2.1.0", "@apidevtools/swagger-methods": "^3.0.2", - "@jsdevtools/ono": "^7.1.3", - "ajv": "^8.6.3", + "ajv": "^8.17.1", "ajv-draft-04": "^1.0.0", - "call-me-maybe": "^1.0.1" + "call-me-maybe": "^1.0.2" }, "peerDependencies": { "openapi-types": ">=7" @@ -2493,11 +2487,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jsdevtools/ono": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" - }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", @@ -2735,10 +2724,10 @@ "dev": true }, "node_modules/@types/json-schema": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", - "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", - "dev": true + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "license": "MIT" }, "node_modules/@types/json-stringify-safe": { "version": "5.0.0", @@ -3187,14 +3176,15 @@ } }, "node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -3841,7 +3831,8 @@ "node_modules/call-me-maybe": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", - "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", + "license": "MIT" }, "node_modules/callsites": { "version": "3.1.0", @@ -5976,6 +5967,22 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-uri": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", + "integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -10722,6 +10729,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, "engines": { "node": ">=6" } @@ -13301,6 +13309,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } diff --git a/package.json b/package.json index f950855..c7369cc 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "typescript": "^5.0.4" }, "dependencies": { - "@apidevtools/swagger-parser": "^10.1.0", + "@apidevtools/swagger-parser": "^12.0.0", "@diplodoc/transform": "^4.31.3", "bem-cn-lite": "^4.1.0", "html-escaper": "^3.0.3", From 779fbfa7a2903727954647d1c2a2a49ca2c46ca1 Mon Sep 17 00:00:00 2001 From: Vladimir Khrebtov Date: Sun, 6 Jul 2025 20:08:01 +0300 Subject: [PATCH 2/2] fix: update test helper, read from tmp file --- src/__tests__/__helpers__/run.ts | 51 +++++++++++++++++++------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/__tests__/__helpers__/run.ts b/src/__tests__/__helpers__/run.ts index ee64aeb..f97074f 100644 --- a/src/__tests__/__helpers__/run.ts +++ b/src/__tests__/__helpers__/run.ts @@ -116,9 +116,9 @@ export async function run(spec: string) { const id = Date.now().toString(); const fs = virtualFS(); - when(jest.spyOn(nodeFS, 'readFile')).mockImplementation((_, callback) => { - callback(null, Buffer.from(spec, 'utf-8')); - }); + const tempFilePath = `/tmp/openapi-test-${id}.yaml`; + + nodeFS.writeFileSync(tempFilePath, spec); when(jest.spyOn(nodeFS.promises, 'writeFile')).mockImplementation(async (file, content) => { fs.writeFile(file.toString(), content); @@ -126,25 +126,34 @@ export async function run(spec: string) { when(jest.spyOn(nodeFS.promises, 'mkdir')).mockImplementation(async () => undefined); - await includerFunction({ - index: 0, - readBasePath: '', - writeBasePath: '', - vars: {}, - passedParams: { - input: id, - }, - tocPath: 'toc', - item: { - name: id, - href: '', - include: { - path: 'openapi', - repo: '__tests__', + try { + await includerFunction({ + index: 0, + readBasePath: '', + writeBasePath: '', + vars: {}, + passedParams: { + input: tempFilePath, }, - items: [], - }, - }); + tocPath: 'toc', + item: { + name: id, + href: '', + include: { + path: 'openapi', + repo: '__tests__', + }, + items: [], + }, + }); + + nodeFS.unlinkSync(tempFilePath); + } catch (error) { + try { + nodeFS.unlinkSync(tempFilePath); + } catch (e) {} + throw error; + } jest.clearAllMocks();