From 78091943d71e8bf799497dc10270750cae2f7822 Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Tue, 27 Dec 2022 15:13:59 +0100 Subject: [PATCH] feat(resolve): add ApiDOM JSON parser Refs #2717 Refs #2718 --- .eslintrc | 6 + package-lock.json | 347 ++++-------------- package.json | 3 +- .../apidom/openapi-3-1/parsers/json/index.js | 48 +++ 4 files changed, 133 insertions(+), 271 deletions(-) create mode 100644 src/helpers/apidom/openapi-3-1/parsers/json/index.js diff --git a/.eslintrc b/.eslintrc index 23d87b56a..74727673f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,6 +32,12 @@ "ignorePackages": true } ], + "import/no-unresolved": [ + 2, + { + "ignore": ["^@swagger-api/apidom-reference/configuration/empty$"] + } + ], "prettier/prettier": "error", "no-param-reassign": 0, // needs to be eliminated in future "no-use-before-define": [2, "nofunc"] // needs to be eliminated in future diff --git a/package-lock.json b/package-lock.json index e51f372f5..9a54e47de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime-corejs3": "^7.11.2", - "@swagger-api/apidom-reference": "^0.58.0", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-reference": "^0.59.0", "cookie": "~0.5.0", "cross-fetch": "^3.1.5", "deepmerge": "~4.2.2", @@ -6782,12 +6783,12 @@ } }, "node_modules/@swagger-api/apidom-ast": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ast/0.58.0/ae487a89ed2d0168e213bcb95257ed3fd8f25405", - "integrity": "sha512-G8OmiCD3iv7mPQi/C8gLlOZny8KrmxzrDfGItqlOMmU7aBaU6ty/xPM91JkUjIJKggPShp11MnSI7Wojc1NZtg==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ast/0.59.0/c4255fd2d4705215f757fdf1302583d79ef6ca40", + "integrity": "sha512-04tOupCbAFR07ZJpTZ+z1Z50sIP2n14y7yW3pyT/Or+sYHVZn3Hp7y9Jg/m+a6q1RI7MDGgugELSfwRFg+L3jA==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", + "@babel/runtime-corejs3": "=7.20.7", "@types/ramda": "=0.28.20", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", @@ -6795,26 +6796,14 @@ "unraw": "=2.0.1" } }, - "node_modules/@swagger-api/apidom-ast/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@swagger-api/apidom-core": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-core/0.58.0/5c241031a037cec4a91bce8022ba8962aa2c3d0d", - "integrity": "sha512-6lm9nADH4LrmjhYL60IaNtVJkcnLd544Kl2xQ/OBFGF5PUaD1m/L/7VSLTYwLI8Hm3oZDvVgWDYJHfvmi6N1dg==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-core/0.59.0/370b41d2b2fcb41f40a7f42a59a95aa81dd0a1a2", + "integrity": "sha512-1nvoD5FKo6aZ1IA5aEQWFpxhAohsCt/GEkG5X9S0ckhKVULTcGZEm+p7IZSQbxMz5Z9oxqdHac+mIcTEZqvbAQ==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-ast": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-ast": "^0.59.0", "@types/ramda": "=0.28.20", "minim": "=0.23.8", "ramda": "=0.28.0", @@ -6823,74 +6812,24 @@ "stampit": "=4.3.2" } }, - "node_modules/@swagger-api/apidom-core/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@swagger-api/apidom-json-pointer": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-json-pointer/0.58.0/97bc5fff5d529817d3004b458b78edbb7b5e0fa8", - "integrity": "sha512-mozZfUb03P+SH8LsWDLMbAW8ENaTo82u6MYIzdvaQHQRft2dRMzXm9XQ3thhyZ5HE+XDu7Y/Bye97s5engix6Q==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-json-pointer/0.59.0/f67a06b21b620b277e6edaf4c00d214d961a1e0c", + "integrity": "sha512-YsXrJQ7/elVsYJsHf/peP3TG4Nlcy8pZg0HFMjFBTRlmNTtOtvJHdUn4odAlUNpBrXITrqBQmkrYYmgzxU8NyQ==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0" } }, - "node_modules/@swagger-api/apidom-json-pointer/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@swagger-api/apidom-ns-asyncapi-2": { "name": "-", "version": "0.0.1", "resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz", "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, - "node_modules/@swagger-api/apidom-ns-json-schema-draft-4": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-json-schema-draft-4/0.58.0/66a0e9f28d112a7f593994feec1bf97400ba4d7a", - "integrity": "sha512-YHAtYnX9RBvINmZAEBC20t1tvSG5xqwsKbQ6/ZCQD0rRO8f+BRXb9QnWfC63N2FFRc3A/LbE7UU1i8FDl5T7Vg==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@types/ramda": "=0.28.20", - "ramda": "=0.28.0", - "ramda-adjunct": "=3.4.0", - "stampit": "=4.3.2" - } - }, - "node_modules/@swagger-api/apidom-ns-json-schema-draft-4/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@swagger-api/apidom-ns-openapi-3-0": { "name": "-", "version": "0.0.1", @@ -6898,41 +6837,14 @@ "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, "node_modules/@swagger-api/apidom-ns-openapi-3-1": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-1/0.58.0/d7279ccbe16e3ef81a6e06ce6640dd86b29b829d", - "integrity": "sha512-GZziqzl9KGNMwC6+mvQe4uyt2TxDr22aOGh/6k8SMAocgtSnsQ0mZlEd0XPPdcf+JFcUIydLHTJJeDVaZ5DmEA==", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-ns-openapi-3-0": "^0.58.0", - "@types/ramda": "=0.28.20", - "ramda": "=0.28.0", - "ramda-adjunct": "=3.4.0", - "stampit": "=4.3.2" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-3-1/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@swagger-api/apidom-ns-openapi-3-1/node_modules/@swagger-api/apidom-ns-openapi-3-0": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-0/0.58.0/579300c13ffc537b409ba3f17b926d52e653235c", - "integrity": "sha512-OwSUuqB1pd6FUcfeiIjnLp46Wsx/zFF4N4lXDLwWYjauLmXqR4+NNoiB2PjY77By/smhPTF/1ge3PoyWGfIV6g==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-1/0.59.0/6030bb4bff4aa6a7fe88f2233e7beb7c971cf3fe", + "integrity": "sha512-mQX3pxw3yKcOQRtTE9N4Rvicv3L/LG3qUFCzMAgMGuC/XA6dhKjz5yBef2/RD/h/wWloqdWYKd6PtkzcJqfpdg==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-ns-json-schema-draft-4": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-ns-openapi-3-0": "^0.59.0", "@types/ramda": "=0.28.20", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", @@ -7000,49 +6912,36 @@ "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, "node_modules/@swagger-api/apidom-reference": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-reference/0.58.0/c370052aadfd0ff8e5b8e6dee4b344ee1513e5a6", - "integrity": "sha512-z3ieSqz8qpcEM9/eBoZ/NW0xM5qXJD55GEhS9m8B6JDiGaRyH60C2ObsQBQFrNioMr18TV6NBrZfKyWa3HkARA==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-reference/0.59.0/2ef38bd7713920d52a9a63cd2fed8d8587ad50fe", + "integrity": "sha512-ciFj5MTY3sEkrV4b3pOUmBeHXxa5CKohV4rbL3fwpl75MsyqSOkIKLXWq2Rb64hiRcl5dLJQdhslF+a9yO6aIQ==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-ast": "^0.58.0", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-json-pointer": "^0.58.0", - "@swagger-api/apidom-ns-asyncapi-2": "^0.58.0", - "@swagger-api/apidom-ns-openapi-3-0": "^0.58.0", - "@swagger-api/apidom-ns-openapi-3-1": "^0.58.0", - "@swagger-api/apidom-parser-adapter-api-design-systems-json": "^0.58.0", - "@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "^0.58.0", - "@swagger-api/apidom-parser-adapter-asyncapi-json-2": "^0.58.0", - "@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "^0.58.0", - "@swagger-api/apidom-parser-adapter-json": "^0.58.0", - "@swagger-api/apidom-parser-adapter-openapi-json-3-0": "^0.58.0", - "@swagger-api/apidom-parser-adapter-openapi-json-3-1": "^0.58.0", - "@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "^0.58.0", - "@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "^0.58.0", - "@swagger-api/apidom-parser-adapter-yaml-1-2": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-json-pointer": "^0.59.0", + "@swagger-api/apidom-ns-asyncapi-2": "^0.59.0", + "@swagger-api/apidom-ns-openapi-3-0": "^0.59.0", + "@swagger-api/apidom-ns-openapi-3-1": "^0.59.0", + "@swagger-api/apidom-parser-adapter-api-design-systems-json": "^0.59.0", + "@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "^0.59.0", + "@swagger-api/apidom-parser-adapter-asyncapi-json-2": "^0.59.0", + "@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "^0.59.0", + "@swagger-api/apidom-parser-adapter-json": "^0.59.0", + "@swagger-api/apidom-parser-adapter-openapi-json-3-0": "^0.59.0", + "@swagger-api/apidom-parser-adapter-openapi-json-3-1": "^0.59.0", + "@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "^0.59.0", + "@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "^0.59.0", + "@swagger-api/apidom-parser-adapter-yaml-1-2": "^0.59.0", "@types/ramda": "=0.28.20", "axios": "=1.2.1", - "minimatch": "=5.1.1", + "minimatch": "=5.1.2", "process": "=0.11.10", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", "stampit": "=4.3.2" } }, - "node_modules/@swagger-api/apidom-reference/node_modules/@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@swagger-api/apidom-reference/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -7052,9 +6951,9 @@ } }, "node_modules/@swagger-api/apidom-reference/node_modules/minimatch": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.1.tgz", - "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -23851,75 +23750,42 @@ } }, "@swagger-api/apidom-ast": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ast/0.58.0/ae487a89ed2d0168e213bcb95257ed3fd8f25405", - "integrity": "sha512-G8OmiCD3iv7mPQi/C8gLlOZny8KrmxzrDfGItqlOMmU7aBaU6ty/xPM91JkUjIJKggPShp11MnSI7Wojc1NZtg==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ast/0.59.0/c4255fd2d4705215f757fdf1302583d79ef6ca40", + "integrity": "sha512-04tOupCbAFR07ZJpTZ+z1Z50sIP2n14y7yW3pyT/Or+sYHVZn3Hp7y9Jg/m+a6q1RI7MDGgugELSfwRFg+L3jA==", "requires": { - "@babel/runtime-corejs3": "=7.20.6", + "@babel/runtime-corejs3": "=7.20.7", "@types/ramda": "=0.28.20", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", "stampit": "=4.3.2", "unraw": "=2.0.1" - }, - "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - } } }, "@swagger-api/apidom-core": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-core/0.58.0/5c241031a037cec4a91bce8022ba8962aa2c3d0d", - "integrity": "sha512-6lm9nADH4LrmjhYL60IaNtVJkcnLd544Kl2xQ/OBFGF5PUaD1m/L/7VSLTYwLI8Hm3oZDvVgWDYJHfvmi6N1dg==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-core/0.59.0/370b41d2b2fcb41f40a7f42a59a95aa81dd0a1a2", + "integrity": "sha512-1nvoD5FKo6aZ1IA5aEQWFpxhAohsCt/GEkG5X9S0ckhKVULTcGZEm+p7IZSQbxMz5Z9oxqdHac+mIcTEZqvbAQ==", "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-ast": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-ast": "^0.59.0", "@types/ramda": "=0.28.20", "minim": "=0.23.8", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", "short-unique-id": "=4.4.4", "stampit": "=4.3.2" - }, - "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - } } }, "@swagger-api/apidom-json-pointer": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-json-pointer/0.58.0/97bc5fff5d529817d3004b458b78edbb7b5e0fa8", - "integrity": "sha512-mozZfUb03P+SH8LsWDLMbAW8ENaTo82u6MYIzdvaQHQRft2dRMzXm9XQ3thhyZ5HE+XDu7Y/Bye97s5engix6Q==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-json-pointer/0.59.0/f67a06b21b620b277e6edaf4c00d214d961a1e0c", + "integrity": "sha512-YsXrJQ7/elVsYJsHf/peP3TG4Nlcy8pZg0HFMjFBTRlmNTtOtvJHdUn4odAlUNpBrXITrqBQmkrYYmgzxU8NyQ==", "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0" - }, - "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - } } }, "@swagger-api/apidom-ns-asyncapi-2": { @@ -23927,72 +23793,23 @@ "resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz", "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, - "@swagger-api/apidom-ns-json-schema-draft-4": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-json-schema-draft-4/0.58.0/66a0e9f28d112a7f593994feec1bf97400ba4d7a", - "integrity": "sha512-YHAtYnX9RBvINmZAEBC20t1tvSG5xqwsKbQ6/ZCQD0rRO8f+BRXb9QnWfC63N2FFRc3A/LbE7UU1i8FDl5T7Vg==", - "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@types/ramda": "=0.28.20", - "ramda": "=0.28.0", - "ramda-adjunct": "=3.4.0", - "stampit": "=4.3.2" - }, - "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - } - } - }, "@swagger-api/apidom-ns-openapi-3-0": { "version": "npm:-@0.0.1", "resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz", "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, "@swagger-api/apidom-ns-openapi-3-1": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-1/0.58.0/d7279ccbe16e3ef81a6e06ce6640dd86b29b829d", - "integrity": "sha512-GZziqzl9KGNMwC6+mvQe4uyt2TxDr22aOGh/6k8SMAocgtSnsQ0mZlEd0XPPdcf+JFcUIydLHTJJeDVaZ5DmEA==", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-1/0.59.0/6030bb4bff4aa6a7fe88f2233e7beb7c971cf3fe", + "integrity": "sha512-mQX3pxw3yKcOQRtTE9N4Rvicv3L/LG3qUFCzMAgMGuC/XA6dhKjz5yBef2/RD/h/wWloqdWYKd6PtkzcJqfpdg==", "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-ns-openapi-3-0": "^0.58.0", + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-ns-openapi-3-0": "npm:-@0.0.1", "@types/ramda": "=0.28.20", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", "stampit": "=4.3.2" - }, - "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - }, - "@swagger-api/apidom-ns-openapi-3-0": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-ns-openapi-3-0/0.58.0/579300c13ffc537b409ba3f17b926d52e653235c", - "integrity": "sha512-OwSUuqB1pd6FUcfeiIjnLp46Wsx/zFF4N4lXDLwWYjauLmXqR4+NNoiB2PjY77By/smhPTF/1ge3PoyWGfIV6g==", - "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-ns-json-schema-draft-4": "^0.58.0", - "@types/ramda": "=0.28.20", - "ramda": "=0.28.0", - "ramda-adjunct": "=3.4.0", - "stampit": "=4.3.2" - } - } } }, "@swagger-api/apidom-parser-adapter-api-design-systems-json": { @@ -24046,17 +23863,16 @@ "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" }, "@swagger-api/apidom-reference": { - "version": "0.58.0", - "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-reference/0.58.0/c370052aadfd0ff8e5b8e6dee4b344ee1513e5a6", - "integrity": "sha512-z3ieSqz8qpcEM9/eBoZ/NW0xM5qXJD55GEhS9m8B6JDiGaRyH60C2ObsQBQFrNioMr18TV6NBrZfKyWa3HkARA==", - "requires": { - "@babel/runtime-corejs3": "=7.20.6", - "@swagger-api/apidom-ast": "^0.58.0", - "@swagger-api/apidom-core": "^0.58.0", - "@swagger-api/apidom-json-pointer": "^0.58.0", + "version": "0.59.0", + "resolved": "https://npm.pkg.github.com/download/@swagger-api/apidom-reference/0.59.0/2ef38bd7713920d52a9a63cd2fed8d8587ad50fe", + "integrity": "sha512-ciFj5MTY3sEkrV4b3pOUmBeHXxa5CKohV4rbL3fwpl75MsyqSOkIKLXWq2Rb64hiRcl5dLJQdhslF+a9yO6aIQ==", + "requires": { + "@babel/runtime-corejs3": "=7.20.7", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-json-pointer": "^0.59.0", "@swagger-api/apidom-ns-asyncapi-2": "npm:-@0.0.1", "@swagger-api/apidom-ns-openapi-3-0": "npm:-@0.0.1", - "@swagger-api/apidom-ns-openapi-3-1": "^0.58.0", + "@swagger-api/apidom-ns-openapi-3-1": "^0.59.0", "@swagger-api/apidom-parser-adapter-api-design-systems-json": "npm:-@0.0.1", "@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "npm:-@0.0.1", "@swagger-api/apidom-parser-adapter-asyncapi-json-2": "npm:-@0.0.1", @@ -24069,22 +23885,13 @@ "@swagger-api/apidom-parser-adapter-yaml-1-2": "npm:-@0.0.1", "@types/ramda": "=0.28.20", "axios": "npm:-@0.0.1", - "minimatch": "=5.1.1", + "minimatch": "=5.1.2", "process": "=0.11.10", "ramda": "=0.28.0", "ramda-adjunct": "=3.4.0", "stampit": "=4.3.2" }, "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.20.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.6.tgz", - "integrity": "sha512-tqeujPiuEfcH067mx+7otTQWROVMKHXEaOQcAeNV5dDdbPWvPcFA8/W9LXw2NfjNmOetqLl03dfnG2WALPlsRQ==", - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.11" - } - }, "brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -24094,9 +23901,9 @@ } }, "minimatch": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.1.tgz", - "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", "requires": { "brace-expansion": "^2.0.1" } diff --git a/package.json b/package.json index 5b82b4087..e16bac4c8 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,8 @@ }, "dependencies": { "@babel/runtime-corejs3": "^7.11.2", - "@swagger-api/apidom-reference": "^0.58.0", + "@swagger-api/apidom-core": "^0.59.0", + "@swagger-api/apidom-reference": "^0.59.0", "cookie": "~0.5.0", "cross-fetch": "^3.1.5", "deepmerge": "~4.2.2", diff --git a/src/helpers/apidom/openapi-3-1/parsers/json/index.js b/src/helpers/apidom/openapi-3-1/parsers/json/index.js new file mode 100644 index 000000000..5508ed841 --- /dev/null +++ b/src/helpers/apidom/openapi-3-1/parsers/json/index.js @@ -0,0 +1,48 @@ +import { from, ParseResultElement } from '@swagger-api/apidom-core'; +import { ParserError } from '@swagger-api/apidom-reference/configuration/empty'; + +const JsonParser = { + name: 'json-swagger-client', + fileExtensions: [], + mediaTypes: ['application/json'], + + async canParse(file) { + const hasSupportedFileExtension = + this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension); + const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType); + + if (!hasSupportedFileExtension) return false; + if (hasSupportedMediaType) return true; + if (!hasSupportedMediaType) { + try { + JSON.parse(file.toString()); + return true; + } catch (e) { + return false; + } + } + return false; + }, + + async parse(file) { + if (this.sourceMap) { + // eslint-disable-next-line no-console + console.warn("json-swagger-client parser plugin doesn't support sourceMaps option"); + } + + const source = file.toString(); + + try { + const element = from(JSON.parse(source)); + const parseResultElement = new ParseResultElement(); + + element.classes.push('result'); + parseResultElement.push(element); + return parseResultElement; + } catch (error) { + throw new ParserError(`Error parsing "${file.uri}"`, error); + } + }, +}; + +export default JsonParser;