From 8ec5c92b081bf50299df6d05cb74a31c31dd9205 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sun, 5 May 2024 07:04:31 +0900 Subject: [PATCH 1/2] Biome Signed-off-by: Sora Morimoto --- .eslintignore | 29 -- .eslintrc.js | 29 -- .gitattributes | 8 - .husky/post-commit | 4 - .husky/pre-commit | 4 - .nvmrc | 1 - biome.json | 21 ++ package.json | 9 +- yarn.lock | 855 +++++---------------------------------------- 9 files changed, 104 insertions(+), 856 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .husky/post-commit delete mode 100644 .husky/pre-commit delete mode 100644 .nvmrc create mode 100644 biome.json diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 50f51994..00000000 --- a/.eslintignore +++ /dev/null @@ -1,29 +0,0 @@ -.eslintrc -node_modules -.husky -.vscode -swagger-test-cli -tests -*.ejs -*.eta -.kube -.idea -*.json -.eslintrc.js -vite.config.ts -tests/**/*.ts -tests/**/schema.js -tests/**/schema.ts -tests/**/*.d.js -swagger-test-cli -swagger-test-cli.* -templates -*.md -.github -.openapi-generator -.vscode -assets -templates -*.yml -*.yaml -*.json \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index a16d99b4..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = { - parserOptions: { - "ecmaVersion": "latest" - }, - env: { - "node": true, - "es6": true - }, - extends: [ - 'eslint:recommended', - 'plugin:prettier/recommended', - ], - plugins: [ - 'prettier', - ], - rules: { - 'prettier/prettier': [ - 'error', - { - endOfLine: 'auto', - printWidth: 80, - tabWidth: 2, - trailingComma: 'all', - semi: true, - singleQuote: true, - }, - ], - }, -}; diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 61e2fc13..00000000 --- a/.gitattributes +++ /dev/null @@ -1,8 +0,0 @@ -* text=auto -*.js text eol=lf -*.mjs text eol=lf -*.jsx text eol=lf -*.ts text eol=lf -*.tsx text eol=lf -*.json text eol=lf -*.md text eol=lf \ No newline at end of file diff --git a/.husky/post-commit b/.husky/post-commit deleted file mode 100644 index 115d75c7..00000000 --- a/.husky/post-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -git update-index -g \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 83af4040..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npm run lint:fix diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 8d2a4516..00000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18.16.1 \ No newline at end of file diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..394d1ad5 --- /dev/null +++ b/biome.json @@ -0,0 +1,21 @@ +{ + "$schema": "node_modules/@biomejs/biome/configuration_schema.json", + "formatter": { + "enabled": true, + "indentStyle": "space" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "organizeImports": { + "enabled": true + }, + "vcs": { + "clientKind": "git", + "enabled": true, + "useIgnoreFile": true + } +} diff --git a/package.json b/package.json index 74958799..3b988bd7 100644 --- a/package.json +++ b/package.json @@ -38,14 +38,13 @@ "LICENSE" ], "scripts": { + "ci": "biome ci .", "cli:help": "node index.js -h", "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts", "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts", "contributors": "all-contributors generate", "generate": "node tests/generate.js", "generate-extended": "node tests/generate-extended.js", - "lint": "eslint .", - "lint:fix": "eslint . --fix", "node": "node swagger-test-cli/generate.js", "node:debug": "node --nolazy swagger-test-cli/generate.js", "test-all": "yarn test-extended && yarn test-simple && yarn test-specific", @@ -119,6 +118,7 @@ "typescript": "5.4.5" }, "devDependencies": { + "@biomejs/biome": "1.7.2", "@types/lodash": "^4.14.195", "@types/node": "^20.4.1", "@types/prettier": "^2.7.3", @@ -126,12 +126,7 @@ "axios": "^1.4.0", "cross-env": "^7.0.3", "dotenv": "^16.3.1", - "eslint": "^8.44.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.0.0", "git-diff": "^2.0.6", - "husky": "^9.0.11", - "pretty-quick": "^4.0.0", "rimraf": "^5.0.1" }, "packageManager": "yarn@4.2.1" diff --git a/yarn.lock b/yarn.lock index 85396d5e..d7926e02 100644 --- a/yarn.lock +++ b/yarn.lock @@ -43,77 +43,101 @@ __metadata: languageName: node linkType: hard -"@eslint-community/eslint-utils@npm:^4.2.0": - version: 4.4.0 - resolution: "@eslint-community/eslint-utils@npm:4.4.0" - dependencies: - eslint-visitor-keys: "npm:^3.3.0" - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - checksum: 10c0/7e559c4ce59cd3a06b1b5a517b593912e680a7f981ae7affab0d01d709e99cd5647019be8fafa38c350305bc32f1f7d42c7073edde2ab536c745e365f37b607e +"@biomejs/biome@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/biome@npm:1.7.2" + dependencies: + "@biomejs/cli-darwin-arm64": "npm:1.7.2" + "@biomejs/cli-darwin-x64": "npm:1.7.2" + "@biomejs/cli-linux-arm64": "npm:1.7.2" + "@biomejs/cli-linux-arm64-musl": "npm:1.7.2" + "@biomejs/cli-linux-x64": "npm:1.7.2" + "@biomejs/cli-linux-x64-musl": "npm:1.7.2" + "@biomejs/cli-win32-arm64": "npm:1.7.2" + "@biomejs/cli-win32-x64": "npm:1.7.2" + dependenciesMeta: + "@biomejs/cli-darwin-arm64": + optional: true + "@biomejs/cli-darwin-x64": + optional: true + "@biomejs/cli-linux-arm64": + optional: true + "@biomejs/cli-linux-arm64-musl": + optional: true + "@biomejs/cli-linux-x64": + optional: true + "@biomejs/cli-linux-x64-musl": + optional: true + "@biomejs/cli-win32-arm64": + optional: true + "@biomejs/cli-win32-x64": + optional: true + bin: + biome: bin/biome + checksum: 10c0/c0fb7b653db6df2e2338f84c1105847713e60ec5c3737f3bbc7df2dd4b1b02e981af81290808806fe0342e9a530b2a83b1550adf9b96f4cab0d13c188070aaef languageName: node linkType: hard -"@eslint-community/regexpp@npm:^4.6.1": - version: 4.10.0 - resolution: "@eslint-community/regexpp@npm:4.10.0" - checksum: 10c0/c5f60ef1f1ea7649fa7af0e80a5a79f64b55a8a8fa5086de4727eb4c86c652aedee407a9c143b8995d2c0b2d75c1222bec9ba5d73dbfc1f314550554f0979ef4 +"@biomejs/cli-darwin-arm64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-darwin-arm64@npm:1.7.2" + conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@eslint/eslintrc@npm:^2.1.4": - version: 2.1.4 - resolution: "@eslint/eslintrc@npm:2.1.4" - dependencies: - ajv: "npm:^6.12.4" - debug: "npm:^4.3.2" - espree: "npm:^9.6.0" - globals: "npm:^13.19.0" - ignore: "npm:^5.2.0" - import-fresh: "npm:^3.2.1" - js-yaml: "npm:^4.1.0" - minimatch: "npm:^3.1.2" - strip-json-comments: "npm:^3.1.1" - checksum: 10c0/32f67052b81768ae876c84569ffd562491ec5a5091b0c1e1ca1e0f3c24fb42f804952fdd0a137873bc64303ba368a71ba079a6f691cee25beee9722d94cc8573 +"@biomejs/cli-darwin-x64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-darwin-x64@npm:1.7.2" + conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@eslint/js@npm:8.57.0": - version: 8.57.0 - resolution: "@eslint/js@npm:8.57.0" - checksum: 10c0/9a518bb8625ba3350613903a6d8c622352ab0c6557a59fe6ff6178bf882bf57123f9d92aa826ee8ac3ee74b9c6203fe630e9ee00efb03d753962dcf65ee4bd94 +"@biomejs/cli-linux-arm64-musl@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-linux-arm64-musl@npm:1.7.2" + conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@exodus/schemasafe@npm:^1.0.0-rc.2": - version: 1.3.0 - resolution: "@exodus/schemasafe@npm:1.3.0" - checksum: 10c0/e19397c14db76342154c32a9088536149babfd9b18ecae815add0b2f911d9aa292aa51c6ab33b857b4b6bb371a74ebde845e6f17b2824e73b4e307230f23f86a +"@biomejs/cli-linux-arm64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-linux-arm64@npm:1.7.2" + conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@humanwhocodes/config-array@npm:^0.11.14": - version: 0.11.14 - resolution: "@humanwhocodes/config-array@npm:0.11.14" - dependencies: - "@humanwhocodes/object-schema": "npm:^2.0.2" - debug: "npm:^4.3.1" - minimatch: "npm:^3.0.5" - checksum: 10c0/66f725b4ee5fdd8322c737cb5013e19fac72d4d69c8bf4b7feb192fcb83442b035b92186f8e9497c220e58b2d51a080f28a73f7899bc1ab288c3be172c467541 +"@biomejs/cli-linux-x64-musl@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-linux-x64-musl@npm:1.7.2" + conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@humanwhocodes/module-importer@npm:^1.0.1": - version: 1.0.1 - resolution: "@humanwhocodes/module-importer@npm:1.0.1" - checksum: 10c0/909b69c3b86d482c26b3359db16e46a32e0fb30bd306a3c176b8313b9e7313dba0f37f519de6aa8b0a1921349e505f259d19475e123182416a506d7f87e7f529 +"@biomejs/cli-linux-x64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-linux-x64@npm:1.7.2" + conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@humanwhocodes/object-schema@npm:^2.0.2": - version: 2.0.3 - resolution: "@humanwhocodes/object-schema@npm:2.0.3" - checksum: 10c0/80520eabbfc2d32fe195a93557cef50dfe8c8905de447f022675aaf66abc33ae54098f5ea78548d925aa671cd4ab7c7daa5ad704fe42358c9b5e7db60f80696c +"@biomejs/cli-win32-arm64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-win32-arm64@npm:1.7.2" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@biomejs/cli-win32-x64@npm:1.7.2": + version: 1.7.2 + resolution: "@biomejs/cli-win32-x64@npm:1.7.2" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"@exodus/schemasafe@npm:^1.0.0-rc.2": + version: 1.3.0 + resolution: "@exodus/schemasafe@npm:1.3.0" + checksum: 10c0/e19397c14db76342154c32a9088536149babfd9b18ecae815add0b2f911d9aa292aa51c6ab33b857b4b6bb371a74ebde845e6f17b2824e73b4e307230f23f86a languageName: node linkType: hard @@ -131,33 +155,6 @@ __metadata: languageName: node linkType: hard -"@nodelib/fs.scandir@npm:2.1.5": - version: 2.1.5 - resolution: "@nodelib/fs.scandir@npm:2.1.5" - dependencies: - "@nodelib/fs.stat": "npm:2.0.5" - run-parallel: "npm:^1.1.9" - checksum: 10c0/732c3b6d1b1e967440e65f284bd06e5821fedf10a1bea9ed2bb75956ea1f30e08c44d3def9d6a230666574edbaf136f8cfd319c14fd1f87c66e6a44449afb2eb - languageName: node - linkType: hard - -"@nodelib/fs.stat@npm:2.0.5": - version: 2.0.5 - resolution: "@nodelib/fs.stat@npm:2.0.5" - checksum: 10c0/88dafe5e3e29a388b07264680dc996c17f4bda48d163a9d4f5c1112979f0ce8ec72aa7116122c350b4e7976bc5566dc3ddb579be1ceaacc727872eb4ed93926d - languageName: node - linkType: hard - -"@nodelib/fs.walk@npm:^1.2.8": - version: 1.2.8 - resolution: "@nodelib/fs.walk@npm:1.2.8" - dependencies: - "@nodelib/fs.scandir": "npm:2.1.5" - fastq: "npm:^1.6.0" - checksum: 10c0/db9de047c3bb9b51f9335a7bb46f4fcfb6829fb628318c12115fbaf7d369bfce71c15b103d1fc3b464812d936220ee9bc1c8f762d032c9f6be9acc99249095b1 - languageName: node - linkType: hard - "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -165,13 +162,6 @@ __metadata: languageName: node linkType: hard -"@pkgr/core@npm:^0.1.0": - version: 0.1.1 - resolution: "@pkgr/core@npm:0.1.1" - checksum: 10c0/3f7536bc7f57320ab2cf96f8973664bef624710c403357429fbf680a5c3b4843c1dbd389bb43daa6b1f6f1f007bb082f5abcb76bb2b5dc9f421647743b71d3d8 - languageName: node - linkType: hard - "@sindresorhus/is@npm:^4.6.0": version: 4.6.0 resolution: "@sindresorhus/is@npm:4.6.0" @@ -209,43 +199,6 @@ __metadata: languageName: node linkType: hard -"@ungap/structured-clone@npm:^1.2.0": - version: 1.2.0 - resolution: "@ungap/structured-clone@npm:1.2.0" - checksum: 10c0/8209c937cb39119f44eb63cf90c0b73e7c754209a6411c707be08e50e29ee81356dca1a848a405c8bdeebfe2f5e4f831ad310ae1689eeef65e7445c090c6657d - languageName: node - linkType: hard - -"acorn-jsx@npm:^5.3.2": - version: 5.3.2 - resolution: "acorn-jsx@npm:5.3.2" - peerDependencies: - acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 10c0/4c54868fbef3b8d58927d5e33f0a4de35f59012fe7b12cf9dfbb345fb8f46607709e1c4431be869a23fb63c151033d84c4198fa9f79385cec34fcb1dd53974c1 - languageName: node - linkType: hard - -"acorn@npm:^8.9.0": - version: 8.11.3 - resolution: "acorn@npm:8.11.3" - bin: - acorn: bin/acorn - checksum: 10c0/3ff155f8812e4a746fee8ecff1f227d527c4c45655bb1fad6347c3cb58e46190598217551b1500f18542d2bbe5c87120cb6927f5a074a59166fbdd9468f0a299 - languageName: node - linkType: hard - -"ajv@npm:^6.12.4": - version: 6.12.6 - resolution: "ajv@npm:6.12.6" - dependencies: - fast-deep-equal: "npm:^3.1.1" - fast-json-stable-stringify: "npm:^2.0.0" - json-schema-traverse: "npm:^0.4.1" - uri-js: "npm:^4.2.2" - checksum: 10c0/41e23642cbe545889245b9d2a45854ebba51cda6c778ebced9649420d9205f2efb39cb43dbc41e358409223b1ea43303ae4839db682c848b891e4811da1a5a71 - languageName: node - linkType: hard - "all-contributors-cli@npm:^6.26.1": version: 6.26.1 resolution: "all-contributors-cli@npm:6.26.1" @@ -542,7 +495,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.1, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.1": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -560,18 +513,6 @@ __metadata: languageName: node linkType: hard -"debug@npm:^4.3.1, debug@npm:^4.3.2": - version: 4.3.4 - resolution: "debug@npm:4.3.4" - dependencies: - ms: "npm:2.1.2" - peerDependenciesMeta: - supports-color: - optional: true - checksum: 10c0/cedbec45298dd5c501d01b92b119cd3faebe5438c3917ff11ae1bff86a6c722930ac9c8659792824013168ba6db7c4668225d845c633fbdafbbf902a6389f736 - languageName: node - linkType: hard - "decamelize@npm:^1.2.0": version: 1.2.0 resolution: "decamelize@npm:1.2.0" @@ -579,13 +520,6 @@ __metadata: languageName: node linkType: hard -"deep-is@npm:^0.1.3": - version: 0.1.4 - resolution: "deep-is@npm:0.1.4" - checksum: 10c0/7f0ee496e0dff14a573dc6127f14c95061b448b87b995fc96c017ce0a1e66af1675e73f1d6064407975bc4ea6ab679497a29fff7b5b9c4e99cb10797c1ad0b4c - languageName: node - linkType: hard - "delayed-stream@npm:~1.0.0": version: 1.0.0 resolution: "delayed-stream@npm:1.0.0" @@ -607,15 +541,6 @@ __metadata: languageName: node linkType: hard -"doctrine@npm:^3.0.0": - version: 3.0.0 - resolution: "doctrine@npm:3.0.0" - dependencies: - esutils: "npm:^2.0.2" - checksum: 10c0/c96bdccabe9d62ab6fea9399fdff04a66e6563c1d6fb3a3a063e8d53c3bb136ba63e84250bbf63d00086a769ad53aef92d2bd483f03f837fc97b71cbee6b2520 - languageName: node - linkType: hard - "dotenv@npm:^16.3.1": version: 16.4.5 resolution: "dotenv@npm:16.4.5" @@ -681,152 +606,6 @@ __metadata: languageName: node linkType: hard -"escape-string-regexp@npm:^4.0.0": - version: 4.0.0 - resolution: "escape-string-regexp@npm:4.0.0" - checksum: 10c0/9497d4dd307d845bd7f75180d8188bb17ea8c151c1edbf6b6717c100e104d629dc2dfb687686181b0f4b7d732c7dfdc4d5e7a8ff72de1b0ca283a75bbb3a9cd9 - languageName: node - linkType: hard - -"eslint-config-prettier@npm:^9.1.0": - version: 9.1.0 - resolution: "eslint-config-prettier@npm:9.1.0" - peerDependencies: - eslint: ">=7.0.0" - bin: - eslint-config-prettier: bin/cli.js - checksum: 10c0/6d332694b36bc9ac6fdb18d3ca2f6ac42afa2ad61f0493e89226950a7091e38981b66bac2b47ba39d15b73fff2cd32c78b850a9cf9eed9ca9a96bfb2f3a2f10d - languageName: node - linkType: hard - -"eslint-plugin-prettier@npm:^5.0.0": - version: 5.1.3 - resolution: "eslint-plugin-prettier@npm:5.1.3" - dependencies: - prettier-linter-helpers: "npm:^1.0.0" - synckit: "npm:^0.8.6" - peerDependencies: - "@types/eslint": ">=8.0.0" - eslint: ">=8.0.0" - eslint-config-prettier: "*" - prettier: ">=3.0.0" - peerDependenciesMeta: - "@types/eslint": - optional: true - eslint-config-prettier: - optional: true - checksum: 10c0/f45d5fc1fcfec6b0cf038a7a65ddd10a25df4fe3f9e1f6b7f0d5100e66f046a26a2492e69ee765dddf461b93c114cf2e1eb18d4970aafa6f385448985c136e09 - languageName: node - linkType: hard - -"eslint-scope@npm:^7.2.2": - version: 7.2.2 - resolution: "eslint-scope@npm:7.2.2" - dependencies: - esrecurse: "npm:^4.3.0" - estraverse: "npm:^5.2.0" - checksum: 10c0/613c267aea34b5a6d6c00514e8545ef1f1433108097e857225fed40d397dd6b1809dffd11c2fde23b37ca53d7bf935fe04d2a18e6fc932b31837b6ad67e1c116 - languageName: node - linkType: hard - -"eslint-visitor-keys@npm:^3.3.0, eslint-visitor-keys@npm:^3.4.1, eslint-visitor-keys@npm:^3.4.3": - version: 3.4.3 - resolution: "eslint-visitor-keys@npm:3.4.3" - checksum: 10c0/92708e882c0a5ffd88c23c0b404ac1628cf20104a108c745f240a13c332a11aac54f49a22d5762efbffc18ecbc9a580d1b7ad034bf5f3cc3307e5cbff2ec9820 - languageName: node - linkType: hard - -"eslint@npm:^8.44.0": - version: 8.57.0 - resolution: "eslint@npm:8.57.0" - dependencies: - "@eslint-community/eslint-utils": "npm:^4.2.0" - "@eslint-community/regexpp": "npm:^4.6.1" - "@eslint/eslintrc": "npm:^2.1.4" - "@eslint/js": "npm:8.57.0" - "@humanwhocodes/config-array": "npm:^0.11.14" - "@humanwhocodes/module-importer": "npm:^1.0.1" - "@nodelib/fs.walk": "npm:^1.2.8" - "@ungap/structured-clone": "npm:^1.2.0" - ajv: "npm:^6.12.4" - chalk: "npm:^4.0.0" - cross-spawn: "npm:^7.0.2" - debug: "npm:^4.3.2" - doctrine: "npm:^3.0.0" - escape-string-regexp: "npm:^4.0.0" - eslint-scope: "npm:^7.2.2" - eslint-visitor-keys: "npm:^3.4.3" - espree: "npm:^9.6.1" - esquery: "npm:^1.4.2" - esutils: "npm:^2.0.2" - fast-deep-equal: "npm:^3.1.3" - file-entry-cache: "npm:^6.0.1" - find-up: "npm:^5.0.0" - glob-parent: "npm:^6.0.2" - globals: "npm:^13.19.0" - graphemer: "npm:^1.4.0" - ignore: "npm:^5.2.0" - imurmurhash: "npm:^0.1.4" - is-glob: "npm:^4.0.0" - is-path-inside: "npm:^3.0.3" - js-yaml: "npm:^4.1.0" - json-stable-stringify-without-jsonify: "npm:^1.0.1" - levn: "npm:^0.4.1" - lodash.merge: "npm:^4.6.2" - minimatch: "npm:^3.1.2" - natural-compare: "npm:^1.4.0" - optionator: "npm:^0.9.3" - strip-ansi: "npm:^6.0.1" - text-table: "npm:^0.2.0" - bin: - eslint: bin/eslint.js - checksum: 10c0/00bb96fd2471039a312435a6776fe1fd557c056755eaa2b96093ef3a8508c92c8775d5f754768be6b1dddd09fdd3379ddb231eeb9b6c579ee17ea7d68000a529 - languageName: node - linkType: hard - -"espree@npm:^9.6.0, espree@npm:^9.6.1": - version: 9.6.1 - resolution: "espree@npm:9.6.1" - dependencies: - acorn: "npm:^8.9.0" - acorn-jsx: "npm:^5.3.2" - eslint-visitor-keys: "npm:^3.4.1" - checksum: 10c0/1a2e9b4699b715347f62330bcc76aee224390c28bb02b31a3752e9d07549c473f5f986720483c6469cf3cfb3c9d05df612ffc69eb1ee94b54b739e67de9bb460 - languageName: node - linkType: hard - -"esquery@npm:^1.4.2": - version: 1.5.0 - resolution: "esquery@npm:1.5.0" - dependencies: - estraverse: "npm:^5.1.0" - checksum: 10c0/a084bd049d954cc88ac69df30534043fb2aee5555b56246493f42f27d1e168f00d9e5d4192e46f10290d312dc30dc7d58994d61a609c579c1219d636996f9213 - languageName: node - linkType: hard - -"esrecurse@npm:^4.3.0": - version: 4.3.0 - resolution: "esrecurse@npm:4.3.0" - dependencies: - estraverse: "npm:^5.2.0" - checksum: 10c0/81a37116d1408ded88ada45b9fb16dbd26fba3aadc369ce50fcaf82a0bac12772ebd7b24cd7b91fc66786bf2c1ac7b5f196bc990a473efff972f5cb338877cf5 - languageName: node - linkType: hard - -"estraverse@npm:^5.1.0, estraverse@npm:^5.2.0": - version: 5.3.0 - resolution: "estraverse@npm:5.3.0" - checksum: 10c0/1ff9447b96263dec95d6d67431c5e0771eb9776427421260a3e2f0fdd5d6bd4f8e37a7338f5ad2880c9f143450c9b1e4fc2069060724570a49cf9cf0312bd107 - languageName: node - linkType: hard - -"esutils@npm:^2.0.2": - version: 2.0.3 - resolution: "esutils@npm:2.0.3" - checksum: 10c0/9a2fe69a41bfdade834ba7c42de4723c97ec776e40656919c62cbd13607c45e127a003f05f724a1ea55e5029a4cf2de444b13009f2af71271e42d93a637137c7 - languageName: node - linkType: hard - "eta@npm:^2.2.0": version: 2.2.0 resolution: "eta@npm:2.2.0" @@ -834,23 +613,6 @@ __metadata: languageName: node linkType: hard -"execa@npm:^5.1.1": - version: 5.1.1 - resolution: "execa@npm:5.1.1" - dependencies: - cross-spawn: "npm:^7.0.3" - get-stream: "npm:^6.0.0" - human-signals: "npm:^2.1.0" - is-stream: "npm:^2.0.0" - merge-stream: "npm:^2.0.0" - npm-run-path: "npm:^4.0.1" - onetime: "npm:^5.1.2" - signal-exit: "npm:^3.0.3" - strip-final-newline: "npm:^2.0.0" - checksum: 10c0/c8e615235e8de4c5addf2fa4c3da3e3aa59ce975a3e83533b4f6a71750fb816a2e79610dc5f1799b6e28976c9ae86747a36a606655bf8cb414a74d8d507b304f - languageName: node - linkType: hard - "external-editor@npm:^3.0.3": version: 3.1.0 resolution: "external-editor@npm:3.1.0" @@ -862,34 +624,6 @@ __metadata: languageName: node linkType: hard -"fast-deep-equal@npm:^3.1.1, fast-deep-equal@npm:^3.1.3": - version: 3.1.3 - resolution: "fast-deep-equal@npm:3.1.3" - checksum: 10c0/40dedc862eb8992c54579c66d914635afbec43350afbbe991235fdcb4e3a8d5af1b23ae7e79bef7d4882d0ecee06c3197488026998fb19f72dc95acff1d1b1d0 - languageName: node - linkType: hard - -"fast-diff@npm:^1.1.2": - version: 1.3.0 - resolution: "fast-diff@npm:1.3.0" - checksum: 10c0/5c19af237edb5d5effda008c891a18a585f74bf12953be57923f17a3a4d0979565fc64dbc73b9e20926b9d895f5b690c618cbb969af0cf022e3222471220ad29 - languageName: node - linkType: hard - -"fast-json-stable-stringify@npm:^2.0.0": - version: 2.1.0 - resolution: "fast-json-stable-stringify@npm:2.1.0" - checksum: 10c0/7f081eb0b8a64e0057b3bb03f974b3ef00135fbf36c1c710895cd9300f13c94ba809bb3a81cf4e1b03f6e5285610a61abbd7602d0652de423144dfee5a389c9b - languageName: node - linkType: hard - -"fast-levenshtein@npm:^2.0.6": - version: 2.0.6 - resolution: "fast-levenshtein@npm:2.0.6" - checksum: 10c0/111972b37338bcb88f7d9e2c5907862c280ebf4234433b95bc611e518d192ccb2d38119c4ac86e26b668d75f7f3894f4ff5c4982899afced7ca78633b08287c4 - languageName: node - linkType: hard - "fast-safe-stringify@npm:^2.0.7": version: 2.1.1 resolution: "fast-safe-stringify@npm:2.1.1" @@ -897,15 +631,6 @@ __metadata: languageName: node linkType: hard -"fastq@npm:^1.6.0": - version: 1.17.1 - resolution: "fastq@npm:1.17.1" - dependencies: - reusify: "npm:^1.0.4" - checksum: 10c0/1095f16cea45fb3beff558bb3afa74ca7a9250f5a670b65db7ed585f92b4b48381445cd328b3d87323da81e43232b5d5978a8201bde84e0cd514310f1ea6da34 - languageName: node - linkType: hard - "fetch-blob@npm:^3.1.2, fetch-blob@npm:^3.1.4": version: 3.2.0 resolution: "fetch-blob@npm:3.2.0" @@ -925,15 +650,6 @@ __metadata: languageName: node linkType: hard -"file-entry-cache@npm:^6.0.1": - version: 6.0.1 - resolution: "file-entry-cache@npm:6.0.1" - dependencies: - flat-cache: "npm:^3.0.4" - checksum: 10c0/58473e8a82794d01b38e5e435f6feaf648e3f36fdb3a56e98f417f4efae71ad1c0d4ebd8a9a7c50c3ad085820a93fc7494ad721e0e4ebc1da3573f4e1c3c7cdd - languageName: node - linkType: hard - "find-up@npm:^4.1.0": version: 4.1.0 resolution: "find-up@npm:4.1.0" @@ -944,34 +660,6 @@ __metadata: languageName: node linkType: hard -"find-up@npm:^5.0.0": - version: 5.0.0 - resolution: "find-up@npm:5.0.0" - dependencies: - locate-path: "npm:^6.0.0" - path-exists: "npm:^4.0.0" - checksum: 10c0/062c5a83a9c02f53cdd6d175a37ecf8f87ea5bbff1fdfb828f04bfa021441bc7583e8ebc0872a4c1baab96221fb8a8a275a19809fb93fbc40bd69ec35634069a - languageName: node - linkType: hard - -"flat-cache@npm:^3.0.4": - version: 3.2.0 - resolution: "flat-cache@npm:3.2.0" - dependencies: - flatted: "npm:^3.2.9" - keyv: "npm:^4.5.3" - rimraf: "npm:^3.0.2" - checksum: 10c0/b76f611bd5f5d68f7ae632e3ae503e678d205cf97a17c6ab5b12f6ca61188b5f1f7464503efae6dc18683ed8f0b41460beb48ac4b9ac63fe6201296a91ba2f75 - languageName: node - linkType: hard - -"flatted@npm:^3.2.9": - version: 3.3.1 - resolution: "flatted@npm:3.3.1" - checksum: 10c0/324166b125ee07d4ca9bcf3a5f98d915d5db4f39d711fba640a3178b959919aae1f7cfd8aabcfef5826ed8aa8a2aa14cc85b2d7d18ff638ddf4ae3df39573eaf - languageName: node - linkType: hard - "follow-redirects@npm:^1.15.6": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" @@ -1033,13 +721,6 @@ __metadata: languageName: node linkType: hard -"get-stream@npm:^6.0.0": - version: 6.0.1 - resolution: "get-stream@npm:6.0.1" - checksum: 10c0/49825d57d3fd6964228e6200a58169464b8e8970489b3acdc24906c782fb7f01f9f56f8e6653c4a50713771d6658f7cfe051e5eb8c12e334138c9c918b296341 - languageName: node - linkType: hard - "git-diff@npm:^2.0.6": version: 2.0.6 resolution: "git-diff@npm:2.0.6" @@ -1053,15 +734,6 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^6.0.2": - version: 6.0.2 - resolution: "glob-parent@npm:6.0.2" - dependencies: - is-glob: "npm:^4.0.3" - checksum: 10c0/317034d88654730230b3f43bb7ad4f7c90257a426e872ea0bf157473ac61c99bf5d205fad8f0185f989be8d2fa6d3c7dce1645d99d545b6ea9089c39f838e7f8 - languageName: node - linkType: hard - "glob@npm:^10.3.7": version: 10.3.12 resolution: "glob@npm:10.3.12" @@ -1077,7 +749,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.0.0, glob@npm:^7.1.3": +"glob@npm:^7.0.0": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -1091,22 +763,6 @@ __metadata: languageName: node linkType: hard -"globals@npm:^13.19.0": - version: 13.24.0 - resolution: "globals@npm:13.24.0" - dependencies: - type-fest: "npm:^0.20.2" - checksum: 10c0/d3c11aeea898eb83d5ec7a99508600fbe8f83d2cf00cbb77f873dbf2bcb39428eff1b538e4915c993d8a3b3473fa71eeebfe22c9bb3a3003d1e26b1f2c8a42cd - languageName: node - linkType: hard - -"graphemer@npm:^1.4.0": - version: 1.4.0 - resolution: "graphemer@npm:1.4.0" - checksum: 10c0/e951259d8cd2e0d196c72ec711add7115d42eb9a8146c8eeda5b8d3ac91e5dd816b9cd68920726d9fd4490368e7ed86e9c423f40db87e2d8dfafa00fa17c3a31 - languageName: node - linkType: hard - "has-flag@npm:^3.0.0": version: 3.0.0 resolution: "has-flag@npm:3.0.0" @@ -1137,22 +793,6 @@ __metadata: languageName: node linkType: hard -"human-signals@npm:^2.1.0": - version: 2.1.0 - resolution: "human-signals@npm:2.1.0" - checksum: 10c0/695edb3edfcfe9c8b52a76926cd31b36978782062c0ed9b1192b36bebc75c4c87c82e178dfcb0ed0fc27ca59d434198aac0bd0be18f5781ded775604db22304a - languageName: node - linkType: hard - -"husky@npm:^9.0.11": - version: 9.0.11 - resolution: "husky@npm:9.0.11" - bin: - husky: bin.mjs - checksum: 10c0/2c787dcf74a837fc9a4fea7da907509d4bd9a289f4ea10ecc9d86279e4d4542b0f5f6443a619bccae19e265f2677172cc2b86aae5c932a35a330cc227d914605 - languageName: node - linkType: hard - "iconv-lite@npm:^0.4.24": version: 0.4.24 resolution: "iconv-lite@npm:0.4.24" @@ -1162,13 +802,6 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.2.0, ignore@npm:^5.3.0": - version: 5.3.1 - resolution: "ignore@npm:5.3.1" - checksum: 10c0/703f7f45ffb2a27fb2c5a8db0c32e7dee66b33a225d28e8db4e1be6474795f606686a6e3bcc50e1aa12f2042db4c9d4a7d60af3250511de74620fbed052ea4cd - languageName: node - linkType: hard - "import-fresh@npm:^3.2.1": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -1179,13 +812,6 @@ __metadata: languageName: node linkType: hard -"imurmurhash@npm:^0.1.4": - version: 0.1.4 - resolution: "imurmurhash@npm:0.1.4" - checksum: 10c0/8b51313850dd33605c6c9d3fd9638b714f4c4c40250cff658209f30d40da60f78992fb2df5dabee4acf589a6a82bbc79ad5486550754bd9ec4e3fc0d4a57d6a6 - languageName: node - linkType: hard - "inflight@npm:^1.0.4": version: 1.0.6 resolution: "inflight@npm:1.0.6" @@ -1247,13 +873,6 @@ __metadata: languageName: node linkType: hard -"is-extglob@npm:^2.1.1": - version: 2.1.1 - resolution: "is-extglob@npm:2.1.1" - checksum: 10c0/5487da35691fbc339700bbb2730430b07777a3c21b9ebaecb3072512dfd7b4ba78ac2381a87e8d78d20ea08affb3f1971b4af629173a6bf435ff8a4c47747912 - languageName: node - linkType: hard - "is-fullwidth-code-point@npm:^3.0.0": version: 3.0.0 resolution: "is-fullwidth-code-point@npm:3.0.0" @@ -1261,29 +880,6 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.0, is-glob@npm:^4.0.3": - version: 4.0.3 - resolution: "is-glob@npm:4.0.3" - dependencies: - is-extglob: "npm:^2.1.1" - checksum: 10c0/17fb4014e22be3bbecea9b2e3a76e9e34ff645466be702f1693e8f1ee1adac84710d0be0bd9f967d6354036fd51ab7c2741d954d6e91dae6bb69714de92c197a - languageName: node - linkType: hard - -"is-path-inside@npm:^3.0.3": - version: 3.0.3 - resolution: "is-path-inside@npm:3.0.3" - checksum: 10c0/cf7d4ac35fb96bab6a1d2c3598fe5ebb29aafb52c0aaa482b5a3ed9d8ba3edc11631e3ec2637660c44b3ce0e61a08d54946e8af30dec0b60a7c27296c68ffd05 - languageName: node - linkType: hard - -"is-stream@npm:^2.0.0": - version: 2.0.1 - resolution: "is-stream@npm:2.0.1" - checksum: 10c0/7c284241313fc6efc329b8d7f08e16c0efeb6baab1b4cd0ba579eb78e5af1aa5da11e68559896a2067cd6c526bd29241dda4eb1225e627d5aa1a89a76d4635a5 - languageName: node - linkType: hard - "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -1322,13 +918,6 @@ __metadata: languageName: node linkType: hard -"json-buffer@npm:3.0.1": - version: 3.0.1 - resolution: "json-buffer@npm:3.0.1" - checksum: 10c0/0d1c91569d9588e7eef2b49b59851f297f3ab93c7b35c7c221e288099322be6b562767d11e4821da500f3219542b9afd2e54c5dc573107c1126ed1080f8e96d7 - languageName: node - linkType: hard - "json-fixer@npm:^1.6.8": version: 1.6.15 resolution: "json-fixer@npm:1.6.15" @@ -1347,39 +936,6 @@ __metadata: languageName: node linkType: hard -"json-schema-traverse@npm:^0.4.1": - version: 0.4.1 - resolution: "json-schema-traverse@npm:0.4.1" - checksum: 10c0/108fa90d4cc6f08243aedc6da16c408daf81793bf903e9fd5ab21983cda433d5d2da49e40711da016289465ec2e62e0324dcdfbc06275a607fe3233fde4942ce - languageName: node - linkType: hard - -"json-stable-stringify-without-jsonify@npm:^1.0.1": - version: 1.0.1 - resolution: "json-stable-stringify-without-jsonify@npm:1.0.1" - checksum: 10c0/cb168b61fd4de83e58d09aaa6425ef71001bae30d260e2c57e7d09a5fd82223e2f22a042dedaab8db23b7d9ae46854b08bb1f91675a8be11c5cffebef5fb66a5 - languageName: node - linkType: hard - -"keyv@npm:^4.5.3": - version: 4.5.4 - resolution: "keyv@npm:4.5.4" - dependencies: - json-buffer: "npm:3.0.1" - checksum: 10c0/aa52f3c5e18e16bb6324876bb8b59dd02acf782a4b789c7b2ae21107fab95fab3890ed448d4f8dba80ce05391eeac4bfabb4f02a20221342982f806fa2cf271e - languageName: node - linkType: hard - -"levn@npm:^0.4.1": - version: 0.4.1 - resolution: "levn@npm:0.4.1" - dependencies: - prelude-ls: "npm:^1.2.1" - type-check: "npm:~0.4.0" - checksum: 10c0/effb03cad7c89dfa5bd4f6989364bfc79994c2042ec5966cb9b95990e2edee5cd8969ddf42616a0373ac49fac1403437deaf6e9050fbbaa3546093a59b9ac94e - languageName: node - linkType: hard - "lines-and-columns@npm:^1.1.6": version: 1.2.4 resolution: "lines-and-columns@npm:1.2.4" @@ -1396,22 +952,6 @@ __metadata: languageName: node linkType: hard -"locate-path@npm:^6.0.0": - version: 6.0.0 - resolution: "locate-path@npm:6.0.0" - dependencies: - p-locate: "npm:^5.0.0" - checksum: 10c0/d3972ab70dfe58ce620e64265f90162d247e87159b6126b01314dd67be43d50e96a50b517bce2d9452a79409c7614054c277b5232377de50416564a77ac7aad3 - languageName: node - linkType: hard - -"lodash.merge@npm:^4.6.2": - version: 4.6.2 - resolution: "lodash.merge@npm:4.6.2" - checksum: 10c0/402fa16a1edd7538de5b5903a90228aa48eb5533986ba7fa26606a49db2572bf414ff73a2c9f5d5fd36b31c46a5d5c7e1527749c07cbcf965ccff5fbdf32c506 - languageName: node - linkType: hard - "lodash@npm:4.17.21, lodash@npm:^4.11.2, lodash@npm:^4.17.19": version: 4.17.21 resolution: "lodash@npm:4.17.21" @@ -1451,13 +991,6 @@ __metadata: languageName: node linkType: hard -"merge-stream@npm:^2.0.0": - version: 2.0.0 - resolution: "merge-stream@npm:2.0.0" - checksum: 10c0/867fdbb30a6d58b011449b8885601ec1690c3e41c759ecd5a9d609094f7aed0096c37823ff4a7190ef0b8f22cc86beb7049196ff68c016e3b3c671d0dac91ce5 - languageName: node - linkType: hard - "mime-db@npm:1.52.0": version: 1.52.0 resolution: "mime-db@npm:1.52.0" @@ -1481,7 +1014,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": +"minimatch@npm:^3.1.1": version: 3.1.2 resolution: "minimatch@npm:3.1.2" dependencies: @@ -1506,20 +1039,6 @@ __metadata: languageName: node linkType: hard -"mri@npm:^1.2.0": - version: 1.2.0 - resolution: "mri@npm:1.2.0" - checksum: 10c0/a3d32379c2554cf7351db6237ddc18dc9e54e4214953f3da105b97dc3babe0deb3ffe99cf409b38ea47cc29f9430561ba6b53b24ab8f9ce97a4b50409e4a50e7 - languageName: node - linkType: hard - -"ms@npm:2.1.2": - version: 2.1.2 - resolution: "ms@npm:2.1.2" - checksum: 10c0/a437714e2f90dbf881b5191d35a6db792efbca5badf112f87b9e1c712aace4b4b9b742dd6537f3edf90fd6f684de897cec230abde57e87883766712ddda297cc - languageName: node - linkType: hard - "mute-stream@npm:0.0.8": version: 0.0.8 resolution: "mute-stream@npm:0.0.8" @@ -1536,13 +1055,6 @@ __metadata: languageName: node linkType: hard -"natural-compare@npm:^1.4.0": - version: 1.4.0 - resolution: "natural-compare@npm:1.4.0" - checksum: 10c0/f5f9a7974bfb28a91afafa254b197f0f22c684d4a1731763dda960d2c8e375b36c7d690e0d9dc8fba774c537af14a7e979129bca23d88d052fbeb9466955e447 - languageName: node - linkType: hard - "node-domexception@npm:^1.0.0": version: 1.0.0 resolution: "node-domexception@npm:1.0.0" @@ -1605,15 +1117,6 @@ __metadata: languageName: node linkType: hard -"npm-run-path@npm:^4.0.1": - version: 4.0.1 - resolution: "npm-run-path@npm:4.0.1" - dependencies: - path-key: "npm:^3.0.0" - checksum: 10c0/6f9353a95288f8455cf64cbeb707b28826a7f29690244c1e4bb61ec573256e021b6ad6651b394eb1ccfd00d6ec50147253aba2c5fe58a57ceb111fad62c519ac - languageName: node - linkType: hard - "oas-kit-common@npm:^1.0.8": version: 1.0.8 resolution: "oas-kit-common@npm:1.0.8" @@ -1681,7 +1184,7 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^5.1.0, onetime@npm:^5.1.2": +"onetime@npm:^5.1.0": version: 5.1.2 resolution: "onetime@npm:5.1.2" dependencies: @@ -1690,20 +1193,6 @@ __metadata: languageName: node linkType: hard -"optionator@npm:^0.9.3": - version: 0.9.4 - resolution: "optionator@npm:0.9.4" - dependencies: - deep-is: "npm:^0.1.3" - fast-levenshtein: "npm:^2.0.6" - levn: "npm:^0.4.1" - prelude-ls: "npm:^1.2.1" - type-check: "npm:^0.4.0" - word-wrap: "npm:^1.2.5" - checksum: 10c0/4afb687a059ee65b61df74dfe87d8d6815cd6883cb8b3d5883a910df72d0f5d029821f37025e4bccf4048873dbdb09acc6d303d27b8f76b1a80dd5a7d5334675 - languageName: node - linkType: hard - "os-tmpdir@npm:~1.0.2": version: 1.0.2 resolution: "os-tmpdir@npm:1.0.2" @@ -1720,15 +1209,6 @@ __metadata: languageName: node linkType: hard -"p-limit@npm:^3.0.2": - version: 3.1.0 - resolution: "p-limit@npm:3.1.0" - dependencies: - yocto-queue: "npm:^0.1.0" - checksum: 10c0/9db675949dbdc9c3763c89e748d0ef8bdad0afbb24d49ceaf4c46c02c77d30db4e0652ed36d0a0a7a95154335fab810d95c86153105bb73b3a90448e2bb14e1a - languageName: node - linkType: hard - "p-locate@npm:^4.1.0": version: 4.1.0 resolution: "p-locate@npm:4.1.0" @@ -1738,15 +1218,6 @@ __metadata: languageName: node linkType: hard -"p-locate@npm:^5.0.0": - version: 5.0.0 - resolution: "p-locate@npm:5.0.0" - dependencies: - p-limit: "npm:^3.0.2" - checksum: 10c0/2290d627ab7903b8b70d11d384fee714b797f6040d9278932754a6860845c4d3190603a0772a663c8cb5a7b21d1b16acb3a6487ebcafa9773094edc3dfe6009a - languageName: node - linkType: hard - "p-try@npm:^2.0.0": version: 2.2.0 resolution: "p-try@npm:2.2.0" @@ -1789,7 +1260,7 @@ __metadata: languageName: node linkType: hard -"path-key@npm:^3.0.0, path-key@npm:^3.1.0": +"path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" checksum: 10c0/748c43efd5a569c039d7a00a03b58eecd1d75f3999f5a28303d75f521288df4823bc057d8784eb72358b2895a05f29a070bc9f1f17d28226cc4e62494cc58c4c @@ -1836,13 +1307,6 @@ __metadata: languageName: node linkType: hard -"picomatch@npm:^3.0.1": - version: 3.0.1 - resolution: "picomatch@npm:3.0.1" - checksum: 10c0/70ec738569f1864658378b7abdab8939d15dae0718c1df994eae3346fd33daf6a3c1ff4e0c1a0cd1e2c0319130985b63a2cff34d192f2f2acbb78aca76111736 - languageName: node - linkType: hard - "pify@npm:^5.0.0": version: 5.0.0 resolution: "pify@npm:5.0.0" @@ -1850,22 +1314,6 @@ __metadata: languageName: node linkType: hard -"prelude-ls@npm:^1.2.1": - version: 1.2.1 - resolution: "prelude-ls@npm:1.2.1" - checksum: 10c0/b00d617431e7886c520a6f498a2e14c75ec58f6d93ba48c3b639cf241b54232d90daa05d83a9e9b9fef6baa63cb7e1e4602c2372fea5bc169668401eb127d0cd - languageName: node - linkType: hard - -"prettier-linter-helpers@npm:^1.0.0": - version: 1.0.0 - resolution: "prettier-linter-helpers@npm:1.0.0" - dependencies: - fast-diff: "npm:^1.1.2" - checksum: 10c0/81e0027d731b7b3697ccd2129470ed9913ecb111e4ec175a12f0fcfab0096516373bf0af2fef132af50cafb0a905b74ff57996d615f59512bb9ac7378fcc64ab - languageName: node - linkType: hard - "prettier@npm:3.0.0": version: 3.0.0 resolution: "prettier@npm:3.0.0" @@ -1884,25 +1332,6 @@ __metadata: languageName: node linkType: hard -"pretty-quick@npm:^4.0.0": - version: 4.0.0 - resolution: "pretty-quick@npm:4.0.0" - dependencies: - execa: "npm:^5.1.1" - find-up: "npm:^5.0.0" - ignore: "npm:^5.3.0" - mri: "npm:^1.2.0" - picocolors: "npm:^1.0.0" - picomatch: "npm:^3.0.1" - tslib: "npm:^2.6.2" - peerDependencies: - prettier: ^3.0.0 - bin: - pretty-quick: lib/cli.mjs - checksum: 10c0/f92f5f6a4c7b8e5c87c405d09f883e49d538bbb117a8d8623102f25900fc2d4617314d30c5320c6278fa9ac2da15e74076e08319a797a5d0028b43d6c5da591b - languageName: node - linkType: hard - "proxy-from-env@npm:^1.1.0": version: 1.1.0 resolution: "proxy-from-env@npm:1.1.0" @@ -1910,20 +1339,6 @@ __metadata: languageName: node linkType: hard -"punycode@npm:^2.1.0": - version: 2.3.1 - resolution: "punycode@npm:2.3.1" - checksum: 10c0/14f76a8206bc3464f794fb2e3d3cc665ae416c01893ad7a02b23766eb07159144ee612ad67af5e84fa4479ccfe67678c4feb126b0485651b302babf66f04f9e9 - languageName: node - linkType: hard - -"queue-microtask@npm:^1.2.2": - version: 1.2.3 - resolution: "queue-microtask@npm:1.2.3" - checksum: 10c0/900a93d3cdae3acd7d16f642c29a642aea32c2026446151f0778c62ac089d4b8e6c986811076e1ae180a694cedf077d453a11b58ff0a865629a4f82ab558e102 - languageName: node - linkType: hard - "rechoir@npm:^0.6.2": version: 0.6.2 resolution: "rechoir@npm:0.6.2" @@ -2004,24 +1419,6 @@ __metadata: languageName: node linkType: hard -"reusify@npm:^1.0.4": - version: 1.0.4 - resolution: "reusify@npm:1.0.4" - checksum: 10c0/c19ef26e4e188f408922c46f7ff480d38e8dfc55d448310dfb518736b23ed2c4f547fb64a6ed5bdba92cd7e7ddc889d36ff78f794816d5e71498d645ef476107 - languageName: node - linkType: hard - -"rimraf@npm:^3.0.2": - version: 3.0.2 - resolution: "rimraf@npm:3.0.2" - dependencies: - glob: "npm:^7.1.3" - bin: - rimraf: bin.js - checksum: 10c0/9cb7757acb489bd83757ba1a274ab545eafd75598a9d817e0c3f8b164238dd90eba50d6b848bd4dcc5f3040912e882dc7ba71653e35af660d77b25c381d402e8 - languageName: node - linkType: hard - "rimraf@npm:^5.0.1": version: 5.0.5 resolution: "rimraf@npm:5.0.5" @@ -2040,15 +1437,6 @@ __metadata: languageName: node linkType: hard -"run-parallel@npm:^1.1.9": - version: 1.2.0 - resolution: "run-parallel@npm:1.2.0" - dependencies: - queue-microtask: "npm:^1.2.2" - checksum: 10c0/200b5ab25b5b8b7113f9901bfe3afc347e19bb7475b267d55ad0eb86a62a46d77510cb0f232507c9e5d497ebda569a08a9867d0d14f57a82ad5564d991588b39 - languageName: node - linkType: hard - "rxjs@npm:^6.6.0": version: 6.6.7 resolution: "rxjs@npm:6.6.7" @@ -2175,7 +1563,7 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3": +"signal-exit@npm:^3.0.2": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" checksum: 10c0/25d272fa73e146048565e08f3309d5b942c1979a6f4a58a8c59d5fa299728e9c2fcd1a759ec870863b1fd38653670240cd420dad2ad9330c71f36608a6a1c912 @@ -2238,20 +1626,6 @@ __metadata: languageName: node linkType: hard -"strip-final-newline@npm:^2.0.0": - version: 2.0.0 - resolution: "strip-final-newline@npm:2.0.0" - checksum: 10c0/bddf8ccd47acd85c0e09ad7375409d81653f645fda13227a9d459642277c253d877b68f2e5e4d819fe75733b0e626bac7e954c04f3236f6d196f79c94fa4a96f - languageName: node - linkType: hard - -"strip-json-comments@npm:^3.1.1": - version: 3.1.1 - resolution: "strip-json-comments@npm:3.1.1" - checksum: 10c0/9681a6257b925a7fa0f285851c0e613cc934a50661fa7bb41ca9cbbff89686bb4a0ee366e6ecedc4daafd01e83eee0720111ab294366fe7c185e935475ebcecd - languageName: node - linkType: hard - "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" @@ -2288,6 +1662,7 @@ __metadata: version: 0.0.0-use.local resolution: "swagger-typescript-api@workspace:." dependencies: + "@biomejs/biome": "npm:1.7.2" "@types/lodash": "npm:^4.14.195" "@types/node": "npm:^20.4.1" "@types/prettier": "npm:^2.7.3" @@ -2298,12 +1673,8 @@ __metadata: cross-env: "npm:^7.0.3" didyoumean: "npm:^1.2.2" dotenv: "npm:^16.3.1" - eslint: "npm:^8.44.0" - eslint-config-prettier: "npm:^9.1.0" - eslint-plugin-prettier: "npm:^5.0.0" eta: "npm:^2.2.0" git-diff: "npm:^2.0.6" - husky: "npm:^9.0.11" js-yaml: "npm:4.1.0" lodash: "npm:4.17.21" make-dir: "npm:4.0.0" @@ -2311,7 +1682,6 @@ __metadata: node-emoji: "npm:2.1.3" node-fetch: "npm:^3.3.1" prettier: "npm:3.0.0" - pretty-quick: "npm:^4.0.0" rimraf: "npm:^5.0.1" swagger-schema-official: "npm:2.0.0-bab6bed" swagger2openapi: "npm:7.0.8" @@ -2345,23 +1715,6 @@ __metadata: languageName: node linkType: hard -"synckit@npm:^0.8.6": - version: 0.8.8 - resolution: "synckit@npm:0.8.8" - dependencies: - "@pkgr/core": "npm:^0.1.0" - tslib: "npm:^2.6.2" - checksum: 10c0/c3d3aa8e284f3f84f2f868b960c9f49239b364e35f6d20825a448449a3e9c8f49fe36cdd5196b30615682f007830d46f2ea354003954c7336723cb821e4b6519 - languageName: node - linkType: hard - -"text-table@npm:^0.2.0": - version: 0.2.0 - resolution: "text-table@npm:0.2.0" - checksum: 10c0/02805740c12851ea5982686810702e2f14369a5f4c5c40a836821e3eefc65ffeec3131ba324692a37608294b0fd8c1e55a2dd571ffed4909822787668ddbee5c - languageName: node - linkType: hard - "through@npm:^2.3.6": version: 2.3.8 resolution: "through@npm:2.3.8" @@ -2392,29 +1745,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.6.2": - version: 2.6.2 - resolution: "tslib@npm:2.6.2" - checksum: 10c0/e03a8a4271152c8b26604ed45535954c0a45296e32445b4b87f8a5abdb2421f40b59b4ca437c4346af0f28179780d604094eb64546bee2019d903d01c6c19bdb - languageName: node - linkType: hard - -"type-check@npm:^0.4.0, type-check@npm:~0.4.0": - version: 0.4.0 - resolution: "type-check@npm:0.4.0" - dependencies: - prelude-ls: "npm:^1.2.1" - checksum: 10c0/7b3fd0ed43891e2080bf0c5c504b418fbb3e5c7b9708d3d015037ba2e6323a28152ec163bcb65212741fa5d2022e3075ac3c76440dbd344c9035f818e8ecee58 - languageName: node - linkType: hard - -"type-fest@npm:^0.20.2": - version: 0.20.2 - resolution: "type-fest@npm:0.20.2" - checksum: 10c0/dea9df45ea1f0aaa4e2d3bed3f9a0bfe9e5b2592bddb92eb1bf06e50bcf98dbb78189668cd8bc31a0511d3fc25539b4cd5c704497e53e93e2d40ca764b10bfc3 - languageName: node - linkType: hard - "type-fest@npm:^0.21.3": version: 0.21.3 resolution: "type-fest@npm:0.21.3" @@ -2456,15 +1786,6 @@ __metadata: languageName: node linkType: hard -"uri-js@npm:^4.2.2": - version: 4.4.1 - resolution: "uri-js@npm:4.4.1" - dependencies: - punycode: "npm:^2.1.0" - checksum: 10c0/4ef57b45aa820d7ac6496e9208559986c665e49447cb072744c13b66925a362d96dd5a46c4530a6b8e203e5db5fe849369444440cb22ecfc26c679359e5dfa3c - languageName: node - linkType: hard - "web-streams-polyfill@npm:^3.0.3": version: 3.3.3 resolution: "web-streams-polyfill@npm:3.3.3" @@ -2507,13 +1828,6 @@ __metadata: languageName: node linkType: hard -"word-wrap@npm:^1.2.5": - version: 1.2.5 - resolution: "word-wrap@npm:1.2.5" - checksum: 10c0/e0e4a1ca27599c92a6ca4c32260e8a92e8a44f4ef6ef93f803f8ed823f486e0889fc0b93be4db59c8d51b3064951d25e43d434e95dc8c960cc3a63d65d00ba20 - languageName: node - linkType: hard - "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": version: 7.0.0 resolution: "wrap-ansi@npm:7.0.0" @@ -2632,10 +1946,3 @@ __metadata: checksum: 10c0/ccd7e723e61ad5965fffbb791366db689572b80cca80e0f96aad968dfff4156cd7cd1ad18607afe1046d8241e6fb2d6c08bf7fa7bfb5eaec818735d8feac8f05 languageName: node linkType: hard - -"yocto-queue@npm:^0.1.0": - version: 0.1.0 - resolution: "yocto-queue@npm:0.1.0" - checksum: 10c0/dceb44c28578b31641e13695d200d34ec4ab3966a5729814d5445b194933c096b7ced71494ce53a0e8820685d1d010df8b2422e5bf2cdea7e469d97ffbea306f - languageName: node - linkType: hard From 35cc0c06a6e9e8892e3caf11fb042c0a24042bcf Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sun, 5 May 2024 07:18:42 +0900 Subject: [PATCH 2/2] Fix biome errors (round 1) Signed-off-by: Sora Morimoto --- .all-contributorsrc | 345 --------- .ncurc.json | 7 +- CHANGELOG.md | 643 +++++++++------- README.md | 685 ++++++++---------- biome.json | 12 + cli/constants.js | 6 +- cli/execute.js | 24 +- cli/index.js | 32 +- cli/operations/display-help.js | 50 +- cli/parse-args.js | 6 +- cli/process-option.js | 22 +- index.d.ts | 174 +++-- index.js | 219 +++--- package.json | 2 - scripts_runner.js | 20 +- src/code-formatter.js | 12 +- src/code-gen-process.js | 90 +-- .../generate-templates/configuration.js | 4 +- src/commands/generate-templates/index.js | 2 +- .../templates-gen-process.js | 42 +- src/component-type-name-resolver.js | 8 +- src/configuration.js | 212 +++--- src/constants.js | 52 +- src/index.js | 6 +- src/schema-components-map.js | 6 +- .../base-schema-parsers/array.js | 6 +- .../base-schema-parsers/complex.js | 10 +- .../base-schema-parsers/discriminator.js | 24 +- src/schema-parser/base-schema-parsers/enum.js | 24 +- .../base-schema-parsers/object.js | 16 +- .../base-schema-parsers/primitive.js | 6 +- .../complex-schema-parsers/all-of.js | 4 +- .../complex-schema-parsers/any-of.js | 4 +- .../complex-schema-parsers/not.js | 2 +- .../complex-schema-parsers/one-of.js | 4 +- src/schema-parser/mono-schema-parser.js | 2 +- src/schema-parser/schema-formatters.js | 28 +- src/schema-parser/schema-parser-fabric.js | 10 +- src/schema-parser/schema-parser.js | 48 +- src/schema-parser/schema-utils.js | 42 +- src/schema-parser/util/enum-key-resolver.js | 4 +- src/schema-routes/schema-routes.js | 136 ++-- .../util/specific-arg-name-resolver.js | 4 +- src/schema-walker.js | 14 +- src/swagger-schema-resolver.js | 32 +- src/templates-worker.js | 39 +- src/translators/javascript.js | 14 +- src/translators/translator.js | 2 +- src/type-name-formatter.js | 32 +- src/util/file-system.js | 26 +- src/util/id.js | 4 +- src/util/internal-case.js | 2 +- src/util/logger.js | 54 +- src/util/name-resolver.js | 10 +- src/util/object-assign.js | 4 +- src/util/pascal-case.js | 2 +- src/util/request.js | 10 +- tests/allSchemas.js | 26 +- tests/generate-extended.js | 39 +- tests/helpers/assertGeneratedModule.js | 12 +- tests/helpers/createGeneratedApiInfos.js | 9 +- tests/helpers/createSchemaInfos.js | 80 +- tests/helpers/specGenerateOptions.js | 4 +- tests/helpers/validateGeneratedModule.js | 24 +- tests/spec/additional-properties-2.0/test.js | 11 +- tests/spec/another-array-type/test.js | 11 +- tests/spec/another-query-params/test.js | 11 +- tests/spec/axios/test.js | 11 +- tests/spec/axiosSingleHttpClient/test.js | 11 +- tests/spec/cli/test.js | 9 +- tests/spec/const-keyword/test.js | 11 +- tests/spec/custom-extensions/test.js | 11 +- tests/spec/defaultAsSuccess/test.js | 11 +- tests/spec/defaultResponse/test.js | 11 +- tests/spec/deprecated/test.js | 11 +- tests/spec/discriminator/test.js | 11 +- tests/spec/dot-path-params/test.js | 7 +- tests/spec/enumNamesAsValues/test.js | 11 +- tests/spec/enums-2.0/test.js | 11 +- tests/spec/extra-templates/test.js | 13 +- tests/spec/extract-enums/test.js | 100 +-- tests/spec/extractRequestBody/test.js | 11 +- tests/spec/extractRequestParams/test.js | 11 +- tests/spec/extractResponseBody/test.js | 11 +- tests/spec/extractResponseError/test.js | 11 +- tests/spec/js/test.js | 6 +- tests/spec/jsAxios/test.js | 6 +- tests/spec/jsSingleHttpClientModular/test.js | 6 +- tests/spec/modular/test.js | 6 +- tests/spec/moduleNameFirstTag/test.js | 11 +- tests/spec/moduleNameIndex/test.js | 11 +- tests/spec/noClient/test.js | 11 +- tests/spec/nullable-2.0/test.js | 11 +- tests/spec/nullable-3.0/test.js | 11 +- tests/spec/object-types/test.js | 11 +- tests/spec/on-insert-path-param/test.js | 11 +- tests/spec/partialBaseTemplate/test.js | 18 +- tests/spec/partialDefaultTemplate/test.js | 18 +- tests/spec/patch/test.js | 11 +- tests/spec/primitive-type-constructs/test.js | 17 +- tests/spec/readonly/test.js | 11 +- tests/spec/responses/test.js | 11 +- tests/spec/routeTypes/test.js | 11 +- tests/spec/singleHttpClient/test.js | 11 +- tests/spec/sortTypes-false/test.js | 11 +- tests/spec/sortTypes/test.js | 11 +- tests/spec/specProperty/test.js | 11 +- tests/spec/templates/test.js | 18 +- tests/spec/typeSuffixPrefix/test.js | 7 +- tests/spec/unionEnums/test.js | 11 +- tests/validate.js | 2 +- yarn.lock | 446 +----------- 112 files changed, 2100 insertions(+), 2436 deletions(-) delete mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc deleted file mode 100644 index f6dfee53..00000000 --- a/.all-contributorsrc +++ /dev/null @@ -1,345 +0,0 @@ -{ - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": false, - "badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg)](#contributors)", - "contributors": [ - { - "login": "js2me", - "name": "Sergey S. Volkov", - "avatar_url": "https://avatars1.githubusercontent.com/u/16340911?v=4", - "profile": "https://github.com/js2me", - "contributions": [ - "code", - "doc", - "design", - "example", - "maintenance", - "ideas", - "bug" - ] - }, - { - "login": "andrefilimono", - "name": "Filimonov Andrey", - "avatar_url": "https://avatars0.githubusercontent.com/u/7794526?v=4", - "profile": "https://github.com/andrefilimono", - "contributions": [ - "code", - "ideas", - "design" - ] - }, - { - "login": "Fl0pZz", - "name": "Rafael Fakhreev", - "avatar_url": "https://avatars2.githubusercontent.com/u/9510124?v=4", - "profile": "https://github.com/Fl0pZz", - "contributions": [ - "code", - "ideas" - ] - }, - { - "login": "azz", - "name": "Lucas Azzola", - "avatar_url": "https://avatars3.githubusercontent.com/u/1297597?v=4", - "profile": "https://azzola.dev", - "contributions": [ - "code", - "ideas", - "design" - ] - }, - { - "login": "JennieJi", - "name": "Jennie", - "avatar_url": "https://avatars3.githubusercontent.com/u/1913045?v=4", - "profile": "https://github.com/JennieJi", - "contributions": [ - "code", - "ideas" - ] - }, - { - "login": "jomarquez21", - "name": "Jose Enrique Marquez", - "avatar_url": "https://avatars1.githubusercontent.com/u/16705169?v=4", - "profile": "https://github.com/jomarquez21", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "Benjamin-Dobell", - "name": "Benjamin Dobell", - "avatar_url": "https://avatars1.githubusercontent.com/u/482276?v=4", - "profile": "https://glassechidna.com.au", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "larrybotha", - "name": "Larry Botha", - "avatar_url": "https://avatars0.githubusercontent.com/u/1510520?v=4", - "profile": "http://fixate.it", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "nikalun", - "name": "Nikolay Lukinykh", - "avatar_url": "https://avatars3.githubusercontent.com/u/13102962?v=4", - "profile": "https://github.com/nikalun", - "contributions": [ - "code", - "ideas", - "bug" - ] - }, - { - "login": "Mvbraathen", - "name": "Marius Bråthen", - "avatar_url": "https://avatars0.githubusercontent.com/u/16756739?v=4", - "profile": "https://github.com/Mvbraathen", - "contributions": [ - "security" - ] - }, - { - "login": "xesjkeee", - "name": "Evgeny Vlasov", - "avatar_url": "https://avatars2.githubusercontent.com/u/17751886?v=4", - "profile": "https://github.com/xesjkeee", - "contributions": [ - "ideas" - ] - }, - { - "login": "kel666", - "name": "Fabio", - "avatar_url": "https://avatars1.githubusercontent.com/u/2040661?v=4", - "profile": "https://github.com/kel666", - "contributions": [ - "bug", - "code" - ] - }, - { - "login": "Fabiencdp", - "name": "Fabien", - "avatar_url": "https://avatars.githubusercontent.com/u/6182473?v=4", - "profile": "https://github.com/Fabiencdp", - "contributions": [ - "bug" - ] - }, - { - "login": "RoXuS", - "name": "Rousseau Julien", - "avatar_url": "https://avatars.githubusercontent.com/u/3296671?v=4", - "profile": "https://about.me/julienrousseau", - "contributions": [ - "bug" - ] - }, - { - "login": "Larox", - "name": "Sebastián Arias", - "avatar_url": "https://avatars.githubusercontent.com/u/9751266?v=4", - "profile": "http://sebastianarias.dev", - "contributions": [ - "bug" - ] - }, - { - "login": "Styn", - "name": "Stijn Lammens", - "avatar_url": "https://avatars.githubusercontent.com/u/6705137?v=4", - "profile": "https://github.com/Styn", - "contributions": [ - "bug", - "code" - ] - }, - { - "login": "emilecantin", - "name": "Emile Cantin", - "avatar_url": "https://avatars.githubusercontent.com/u/885486?v=4", - "profile": "http://emilecantin.com", - "contributions": [ - "bug", - "code" - ] - }, - { - "login": "armsnyder", - "name": "Adam Snyder", - "avatar_url": "https://avatars.githubusercontent.com/u/9969202?v=4", - "profile": "https://github.com/armsnyder", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "jnpoyser", - "name": "James Poyser", - "avatar_url": "https://avatars.githubusercontent.com/u/7920428?v=4", - "profile": "https://github.com/jnpoyser", - "contributions": [ - "code", - "ideas" - ] - }, - { - "login": "Nihisil", - "name": "Alexey", - "avatar_url": "https://avatars.githubusercontent.com/u/475367?v=4", - "profile": "http://ru.linkedin.com/in/lisikhin", - "contributions": [ - "bug" - ] - }, - { - "login": "jiangmaniu", - "name": "江麻妞", - "avatar_url": "https://avatars.githubusercontent.com/u/50100681?v=4", - "profile": "http://imaniu.com", - "contributions": [ - "code" - ] - }, - { - "login": "kmoskwiak", - "name": "Kasper Moskwiak", - "avatar_url": "https://avatars.githubusercontent.com/u/5294519?v=4", - "profile": "https://kspr.dev", - "contributions": [ - "code", - "ideas" - ] - }, - { - "login": "baggoedw", - "name": "baggoedw", - "avatar_url": "https://avatars.githubusercontent.com/u/92381702?v=4", - "profile": "https://github.com/baggoedw", - "contributions": [ - "code" - ] - }, - { - "login": "MarcusDunn", - "name": "Marcus Dunn", - "avatar_url": "https://avatars.githubusercontent.com/u/51931484?v=4", - "profile": "https://marcusdunn.github.io", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "hedgepigdaniel", - "name": "Daniel Playfair Cal", - "avatar_url": "https://avatars.githubusercontent.com/u/1217649?v=4", - "profile": "https://www.danielplayfaircal.com/", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "PatrickShaw", - "name": "Patrick Shaw", - "avatar_url": "https://avatars.githubusercontent.com/u/5153619?v=4", - "profile": "https://www.linkedin.com/in/patrick-shaw/", - "contributions": [ - "review" - ] - }, - { - "login": "brookjordan", - "name": "Brook Jordan", - "avatar_url": "https://avatars.githubusercontent.com/u/9323190?v=4", - "profile": "http://brook.dev", - "contributions": [ - "code" - ] - }, - { - "login": "RoCat", - "name": "RoCat", - "avatar_url": "https://avatars.githubusercontent.com/u/3562317?v=4", - "profile": "https://github.com/RoCat", - "contributions": [ - "code", - "ideas", - "design" - ] - }, - { - "login": "ApacheEx", - "name": "Oleg Kuzava", - "avatar_url": "https://avatars.githubusercontent.com/u/1918108?v=4", - "profile": "https://github.com/ApacheEx", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "nksfrank", - "name": "Niklas Frank", - "avatar_url": "https://avatars.githubusercontent.com/u/7352072?v=4", - "profile": "http://nikz.se", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "qboot", - "name": "Quentin Brunet", - "avatar_url": "https://avatars.githubusercontent.com/u/20137632?v=4", - "profile": "https://quentinbrunet.com", - "contributions": [ - "code" - ] - }, - { - "login": "Soarc", - "name": "Gor Rustamyan", - "avatar_url": "https://avatars.githubusercontent.com/u/3385495?v=4", - "profile": "https://github.com/Soarc", - "contributions": [ - "code", - "bug" - ] - }, - { - "login": "JochenDiekenbrock", - "name": "Jochen Diekenbrock", - "avatar_url": "https://avatars.githubusercontent.com/u/1625222?v=4", - "profile": "https://github.com/JochenDiekenbrock", - "contributions": [ - "code", - "bug" - ] - } - ], - "contributorsPerLine": 7, - "projectName": "swagger-typescript-api", - "projectOwner": "acacode", - "repoType": "github", - "repoHost": "https://github.com", - "skipCi": true, - "commitConvention": "angular" -} diff --git a/.ncurc.json b/.ncurc.json index da7ff7a5..868ca9ec 100644 --- a/.ncurc.json +++ b/.ncurc.json @@ -1,7 +1,4 @@ { "upgrade": true, - "reject": [ - "nanoid", - "eta" - ] -} \ No newline at end of file + "reject": ["nanoid", "eta"] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b2820ee4..3815e76f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,38 +1,38 @@ -# next release +# next release -## 13.0.3 +## 13.0.3 -fix: problem with type `any` as base type of discriminator schema (cases when schema without discriminator is empty) +fix: problem with type `any` as base type of discriminator schema (cases when schema without discriminator is empty) -## 13.0.2 +## 13.0.2 fix: problem with incorrect settings type suffix for internal discriminator mappings -## 13.0.1 +## 13.0.1 -feat: `const` keyword OpenAPI 3.0 draft -fix: problem with using `anyOf` +feat: `const` keyword OpenAPI 3.0 draft +fix: problem with using `anyOf` feat: `--extract-responses` (nodejs: `extractResponses`) option to extract all schemas from `/components/responses` -fix: discriminator and mapping with invalid discriminator property name (#551) +fix: discriminator and mapping with invalid discriminator property name (#551) fix: problem with incorrect resolving type name of discriminator mapping types data contracts -## 13.0.0 - -BREAKING_CHANGE: disable support NodeJS 14.x -BREAKING_CHANGE: change swagger-typescript-api NodeJS "generateApi" function return type -BREAKING_CHANGE: remove `rawModelTypes` from output api configuration -feat: `--custom-config ` option (#503) -feat: `--sort-routes` option, ability to sort routes; -fix: critical bugs based with extract types and enums -fix: sort types option (sort was not correctly work with nested or extracted types) -fix: problems based with extracting enums; -fix: nullable enum with integer values (#543) -fix: generation enum numbers as strings one (#534) -chore: refactoring the axios imports -fix: non-object custom spec extensions (#500) -fix(docs): input instead of output in readme -internal: remove redundant internal scripts -internal: change process with using custom templates +## 13.0.0 + +BREAKING_CHANGE: disable support NodeJS 14.x +BREAKING_CHANGE: change swagger-typescript-api NodeJS "generateApi" function return type +BREAKING_CHANGE: remove `rawModelTypes` from output api configuration +feat: `--custom-config ` option (#503) +feat: `--sort-routes` option, ability to sort routes; +fix: critical bugs based with extract types and enums +fix: sort types option (sort was not correctly work with nested or extracted types) +fix: problems based with extracting enums; +fix: nullable enum with integer values (#543) +fix: generation enum numbers as strings one (#534) +chore: refactoring the axios imports +fix: non-object custom spec extensions (#500) +fix(docs): input instead of output in readme +internal: remove redundant internal scripts +internal: change process with using custom templates ```diff interface GenerateApiOutput { @@ -43,42 +43,45 @@ interface GenerateApiOutput { } ``` -internal: refactor schema parser code (preparing it for async code execution) -fix: problem with filtering primitive in complex types (#459) -feat: add discriminator property support (#456) -internal: prepare code + templates for async code execution (next plans) -fix: problems with dot in query params (hard fix) (#460) -feature: ability to send custom Ts output code translator to js. Example: +internal: refactor schema parser code (preparing it for async code execution) +fix: problem with filtering primitive in complex types (#459) +feat: add discriminator property support (#456) +internal: prepare code + templates for async code execution (next plans) +fix: problems with dot in query params (hard fix) (#460) +feature: ability to send custom Ts output code translator to js. Example: + ```ts - const { Translator } = require("swagger-typescript-api/src/translators/translator"); - const { JavascriptTranslator } = require("swagger-typescript-api/src/translators/javascript"); - - class MyTranslator extends Translator { // or use extends JavascriptTranslator - translate({ fileName, fileExtension, fileContent }) { - // format ts\js code with using this codeFormatter (prettier + ts import fixer) - this.codeFormatter.format(fileContent) - // config of the code gen process - this.config. - // logger - this.logger. - - return [ - { - fileName, - fileExtension, - fileContent, - } - ] - } - } +const { + Translator, +} = require("swagger-typescript-api/src/translators/translator"); +const { + JavascriptTranslator, +} = require("swagger-typescript-api/src/translators/javascript"); + +class MyTranslator extends Translator { + // or use extends JavascriptTranslator + translate({ fileName, fileExtension, fileContent }) { + // format ts\js code with using this codeFormatter (prettier + ts import fixer) + this.codeFormatter.format(fileContent); + // config of the code gen process + // logger + this.config.this.logger.return[ + { + fileName, + fileExtension, + fileContent, + } + ]; + } +} ``` -## 12.0.4 +## 12.0.4 -fix: onCreateRoute skip behaviour +fix: onCreateRoute skip behaviour fix: problems with prefixes\suffixes for extracted requests params, enums -**Full Changelog**: https://github.com/acacode/swagger-typescript-api/compare/12.0.3...12.0.4 +**Full Changelog**: https://github.com/acacode/swagger-typescript-api/compare/12.0.3...12.0.4 ## 12.0.3 @@ -96,6 +99,7 @@ docs: update docs for `requestOptions` nodejs option ## 12.0.0 new hooks: + ```ts /** calls before parse\process route path */ onPreBuildRoutePath: (routePath: string) => string | void; @@ -106,50 +110,50 @@ onInsertPathParam: (paramName: string, index: number, arr: BuildRouteParam[], re /** calls before parse any kind of schema */ onPreParseSchema: (originalSchema: any, typeName: string, schemaType: string) => any; ``` + BREAKING_CHANGE: add ability to custom prefix for autofix invalid enum keys, invalid type names with nodejs options (`fixInvalidTypeNamePrefix: string`, `fixInvalidEnumKeyPrefix: string`) BREAKING_CHANGE: by default all component enum schemas (even numeric) extracting as `enum` TS constructions (#344) feature: ability to extract all enums from nested types\interfaces to `enum` TS construction using `--extract-enums` option (#344) feature: ability to modify route path params before insert them into string (request url, #446, with using hook `onInsertPathParam`) feature: (nodejs) ability to add prefix\suffix for type names and enum keys + ```ts typePrefix?: string; typeSuffix?: string; enumKeyPrefix?: string; enumKeySuffix?: string; ``` + feature: ability to customize resolving process of the extracting type names (`extractingOptions` nodejs option) + ```ts extractingOptions = { // requestBodySuffix: ["Payload", "Body", "Input"], // or // requestBodyNameResolver: (typeName, reservedNames) => string; - // requestParamsSuffix: ["Params"], // or // requestParamsNameResolver: (typeName, reservedNames) => string; - // responseBodySuffix: ["Data", "Result", "Output"], // or // responseBodyNameResolver: (typeName, reservedNames) => string; - // responseErrorSuffix: ["Error", "Fail", "Fails", "ErrorData", "HttpError", "BadResponse"], // or // responseErrorNameResolver: (typeName, reservedNames) => string; -} +}; ``` + docs: update docs for `extraTemplates` option fix: problem with default name of single api file (Api.ts) fix: problem based with tuple types (#445) fix: problem with `defaultResponseType` declaration type - # 11.1.3 fix: problems with `text/*` content types (axios, fetch http clients) (thanks @JochenDiekenbrock, #312, #443) fix: problem with `application/json*` content type (thanks @JochenDiekenbrock, #440, #441) fix: different query type parameters declarations (in route name `{?accountStatus,createdT`, #439) - # 11.1.2 fix: problems with missing type imports in `.d.ts` files with using option `--js` @@ -158,9 +162,11 @@ fix: additionalProperties management problem in Swagger 2 (#343) fix: hanging cli after execution finished (#436, thanks @Soarc) # 11.1.1 + fix: `--api-class-name` option has no default value (#433) # 11.1.0 + BREAKING_CHANGE: replace `axios` to `node-fetch` feat: ability to send request options for getting swagger schema by url (`requestOptions` property) @@ -173,202 +179,220 @@ feat: ability to send request options for getting swagger schema by url (`reques ## Breaking changes - - `data-contract-jsdoc.ejs` file uses new input structure. Please update your local copy. - - new codebase (class way) - - ability to change everything in codegen process configuration with using NodeJS Api - - ability to call `generateApi` function 2 and more times per 1 NodeJS process. - - new command `generate-templates` to create source templates +- `data-contract-jsdoc.ejs` file uses new input structure. Please update your local copy. +- new codebase (class way) +- ability to change everything in codegen process configuration with using NodeJS Api +- ability to call `generateApi` function 2 and more times per 1 NodeJS process. +- new command `generate-templates` to create source templates ## [feature] Ability to generate source templates + New command `generate-templates` which allow you to generate source templates which using with option `--templates` ## [feature] Ability to modify internal codegen typescript structs + Everything which creates codegen about output typescript code now contains in `Ts` field in [`src/configuration`](src/configuration.js). And this thing is available for end user modifications with using NodeJS Cli option `codeGenConstructs`. It contains almost all which is not contains in `.eta`\ `.ejs` templates. For example: `Record`, `readonly typeField?: value`, etc Structure of `Ts` property + ```ts - const Ts = { - Keyword: { - Number: "number", - String: "string", - Boolean: "boolean", - Any: "any", - Void: "void", - Unknown: "unknown", - Null: "null", - Undefined: "undefined", - Object: "object", - File: "File", - Date: "Date", - Type: "type", - Enum: "enum", - Interface: "interface", - Array: "Array", - Record: "Record", - Intersection: "&", - Union: "|", - }, - CodeGenKeyword: { - UtilRequiredKeys: "UtilRequiredKeys", - }, - /** - * $A[] or Array<$A> - */ - ArrayType: (content) => { - if (this.anotherArrayType) { - return Ts.TypeWithGeneric(Ts.Keyword.Array, [content]); - } +const Ts = { + Keyword: { + Number: "number", + String: "string", + Boolean: "boolean", + Any: "any", + Void: "void", + Unknown: "unknown", + Null: "null", + Undefined: "undefined", + Object: "object", + File: "File", + Date: "Date", + Type: "type", + Enum: "enum", + Interface: "interface", + Array: "Array", + Record: "Record", + Intersection: "&", + Union: "|", + }, + CodeGenKeyword: { + UtilRequiredKeys: "UtilRequiredKeys", + }, + /** + * $A[] or Array<$A> + */ + ArrayType: (content) => { + if (this.anotherArrayType) { + return Ts.TypeWithGeneric(Ts.Keyword.Array, [content]); + } - return `${Ts.ExpressionGroup(content)}[]`; - }, - /** - * "$A" - */ - StringValue: (content) => `"${content}"`, - /** - * $A - */ - BooleanValue: (content) => `${content}`, - /** - * $A - */ - NumberValue: (content) => `${content}`, - /** - * $A - */ - NullValue: (content) => content, - /** - * $A1 | $A2 - */ - UnionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Union} `), - /** - * ($A1) - */ - ExpressionGroup: (content) => (content ? `(${content})` : ""), - /** - * $A1 & $A2 - */ - IntersectionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Intersection} `), - /** - * Record<$A1, $A2> - */ - RecordType: (key, value) => Ts.TypeWithGeneric(Ts.Keyword.Record, [key, value]), - /** - * readonly $key?:$value - */ - TypeField: ({ readonly, key, optional, value }) => - _.compact([readonly && "readonly ", key, optional && "?", ": ", value]).join(""), - /** - * [key: $A1]: $A2 - */ - InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`, - /** - * $A1 = $A2 - */ - EnumField: (key, value) => `${key} = ${value}`, - /** - * $A0.key = $A0.value, - * $A1.key = $A1.value, - * $AN.key = $AN.value, - */ - EnumFieldsWrapper: (contents) => - _.map(contents, ({ key, value }) => ` ${Ts.EnumField(key, value)}`).join(",\n"), - /** - * {\n $A \n} - */ - ObjectWrapper: (content) => `{\n${content}\n}`, - /** - * /** $A *\/ - */ - MultilineComment: (contents, formatFn) => - [ - ...(contents.length === 1 - ? [`/** ${contents[0]} */`] - : ["/**", ...contents.map((content) => ` * ${content}`), " */"]), - ].map((part) => `${formatFn ? formatFn(part) : part}\n`), - /** - * $A1<...$A2.join(,)> - */ - TypeWithGeneric: (typeName, genericArgs) => { - return `${typeName}${genericArgs.length ? `<${genericArgs.join(",")}>` : ""}`; - }, - } + return `${Ts.ExpressionGroup(content)}[]`; + }, + /** + * "$A" + */ + StringValue: (content) => `"${content}"`, + /** + * $A + */ + BooleanValue: (content) => `${content}`, + /** + * $A + */ + NumberValue: (content) => `${content}`, + /** + * $A + */ + NullValue: (content) => content, + /** + * $A1 | $A2 + */ + UnionType: (contents) => _.join(_.uniq(contents), ` ${Ts.Keyword.Union} `), + /** + * ($A1) + */ + ExpressionGroup: (content) => (content ? `(${content})` : ""), + /** + * $A1 & $A2 + */ + IntersectionType: (contents) => + _.join(_.uniq(contents), ` ${Ts.Keyword.Intersection} `), + /** + * Record<$A1, $A2> + */ + RecordType: (key, value) => + Ts.TypeWithGeneric(Ts.Keyword.Record, [key, value]), + /** + * readonly $key?:$value + */ + TypeField: ({ readonly, key, optional, value }) => + _.compact([ + readonly && "readonly ", + key, + optional && "?", + ": ", + value, + ]).join(""), + /** + * [key: $A1]: $A2 + */ + InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`, + /** + * $A1 = $A2 + */ + EnumField: (key, value) => `${key} = ${value}`, + /** + * $A0.key = $A0.value, + * $A1.key = $A1.value, + * $AN.key = $AN.value, + */ + EnumFieldsWrapper: (contents) => + _.map(contents, ({ key, value }) => ` ${Ts.EnumField(key, value)}`).join( + ",\n", + ), + /** + * {\n $A \n} + */ + ObjectWrapper: (content) => `{\n${content}\n}`, + /** + * /** $A *\/ + */ + MultilineComment: (contents, formatFn) => + [ + ...(contents.length === 1 + ? [`/** ${contents[0]} */`] + : ["/**", ...contents.map((content) => ` * ${content}`), " */"]), + ].map((part) => `${formatFn ? formatFn(part) : part}\n`), + /** + * $A1<...$A2.join(,)> + */ + TypeWithGeneric: (typeName, genericArgs) => { + return `${typeName}${ + genericArgs.length ? `<${genericArgs.join(",")}>` : "" + }`; + }, +}; ``` ## [feature] Ability to modify swagger schema type/format to typescript construction translators + Swagger schema has constructions like `{ "type": "string" | "integer" | etc, "format": "date-time" | "float" | "etc" }` where field `type` is not "readable" for TypeScript. And because of this `swagger-typescript-api` has key value group to translate swagger schema fields `type`/`format` to TypeScript constructions. See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times) For example, current version of default configuration translates this schema + ```json { "type": "string", "format": "date-time" } ``` -translates to -```ts -string -``` + +translates to `string` + If you need to see `Date` instead of `string` you are able to change it with using `primitiveTypeConstructs` + ```ts generateApiForTest({ // ... primitiveTypeConstructs: (construct) => ({ string: { - 'date-time': 'Date' - } - }) -}) + "date-time": "Date", + }, + }), +}); ``` Structure of `primitiveTypes` property + ```ts const primitiveTypes = { - integer: () => Ts.Keyword.Number, - number: () => Ts.Keyword.Number, - boolean: () => Ts.Keyword.Boolean, - object: () => Ts.Keyword.Object, + integer: () => Ts.Keyword.Number, + number: () => Ts.Keyword.Number, + boolean: () => Ts.Keyword.Boolean, + object: () => Ts.Keyword.Object, + file: () => Ts.Keyword.File, + string: { + $default: () => Ts.Keyword.String, + + /** formats */ + binary: () => Ts.Keyword.File, file: () => Ts.Keyword.File, - string: { - $default: () => Ts.Keyword.String, - - /** formats */ - binary: () => Ts.Keyword.File, - file: () => Ts.Keyword.File, - "date-time": () => Ts.Keyword.String, - time: () => Ts.Keyword.String, - date: () => Ts.Keyword.String, - duration: () => Ts.Keyword.String, - email: () => Ts.Keyword.String, - "idn-email": () => Ts.Keyword.String, - "idn-hostname": () => Ts.Keyword.String, - ipv4: () => Ts.Keyword.String, - ipv6: () => Ts.Keyword.String, - uuid: () => Ts.Keyword.String, - uri: () => Ts.Keyword.String, - "uri-reference": () => Ts.Keyword.String, - "uri-template": () => Ts.Keyword.String, - "json-pointer": () => Ts.Keyword.String, - "relative-json-pointer": () => Ts.Keyword.String, - regex: () => Ts.Keyword.String, - }, - array: ({ items, ...schemaPart }, parser) => { - const content = parser.getInlineParseContent(items); - return parser.safeAddNullToType(schemaPart, Ts.ArrayType(content)); - }, - } + "date-time": () => Ts.Keyword.String, + time: () => Ts.Keyword.String, + date: () => Ts.Keyword.String, + duration: () => Ts.Keyword.String, + email: () => Ts.Keyword.String, + "idn-email": () => Ts.Keyword.String, + "idn-hostname": () => Ts.Keyword.String, + ipv4: () => Ts.Keyword.String, + ipv6: () => Ts.Keyword.String, + uuid: () => Ts.Keyword.String, + uri: () => Ts.Keyword.String, + "uri-reference": () => Ts.Keyword.String, + "uri-template": () => Ts.Keyword.String, + "json-pointer": () => Ts.Keyword.String, + "relative-json-pointer": () => Ts.Keyword.String, + regex: () => Ts.Keyword.String, + }, + array: ({ items, ...schemaPart }, parser) => { + const content = parser.getInlineParseContent(items); + return parser.safeAddNullToType(schemaPart, Ts.ArrayType(content)); + }, +}; ``` ## Other + feat: `--another-array-type` cli option (#414) fix: path params with dot style (truck.id) (#413) - - # 10.0.3 + fix: CRLF -> LF (#423) docs: add docs for addReadonly nodeJS api flag (#425) chore: remove useless trailing whitespaces which make test edit harder (thanks @qboot, #422) @@ -378,7 +402,7 @@ chore: add logging (project version, node version, npm version) # 10.0.2 fix: host.fileExists is not a function -fix: other problems linked with new typescript version (4.8.*) (thanks @elkeis, @Jnig) +fix: other problems linked with new typescript version (4.8.\*) (thanks @elkeis, @Jnig) fix: problem with required nested properties based on root required properties list fix: fetch http client headers content type priority fix: fs.rmSync (thanks @smorimoto) @@ -387,7 +411,7 @@ docs: add documentation for `unwrapResponseData` nodejs option (thanks @simowe) BREAKING_CHANGE: rename `.eta` file extensions to `.ejs`. Backward capability should be existed. fix: problem with `--sort-types` option -# 10.0.* +# 10.0.\* fix: problem with default http request headers in axios client @@ -434,39 +458,47 @@ fix: problem with default http request headers in axios client # 9.2.0 Features: + - full response typing for status code, data and headers. (#272, thanks @rustyconover) - --unwrap-response-data to unwrap the data item from the response (#268, thanks @laktak) Fixes: + - fix: formdata in axios template (#277, thanks @tiagoskaneta) # 9.1.2 Fixes: + - Bug with --single-http-client and private `http` property # 9.1.1 Fixes: + - Bug with nested objects in FormData (issue #262, thanks @avlnche64) # 9.1.0 Fixes: + - Critical bug linked with `templateRequire` in ETA templates - Critical bugs linked with `--type-prefix`, `--type-suffix` Internal: + - Improve manual testing scripts # 9.0.2 Fixes: + - 9.0.1 won't build with tsc when imported (thanks @mastermatt) # 9.0.1 Fixes: + - Can't compile 9.0.0 version (thanks @Nihisil ) # 9.0.0 @@ -474,6 +506,7 @@ Fixes: NOTE: This version is not compatible with previous templates (removed `route.request.params`, `apiConfig.props`, `apiConfig.generic`, `apiConfig.description`, `apiConfig.hasDescription`) Fixes: + - Consider 2xx a successful status (thanks @wyozi) - GET method query option bug (thanks @rhkdgns95, @SaschaGalley) - `silent` property missed in `.d.ts` file (thanks @mastermatt) @@ -482,11 +515,11 @@ Fixes: - variable name "params" doesn't uniq (thanks @mixalbl4-127 ) Features: + - `--disableProxy` option (thanks @kel666) - `--extract-request-body` option. Allows to extract request body type to data contract - Add TSDoc tag for deprecated route (thanks @wyozi) - # 8.0.3 - Fixes encoding array query params in `fetch` http templates (thanks @prog13) @@ -494,28 +527,35 @@ Features: # 8.0.2 Fixes: + - Wrong working the `format` option in `fetch` http client # 8.0.1 Fixes: + - Not working `customFetch` Error: `Failed to execute 'fetch' on 'Window': Illegal invocation` # 8.0.0 BREAKING_CHANGES: + - remove default `json` format of the response type (both for `axios` and `fetch` http clients) (issue #213, thanks @po5i) Features: + - Allow passing custom fetch function (`fetch` http client only) - Allow to set global response type format through `HttpClient` constructor Example: + ```ts - const httpClient = new HttpClient({ format: 'json' }); - // all request responses will been formatted as json +const httpClient = new HttpClient({ format: "json" }); +// all request responses will been formatted as json ``` + Fixes: + - Missing `schema.$ref` in inline enum schemas - Array query param values are serialized with the (non-default) comma separated style (issue #222, thanks @Styn, PR #223) - TypeScript error "TS6133: 'E' is declared but its value is never read." (`axios` http client) (issue #220, thanks @pmbednarczyk ) @@ -523,6 +563,7 @@ Fixes: # 7.0.1 Fixes: + - "securityWorker" is only used if "secure" option is specified on each request (issue #212, thanks @dkamyshov) NOTE: added global `secure` option for `axios` http client - `index.d.ts` file (add `rawModelTypes`) @@ -530,16 +571,20 @@ Fixes: # 7.0.0 BREAKING_CHANGES: + - format `namespace` name in `--route-types` as camelCase with upper first capitalized letter `foo_bar` -> `FooBar` Fixes: + - Incorrect working the `--route-types` option with `--modular` option (route types should be splitted on files) - Fix critical bug linked with enums with boolean type (thanks @haedaal) Features: + - Ability to return `false` in `onCreateRoute` hook, it allow to ignore route - Add output util functions + ```ts createFile: (params: { path: string; @@ -570,59 +615,70 @@ Features: # 6.4.2 Fixes: + - Bug with missing `name` property in in-path requests parameters - Problem with usage `--route-types` with `--modular` option (mising import data contracts) # 6.4.1 Fixes: + - Bug with axios headers (thanks @mutoe) # 6.4.0 Features: + - `onFormatRouteName(routeInfo: RawRouteInfo, templateRouteName: string)` hook. Allows to format route name, as you like :) Fixes: + - Bug with wrong complex types (anyOf, oneOf, allOf) when some child schema contains only description ![example](./assets/changelog_assets/fixComplexTypeAny.jpg) - Bug with number enums which have `x-enumNames` - Problem with not existing `title` property in `info` Minor: + - Improve description for complex types - Improve description in single api file # 6.3.0 Features: + - `--type-suffix` option. Allows to set suffix for data contract name. (issue #191, thanks @the-ult) - `--type-prefix` option. Allows to set prefix for data contract name. (issue #191, thanks @the-ult) Examples [here](./spec/typeSuffixPrefix/schema.ts) - `onFormatTypeName(usageTypeName, rawTypeName, schemaType)` hook. Allow to format data contract names as you want. Internal: + - rename and split `checkAndRenameModelName` -> `formatModelName`, `fixModelName` # 6.2.1 Fixes: + - missing `generateUnionEnums?: boolean;` in `index.d.ts` file (thanks @artsaban) - missing default params to axios http client (`--axios`) (issue #192, thanks @Nihisil) # 6.2.0 Features: + - `--module-name-first-tag` option. Splits routes based on the first tag (thanks @jnpoyser) # 6.1.2 Fixes: + - Problems with using both `--axios` and `--modular` options together (TS, `organizeImports` crashed the codegeneration) # 6.1.1 Fixes: + - Problems with `--axios` option - ignoring `path`, `format`, `type` payload properties in `request()` method of `HttpClient` - Missing `format` property for requests in `--modular` option @@ -630,77 +686,92 @@ Fixes: # 6.1.0 Features: + - `--silent` option. Output only errors to console (default: false) Fixes: + - Bug with `kebab-case` path params (issue #184, thanks @Mr-sgreen) - Typings for `--js` option # 6.0.0 BREAKING_CHANGES: + - Ability to override only one template (issue #166, thanks @Nihisil) - removed `TPromise` type for `--responses` options (perf. problem, issue #182, thanks @mixalbl4-127) - breaking changes in `http-client.eta` - `securityWorker` now can return `Promise | RequestParams | void` Features: + - template path prefixes `@base`, `@default`, `@modular` (using in Eta templates, `includeFile()`, see README.md) - `--axios` option for axios http client (issue #142, thanks @msklvsk, @mixalbl4-127 ) # 5.1.7 Fixes: + - Do not fail if template file does not exist (issue #166, thanks @armsnyder ) Caveat: With this fix it will still error if the overridden template uses `includeFile` on a template file that is not overridden # 5.1.6 Fixes: + - The contentFormatter for ContentType:Json does not correctly format strings (issue #176, thanks @Styn) # 5.1.5 Fixes: + - ContentType.FormData no longer sets the correct boundary (issue #172, thanks @Styn) # 5.1.4 Fixes: + - header overwrite in `default` and `modular` API templates (issue #171 by @Styn, thanks @emilecantin for PR with fix) # 5.1.3 Fixes: + - Ignored `x-nullable` field - Schema type names which starts with number or special characters # 5.1.2 Fixes: + - Linter disable rules is not working (issue #164, thanks @Haritaso) # 5.1.1 Fixes: + - The HttpResponse type is no longer exported from http-client (issue #161, thanks @Styn) # 5.1.0 Fixes: + - Bug with optional nested properties of object schema type (issue #156, thanks @Fabiencdp) Features: + - `onCreateRouteName(routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo): RouteNameInfo | void` hook Which allows to customize route name without customizing `route-name.eta` template - Improved content kinds for request infos - `--single-http-client` option which allows to send HttpClient instance to Api constructor and not to create many count of HttpClient instances with `--modular` api (issue #155) Minor: + - A bit improve type declaration file (index.d.ts) for this tool - make exportable `ApiConfig` interface Internal: + - clearing `routeNameDuplicatesMap` before each `parseRoutes()` function call - Changed templates: - `http-client.eta` @@ -710,6 +781,7 @@ Internal: # 5.0.0 Fixes: + - Request content types auto substitution i.e. if request body is form data, then request body content type will be `multipart/form-data` - Strange method name (issue #152, thanks @RoXuS) @@ -717,6 +789,7 @@ Fixes: - Critical bug with `:paramName` path params (issue #154) Features: + - Ability to provide custom formatting `fetch` response - `"IMAGE"` content kind for response\request data objects - `RequestParams` `RequestHeaders` types for `--route-types` (`routeTypes: true`) option (issue #150, thanks @Fabiencdp ) @@ -726,12 +799,14 @@ Features: `HttpClient` instance now have the `abortRequest(cancelToken)` method BREAKING_CHANGES: + - Fully refactored `http-client.eta` template, make it more flexible and simpler. `HttpClient["request"]` takes one argument with type `FullRequestParams` (previously it takes many count of arguments which was not flexible) - Changed the default response body type from `any` to `void` (issue #14) Internal: + - Changed templates: - `http-client.eta` - `procedure-call.eta` @@ -742,9 +817,11 @@ This version works with previous templates. # 4.4.0 Fixes: + - Client generation for `Content-Type: application/x-www-form-urlencoded` (issue #146, thanks @Larox) Internal: + - Changed templates: - `http-client.eta` - `procedure-call.eta` @@ -752,56 +829,65 @@ Internal: # 4.3.0 Fixes: + - enum + nullable: true doesn't compute the good type (issue #145, thanks @RoXuS) - Underscores are omitted from enum keys (issue #108, thanks @eolant) - CLI silently fails if the directory to put new files in doesn't exist yet (issue #141, thanks @Styn) Features: + - Improved type description Internal: + - dependencies update: - `"js-yaml": "^4.0.0"` (`"^3.14.1"`) - `"make-dir": "^3.1.0"` - `"swagger2openapi": "^7.0.5"` (`"^7.0.4"`) - Difference in templates: - `data-contracts.eta` - ![dataContracts430](./assets/changelog_assets/http-client-template-diff-4.3.0.jpg) + ![dataContracts430](./assets/changelog_assets/http-client-template-diff-4.3.0.jpg) # 4.2.0 + Features: + - new hook `onCreateRequestParams` which allows modify request params (`--extract-request-params` option) before sending it to route info ![onCreateRequestParams](./assets/changelog_assets/onCreateRequestParamsHook.jpg) How to use: + ```ts - generateApi({ - // ... your config, - hooks: { - onCreateRequestParams: (rawType) => { - if (Object.keys(rawType.properties).length > 1) return rawType; - - return rawType; - } - } - }) + generateApi({ + // ... your config, + hooks: { + onCreateRequestParams: (rawType) => { + if (Object.keys(rawType.properties).length > 1) return rawType; + + return rawType; + }, + }, + }); ``` + - response content types (array of string like `application/json`, `image/png`) which allows to customize declaration of request response Exist in `procedure-call.eta` template `it.route.response.contentTypes` Internal: + - Difference in templates: - `procedure-call.eta` - ![procedureCallEta1](./assets/changelog_assets/changes_procedure_call_1.jpg) - + ![procedureCallEta1](./assets/changelog_assets/changes_procedure_call_1.jpg) # 4.1.0 Features: + - Improve `require()` function used in ETA templates (using relative path imports) - `--clean-output` option. clean output folder before generate api Fixes: + - Error: `Unexpected token =` (Issue #136, Thanks @jlow-mudbath) - Output folder creation (Issue #137, Thanks @Rinta01) Create output folder if it is not exist @@ -809,41 +895,50 @@ Fixes: # 4.0.5 BREAKING_CHANGE: + - remove `'prettier-plugin-organize-imports'` dependency from package Fixes: + - issue #134 (Thanks @mrfratello) # 4.0.4 Features: + - add `require()` to template `utils` object Docs: + - add information about contributors # 4.0.3 Features: + - `--disableStrictSSL` option for disable strict SSL statement with fetching swagger schema. (Thanks @kel666 for PR with feature request) This option fix problem #114 # 4.0.2 Fixes: - - `Unexpected token '.'` on v4 (Thanks @savingprivatebryan for issue #111) - Replaced all new syntax sugar like `?.` or `??` to prev. alternatives for support nodejs 12 + +- `Unexpected token '.'` on v4 (Thanks @savingprivatebryan for issue #111) + Replaced all new syntax sugar like `?.` or `??` to prev. alternatives for support nodejs 12 # 4.0.1 Fixes: + - `Cannot find module 'prettier-plugin-organize-imports'` #109 # 4.0.0 BREAKING_CHANGES: + - Migrate from [mustache](https://mustache.github.io/) template engine to [ETA](https://eta.js.org/) template engine. (Thanks @Fl0pZz) - Critical change in `HttpResponse` type (Remove `D | null`, `E | null` unions) + ```diff interface HttpResponse extends Response { - data: D | null; @@ -854,16 +949,19 @@ interface HttpResponse extends R ``` Features: + - `--modular` option. Allows to generate api class per module name. Example: [here](./tests/spec/modular) - new templates on [ETA](https://eta.js.org/) (enhanced EJS) which can improve your templates! (Thanks @Fl0pZz) [ETA extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=shadowtime2000.eta-vscode) (thanks @shadowtime2000) Also moved out to templates: - - `procedure-call.eta` (request api method template) - - `route-name.eta` (api method name template) - - `route-docs.eta` (api method docs template) + + - `procedure-call.eta` (request api method template) + - `route-name.eta` (api method name template) + - `route-docs.eta` (api method docs template) No worry about strange syntax it is very simple in usage :) + - Optional templates feature (Except templates using in `includeFile` `ETA` directive) Now you can store only the `ETA` templates which you need to change for yourself. - `--extract-request-params` option. Generate path and query request params data contract and modify request payload args @@ -884,109 +982,126 @@ Features: }>; ``` ```ts - generateApi({ - input: "./schema.json", - output: "./__generated__", - hooks: { - onCreateComponent(component) { - // do something - return component; - }, - // ... - } - }) + generateApi({ + input: "./schema.json", + output: "./__generated__", + hooks: { + onCreateComponent(component) { + // do something + return component; + }, + // ... + }, + }); ``` Internal: + - Update all dependencies to latest Fixes: + - `x-enumNames` support for enums - Problem of complex types (`oneOf`, `allOf`) with `properties` field - `additionalProperties: true` should make `[key: string]: any` for object types (Thanks @brookjordan for issue #103) Common: + - `HttpClient` is exportable by default - Improve typings when use `swagger-typescript-api` with NodeJS (`index.d.ts`) # 3.1.2 + Fixes: + - axios vulnerability (#101 issue, thanks @Mvbraathen) # 3.1.1 Fixes: + - `name.includes is not a function` (issue #98) # 3.1.0 Features: + - `--moduleNameIndex` option. determines which path index should be used for routes separation (Thanks @nikalun) Examples: - GET:api/v1/fruites/getFruit -> index:2 -> moduleName -> fruites - GET:api/v1/fruites/getFruit -> index:0 -> moduleName -> api + GET:api/v1/fruits/getFruit -> index:2 -> moduleName -> fruits + GET:api/v1/fruits/getFruit -> index:0 -> moduleName -> api # 3.0.1 Fixes: + - invalid default templates path (#92, thanks @larrybotha for quick fix) # 3.0.0 BREAKING_CHANGES: + - Renamed mustache templates: - `api.mustache` -> `data-contracts.mustache` - `client.mustache` -> `http.client.mustache` + `api.mustache` - Split the `client.mustache` template into two parts: `http-client.mustache` and `api.mustache` Fixes: + - Fixed unsafe clone() of Response causing json() hang. (Thanks @Benjamin-Dobell) # 2.0.0 Features: + - `--js` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/79) BREAKING_CHANGES: + - Requests returns `Promise>` type. `HttpResponse` it is [Fetch.Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) wrapper with fields `data` and `error` Example: + ```ts - const api = new Api() + const api = new Api(); - // - const response: HttpResponse = await api.fruits.getAll() + // + const response: HttpResponse = await api.fruits.getAll(); - response.data // Data (can be null if response.ok is false) - response.error // Error (can be null if response.ok is true) + response.data; // Data (can be null if response.ok is false) + response.error; // Error (can be null if response.ok is true) ``` + - Breaking changes in the `client.mustache` template. Needs to update local custom templates. Fixes: -- Security configuration in methods. When the security definition is in the main configuration of the swagger definition +- Security configuration in methods. When the security definition is in the main configuration of the swagger definition # 1.12.0 Features: + - Can provide ability to generate from swagger JSON directly not from a file? #69 (Thanks @JennieJi) Fixes: + - handling `x-omitempty` property for definition properties #68 - Additional properties map to empty interfaces (OpenAPI v3) #76 - Pattern fields in Path Item Object are treated as operations #75 - Remove const enum from default template #73 - enums with spaces throw an error #71 - # 1.11.0 Features: + - Improve the naming of model types ([#65 issue](https://github.com/acacode/swagger-typescript-api/issues/65)) # 1.10.0 Features: + - `--templates` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/54) Provide custom `mustache` templates folder which allows to generate custom code (models, Api class, routes) - `--union-enums` CLI option. [[feature request]](https://github.com/acacode/swagger-typescript-api/issues/58) @@ -999,19 +1114,20 @@ Features: } ``` will be converted into: - ``` -export type StringEnum = "String1" | "String2" | "String3" | "String4"; - ``` - + ``` + export type StringEnum = "String1" | "String2" | "String3" | "String4"; + ``` # 1.8.4 Fixes: + - Multiple types for a property in Swagger 2 are not handled correctly ([#55 issue](https://github.com/acacode/swagger-typescript-api/issues/55)) # 1.8.3 Fixes: + - Generating invalid code in composed schema contexts ([#51 issue](https://github.com/acacode/swagger-typescript-api/issues/51)) ```yaml components: @@ -1039,14 +1155,17 @@ Fixes: # 1.8.2 Fixes: + - Broken types for arrays of union types ([issue](https://github.com/acacode/swagger-typescript-api/issues/49)) # 1.8.1 Fixes: + - form data request body (request body content `multipart/form-data`) Minor: + - inline comments of the data contract type properties ![one line comments](./assets/changelog_assets/one-line-comments.jpg) - remove `Array` type usage (now the more simple type `T[]`) @@ -1058,7 +1177,6 @@ Features: - **Partially** support FormData body types - Support to generate query params of nested query objects (Partial fix of [this issue](https://github.com/acacode/swagger-typescript-api/issues/45)) - # 1.7.2 Fixes: @@ -1068,7 +1186,6 @@ Fixes: ![path params bug 1](./assets/changelog_assets/bug-with-no-path-args.jpg) ![path params bug 2](./assets/changelog_assets/bug-with-no-path-args2.jpg) - # 1.7.0 Breaking Changes: @@ -1083,7 +1200,6 @@ Chore: - default value for `SecurityDataType` Api class generic type - # 1.6.3 Fixes: @@ -1091,7 +1207,6 @@ Fixes: - Handling of nullable for $ref in OpenAPI 3.0 ([issue](https://github.com/acacode/swagger-typescript-api/issues/39)) Plus based on this issue was fixed most other problems with using `required` and `nullable` properties - # 1.6.2 Fixes: diff --git a/README.md b/README.md index 379ebd7c..6c72a1ae 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,30 @@ -# swagger-typescript-api +# swagger-typescript-api -[![NPM badge](https://img.shields.io/npm/v/swagger-typescript-api.svg)](https://www.npmjs.com/package/swagger-typescript-api) -[![CI](https://github.com/acacode/swagger-typescript-api/actions/workflows/main.yml/badge.svg?branch=next)](https://github.com/acacode/swagger-typescript-api/actions/workflows/main.yml) -[![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg)](#contributors) - + - +- Generate api via swagger scheme +- Supports OA 3.0, 2.0, JSON, yaml +- Generated api module use [**Fetch Api**](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or [**Axios**](https://github.com/axios/axios) to make requests. -Generate api via swagger scheme. -Supports OA 3.0, 2.0, JSON, yaml -Generated api module use [**Fetch Api**](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or [**Axios**](https://github.com/axios/axios) to make requests. - -

-Any questions you can ask [**here**](https://github.com/acacode/swagger-typescript-api/issues) or in [**our slack**](https://join.slack.com/t/acacode/shared_invite/enQtOTQ5ODgyODQzMzYwLWYxOGI1MzQ3Yzg1ZWI5ZTI5NzNiZjExZTE5OWI1YjQ4NjBiNTk4NWVlNjM5YmU1ZWI2ZDkyMzZkZGIxNjA5NTQ)(**#swagger-typescript-api** channel) - -
- -![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/components-converter-example.jpg) - -P.S. If you are creating the PR, please check your changes with using command `npm run prepare` -P.S. If you want to contribute please use the `next` branch. All PRs that has target `master` will be declined! - +Any questions you can ask [**here**](https://github.com/acacode/swagger-typescript-api/issues) or in [**our Slack**](https://join.slack.com/t/acacode/shared_invite/enQtOTQ5ODgyODQzMzYwLWYxOGI1MzQ3Yzg1ZWI5ZTI5NzNiZjExZTE5OWI1YjQ4NjBiNTk4NWVlNjM5YmU1ZWI2ZDkyMzZkZGIxNjA5NTQ)(**#swagger-typescript-api** channel) -Thanks to [Jetbrains](https://www.jetbrains.com/?from=swaggertypescriptapi) for providing a free license for their excellent Webstorm IDE. - - Jetbrains - +![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/components-converter-example.jpg) +Thanks to [JetBrains](https://www.jetbrains.com/?from=swaggertypescriptapi) for providing a free license for their excellent Webstorm IDE. -## 👀 Examples +## 👀 Examples -All examples you can find [**here**](https://github.com/acacode/swagger-typescript-api/tree/master/tests) +All examples you can find [**here**](https://github.com/acacode/swagger-typescript-api/tree/master/tests) -## 📄 Usage +## 📄 Usage ```muse Usage: sta [options] @@ -63,7 +52,7 @@ Options: --extract-response-error extract response error type to data contract (default: false) --modular generate separated files for http client, data contracts, and routes (default: false) --js generate js api module with declaration file (default: false) - --module-name-index determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites) (default: 0) + --module-name-index determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits) (default: 0) --module-name-first-tag splits routes based on the first tag (default: false) --disableStrictSSL disabled strict SSL (default: false) --disableProxy disabled proxy (default: false) @@ -97,14 +86,16 @@ Commands: -h, --help display help for command ``` -Also you can use `npx`: +Also you can use `npx`: + ``` - npx swagger-typescript-api -p ./swagger.json -o ./src -n myApi.ts +npx swagger-typescript-api -p ./swagger.json -o ./src -n myApi.ts ``` You can use this package from nodejs: + ```js -const { generateApi, generateTemplates } = require('swagger-typescript-api'); +const { generateApi, generateTemplates } = require("swagger-typescript-api"); const path = require("path"); const fs = require("fs"); @@ -113,8 +104,8 @@ generateApi({ name: "MySuperbApi.ts", // set to `false` to prevent the tool from writing to disk output: path.resolve(process.cwd(), "./src/__generated__"), - url: 'http://api.com/swagger.json', - input: path.resolve(process.cwd(), './foo/swagger.json'), + url: "http://api.com/swagger.json", + input: path.resolve(process.cwd(), "./foo/swagger.json"), spec: { swagger: "2.0", info: { @@ -123,7 +114,7 @@ generateApi({ }, // ... }, - templates: path.resolve(process.cwd(), './api-templates'), + templates: path.resolve(process.cwd(), "./api-templates"), httpClientType: "axios", // or "fetch" defaultResponseAsSuccess: false, generateClient: true, @@ -134,7 +125,8 @@ generateApi({ extractRequestBody: false, extractEnums: false, unwrapResponseData: false, - prettier: { // By default prettier config is load from your project + prettier: { + // By default prettier config is load from your project printWidth: 120, tabWidth: 2, trailingComma: "all", @@ -146,10 +138,10 @@ generateApi({ enumNamesAsValues: false, moduleNameFirstTag: false, generateUnionEnums: false, - typePrefix: '', - typeSuffix: '', - enumKeyPrefix: '', - enumKeySuffix: '', + typePrefix: "", + typeSuffix: "", + enumKeyPrefix: "", + enumKeySuffix: "", addReadonly: false, sortTypes: false, sortRouters: false, @@ -157,22 +149,29 @@ generateApi({ requestBodySuffix: ["Payload", "Body", "Input"], requestParamsSuffix: ["Params"], responseBodySuffix: ["Data", "Result", "Output"], - responseErrorSuffix: ["Error", "Fail", "Fails", "ErrorData", "HttpError", "BadResponse"], + responseErrorSuffix: [ + "Error", + "Fail", + "Fails", + "ErrorData", + "HttpError", + "BadResponse", + ], }, /** allow to generate extra files based with this extra templates, see more below */ extraTemplates: [], anotherArrayType: false, fixInvalidTypeNamePrefix: "Type", - fixInvalidEnumKeyPrefix: "Value", + fixInvalidEnumKeyPrefix: "Value", codeGenConstructs: (constructs) => ({ ...constructs, - RecordType: (key, value) => `MyRecord` + RecordType: (key, value) => `MyRecord`, }), primitiveTypeConstructs: (constructs) => ({ - ...constructs, - string: { - 'date-time': 'Date' - } + ...constructs, + string: { + "date-time": "Date", + }, }), hooks: { onCreateComponent: (component) => {}, @@ -185,15 +184,14 @@ generateApi({ onPreParseSchema: (originalSchema, typeName, schemaType) => {}, onParseSchema: (originalSchema, parsedSchema) => {}, onPrepareConfig: (currentConfiguration) => {}, - } + }, }) .then(({ files, configuration }) => { files.forEach(({ content, name }) => { fs.writeFile(path, content); }); }) - .catch(e => console.error(e)) - + .catch((e) => console.error(e)); generateTemplates({ cleanOutput: false, @@ -202,83 +200,78 @@ generateTemplates({ modular: false, silent: false, rewrite: false, -}) - +}); ``` +## 💎 options + +### **`--templates`** -## 💎 options -### **`--templates`** -This option needed for cases when you don't want to use the default `swagger-typescript-api` output structure -You can create custom templates with extensions `.ejs` or `.eta` +This option needed for cases when you don't want to use the default `swagger-typescript-api` output structure +You can create custom templates with extensions `.ejs` or `.eta` -Templates: -- `api.ejs` - *(generates file)* Api class module (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.ejs)) -- `data-contracts.ejs` - *(generates file)* all types (data contracts) from swagger schema (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.ejs)) -- `http-client.ejs` - *(generates file)* HttpClient class module (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.ejs)) -- `procedure-call.ejs` - *(subtemplate)* route in Api class (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.ejs)) -- `route-docs.ejs` - *(generates file)* documentation for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.ejs)) -- `route-name.ejs` - *(subtemplate)* route name for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.ejs)) -- `route-type.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs)) -- `route-types.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.ejs)) -- `data-contract-jsdoc.ejs` - *(subtemplate)* generates JSDOC for data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs)) +Templates: -[//]: # (- `enum-data-contract.ejs` - *(subtemplate)* generates `enum` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs))) -[//]: # (- `interface-data-contract.ejs` - *(subtemplate)* generates `interface` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs))) -[//]: # (- `type-data-contract.ejs` - *(subtemplate)* generates `type` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs))) +- `api.ejs` - _(generates file)_ Api class module (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.ejs)) +- `data-contracts.ejs` - _(generates file)_ all types (data contracts) from swagger schema (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.ejs)) +- `http-client.ejs` - _(generates file)_ HttpClient class module (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.ejs)) +- `procedure-call.ejs` - _(subtemplate)_ route in Api class (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.ejs)) +- `route-docs.ejs` - _(generates file)_ documentation for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.ejs)) +- `route-name.ejs` - _(subtemplate)_ route name for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.ejs)) +- `route-type.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs)) +- `route-types.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.ejs)) +- `data-contract-jsdoc.ejs` - _(subtemplate)_ generates JSDOC for data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs)) +[//]: # "- `enum-data-contract.ejs` - *(subtemplate)* generates `enum` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs))" +[//]: # "- `interface-data-contract.ejs` - *(subtemplate)* generates `interface` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs))" +[//]: # "- `type-data-contract.ejs` - *(subtemplate)* generates `type` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs))" + +How to use it: -How to use it: 1. copy `swagger-typescript-api` templates into your place in project - - from [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default) for single api file - - from [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular) for multiple api files (with `--modular` option) - - from [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base) for base templates (templates using both in default and modular) -1. add `--templates PATH_TO_YOUR_TEMPLATES` option -2. modify [ETA](https://eta.js.org/docs/syntax) templates as you like - -NOTE: - Eta has special directive to render template in your Eta templates - `includeFile(pathToTemplate, payload)` - If you want to use some default templates from this tool you can use path prefixes: `@base`, `@default`, `@modular`. - `@base` - [path to base templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base) - `@default` - [path to single api file templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default) - `@modular` - [path to multiple api files templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular) - Examples: - - `includeFile("@base/data-contracts.ejs", { ...yourData, ...it })` - - `includeFile("@default/api.ejs", { ...yourData, ...it })` - - `includeFile("@default/procedure-call.ejs", { ...yourData, ...it })` - - `includeFile("@modular/api.ejs", { ...yourData, ...it })` - - `includeFile("@modular/procedure-call.ejs", { ...yourData, ...it })` - - `includeFile("@base/route-docs.ejs", { ...yourData, ...it })` - - `includeFile("@base/route-name.ejs", { ...yourData, ...it })` - - `includeFile("@base/route-type.ejs", { ...yourData, ...it })` - - `includeFile("@base/route-types.ejs", { ...yourData, ...it })` - -### **`--module-name-index`** -This option should be used in cases when you have api with one global prefix like `/api` -Example: -`GET:/api/fruits/getFruits` -`POST:/api/fruits/addFruits` -`GET:/api/vegetables/addVegetable` -with `--module-name-index 0` Api class will have one property `api` -When we change it to `--module-name-index 1` then Api class have two properties `fruits` and `vegetables` - -### **`--module-name-first-tag`** -This option will group your API operations based on their first tag - mirroring how the Swagger UI groups displayed operations - -### `extraTemplates` (NodeJS option) -type `(Record & { name: string, path: string })[]` -This thing allow you to generate extra ts\js files based on extra templates (one extra template for one ts\js file) -[Example here](https://github.com/acacode/swagger-typescript-api/tree/next/tests/spec/extra-templates) - - -## `generate-templates` command + - from [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default) for single api file + - from [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular) for multiple api files (with `--modular` option) + - from [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base) for base templates (templates using both in default and modular) +1. add `--templates PATH_TO_YOUR_TEMPLATES` option +1. modify [ETA](https://eta.js.org/docs/syntax) templates as you like + +NOTE: +Eta has special directive to render template in your Eta templates - `includeFile(pathToTemplate, payload)` +If you want to use some default templates from this tool you can use path prefixes: `@base`, `@default`, `@modular`. +`@base` - [path to base templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base) +`@default` - [path to single api file templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default) +`@modular` - [path to multiple api files templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular) +Examples: - `includeFile("@base/data-contracts.ejs", { ...yourData, ...it })` - `includeFile("@default/api.ejs", { ...yourData, ...it })` - `includeFile("@default/procedure-call.ejs", { ...yourData, ...it })` - `includeFile("@modular/api.ejs", { ...yourData, ...it })` - `includeFile("@modular/procedure-call.ejs", { ...yourData, ...it })` - `includeFile("@base/route-docs.ejs", { ...yourData, ...it })` - `includeFile("@base/route-name.ejs", { ...yourData, ...it })` - `includeFile("@base/route-type.ejs", { ...yourData, ...it })` - `includeFile("@base/route-types.ejs", { ...yourData, ...it })` + +### **`--module-name-index`** + +This option should be used in cases when you have api with one global prefix like `/api` +Example: +`GET:/api/fruits/getFruits` +`POST:/api/fruits/addFruits` +`GET:/api/vegetables/addVegetable` +with `--module-name-index 0` Api class will have one property `api` +When we change it to `--module-name-index 1` then Api class have two properties `fruits` and `vegetables` + +### **`--module-name-first-tag`** + +This option will group your API operations based on their first tag - mirroring how the Swagger UI groups displayed operations + +### `extraTemplates` (NodeJS option) + +type `(Record & { name: string, path: string })[]` +This thing allow you to generate extra ts\js files based on extra templates (one extra template for one ts\js file) +[Example here](https://github.com/acacode/swagger-typescript-api/tree/next/tests/spec/extra-templates) + +## `generate-templates` command + This command allows you to generate source templates which using with option `--templates` -## Modification internal codegen structs with NodeJS API: +## Modification internal codegen structs with NodeJS API: -You are able to modify TypeScript internal structs using for generating output with using `generateApi` options `codeGenConstructs` and `primitiveTypeConstructs`. +You are able to modify TypeScript internal structs using for generating output with using `generateApi` options `codeGenConstructs` and `primitiveTypeConstructs`. -### `codeGenConstructs` +### `codeGenConstructs` This option has type `(struct: CodeGenConstruct) => Partial`. @@ -286,281 +279,235 @@ This option has type `(struct: CodeGenConstruct) => Partial`. generateApi({ // ... codeGenConstructs: (struct) => ({ - Keyword: { - Number: "number", - String: "string", - Boolean: "boolean", - Any: "any", - Void: "void", - Unknown: "unknown", - Null: "null", - Undefined: "undefined", - Object: "object", - File: "File", - Date: "Date", - Type: "type", - Enum: "enum", - Interface: "interface", - Array: "Array", - Record: "Record", - Intersection: "&", - Union: "|", - }, - CodeGenKeyword: { - UtilRequiredKeys: "UtilRequiredKeys", - }, - /** - * $A[] or Array<$A> - */ - ArrayType: (content) => { - if (this.anotherArrayType) { - return `Array<${content}>`; - } - - return `(${content})[]`; - }, - /** - * "$A" - */ - StringValue: (content) => `"${content}"`, - /** - * $A - */ - BooleanValue: (content) => `${content}`, - /** - * $A - */ - NumberValue: (content) => `${content}`, - /** - * $A - */ - NullValue: (content) => content, - /** - * $A1 | $A2 - */ - UnionType: (contents) => _.join(_.uniq(contents), ` | `), - /** - * ($A1) - */ - ExpressionGroup: (content) => (content ? `(${content})` : ""), - /** - * $A1 & $A2 - */ - IntersectionType: (contents) => _.join(_.uniq(contents), ` & `), - /** - * Record<$A1, $A2> - */ - RecordType: (key, value) => `Record<${key}, ${value}>`, - /** - * readonly $key?:$value - */ - TypeField: ({ readonly, key, optional, value }) => - _.compact([readonly && "readonly ", key, optional && "?", ": ", value]).join(""), - /** - * [key: $A1]: $A2 - */ - InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`, - /** - * $A1 = $A2 - */ - EnumField: (key, value) => `${key} = ${value}`, - /** - * $A0.key = $A0.value, - * $A1.key = $A1.value, - * $AN.key = $AN.value, - */ - EnumFieldsWrapper: (contents) => - _.map(contents, ({ key, value }) => ` ${key} = ${value}`).join(",\n"), - /** - * {\n $A \n} - */ - ObjectWrapper: (content) => `{\n${content}\n}`, - /** - * /** $A *\/ - */ - MultilineComment: (contents, formatFn) => - [ - ...(contents.length === 1 - ? [`/** ${contents[0]} */`] - : ["/**", ...contents.map((content) => ` * ${content}`), " */"]), - ].map((part) => `${formatFn ? formatFn(part) : part}\n`), - /** - * $A1<...$A2.join(,)> - */ - TypeWithGeneric: (typeName, genericArgs) => { - return `${typeName}${genericArgs.length ? `<${genericArgs.join(",")}>` : ""}`; - }, - }) -}) -``` + Keyword: { + Number: "number", + String: "string", + Boolean: "boolean", + Any: "any", + Void: "void", + Unknown: "unknown", + Null: "null", + Undefined: "undefined", + Object: "object", + File: "File", + Date: "Date", + Type: "type", + Enum: "enum", + Interface: "interface", + Array: "Array", + Record: "Record", + Intersection: "&", + Union: "|", + }, + CodeGenKeyword: { + UtilRequiredKeys: "UtilRequiredKeys", + }, + /** + * $A[] or Array<$A> + */ + ArrayType: (content) => { + if (this.anotherArrayType) { + return `Array<${content}>`; + } -For example, if you need to generate output `Record` instead of `object` you can do it with using following code: + return `(${content})[]`; + }, + /** + * "$A" + */ + StringValue: (content) => `"${content}"`, + /** + * $A + */ + BooleanValue: (content) => `${content}`, + /** + * $A + */ + NumberValue: (content) => `${content}`, + /** + * $A + */ + NullValue: (content) => content, + /** + * $A1 | $A2 + */ + UnionType: (contents) => _.join(_.uniq(contents), ` | `), + /** + * ($A1) + */ + ExpressionGroup: (content) => (content ? `(${content})` : ""), + /** + * $A1 & $A2 + */ + IntersectionType: (contents) => _.join(_.uniq(contents), ` & `), + /** + * Record<$A1, $A2> + */ + RecordType: (key, value) => `Record<${key}, ${value}>`, + /** + * readonly $key?:$value + */ + TypeField: ({ readonly, key, optional, value }) => + _.compact([ + readonly && "readonly ", + key, + optional && "?", + ": ", + value, + ]).join(""), + /** + * [key: $A1]: $A2 + */ + InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`, + /** + * $A1 = $A2 + */ + EnumField: (key, value) => `${key} = ${value}`, + /** + * $A0.key = $A0.value, + * $A1.key = $A1.value, + * $AN.key = $AN.value, + */ + EnumFieldsWrapper: (contents) => + _.map(contents, ({ key, value }) => ` ${key} = ${value}`).join(",\n"), + /** + * {\n $A \n} + */ + ObjectWrapper: (content) => `{\n${content}\n}`, + /** + * /** $A *\/ + */ + MultilineComment: (contents, formatFn) => + [ + ...(contents.length === 1 + ? [`/** ${contents[0]} */`] + : ["/**", ...contents.map((content) => ` * ${content}`), " */"]), + ].map((part) => `${formatFn ? formatFn(part) : part}\n`), + /** + * $A1<...$A2.join(,)> + */ + TypeWithGeneric: (typeName, genericArgs) => { + return `${typeName}${ + genericArgs.length ? `<${genericArgs.join(",")}>` : "" + }`; + }, + }), +}); +``` + +For example, if you need to generate output `Record` instead of `object` you can do it with using following code: ```ts generateApi({ - // ... - codeGenConstructs: (struct) => ({ - Keyword: { - Object: "Record", - } - }) -}) + // ... + codeGenConstructs: (struct) => ({ + Keyword: { + Object: "Record", + }, + }), +}); ``` -### `primitiveTypeConstructs` +### `primitiveTypeConstructs` + +It is type mapper or translator swagger schema objects. `primitiveTypeConstructs` translates `type`/`format` schema fields to typescript structs. +This option has type -It is type mapper or translator swagger schema objects. `primitiveTypeConstructs` translates `type`/`format` schema fields to typescript structs. -This option has type ```ts type PrimitiveTypeStructValue = | string - | ((schema: Record, parser: import("./src/schema-parser/schema-parser").SchemaParser) => string); + | (( + schema: Record, + parser: import("./src/schema-parser/schema-parser").SchemaParser, + ) => string); type PrimitiveTypeStruct = Record< "integer" | "number" | "boolean" | "object" | "file" | "string" | "array", - string | ({ $default: PrimitiveTypeStructValue } & Record) -> + | string + | ({ $default: PrimitiveTypeStructValue } & Record< + string, + PrimitiveTypeStructValue + >) +>; -declare const primitiveTypeConstructs: (struct: PrimitiveTypeStruct) => Partial +declare const primitiveTypeConstructs: ( + struct: PrimitiveTypeStruct, +) => Partial; generateApi({ - // ... - primitiveTypeConstructs: (struct) => ({ - integer: () => "number", - number: () => "number", - boolean: () => "boolean", - object: () => "object", - file: () => "File", - string: { - $default: () => "string", - - /** formats */ - binary: () => "File", - file: () => "File", - "date-time": () => "string", - time: () => "string", - date: () => "string", - duration: () => "string", - email: () => "string", - "idn-email": () => "string", - "idn-hostname": () => "string", - ipv4: () => "string", - ipv6: () => "string", - uuid: () => "string", - uri: () => "string", - "uri-reference": () => "string", - "uri-template": () => "string", - "json-pointer": () => "string", - "relative-json-pointer": () => "string", - regex: () => "string", - }, - array: (schema, parser) => { - const content = parser.getInlineParseContent(schema.items); - return parser.safeAddNullToType(schema, `(${content})[]`); - }, - }) -}) + // ... + primitiveTypeConstructs: (struct) => ({ + integer: () => "number", + number: () => "number", + boolean: () => "boolean", + object: () => "object", + file: () => "File", + string: { + $default: () => "string", + + /** formats */ + binary: () => "File", + file: () => "File", + "date-time": () => "string", + time: () => "string", + date: () => "string", + duration: () => "string", + email: () => "string", + "idn-email": () => "string", + "idn-hostname": () => "string", + ipv4: () => "string", + ipv6: () => "string", + uuid: () => "string", + uri: () => "string", + "uri-reference": () => "string", + "uri-template": () => "string", + "json-pointer": () => "string", + "relative-json-pointer": () => "string", + regex: () => "string", + }, + array: (schema, parser) => { + const content = parser.getInlineParseContent(schema.items); + return parser.safeAddNullToType(schema, `(${content})[]`); + }, + }), +}); ``` -For example, if you need to change `"string"/"date-time"` default output as `string` to `Date` you can do it with using following code: +For example, if you need to change `"string"/"date-time"` default output as `string` to `Date` you can do it with using following code: ```ts - generateApi({ - primitiveTypeConstructs: (struct) => ({ - string: { - "date-time": "Date", - }, - }) -}) - + primitiveTypeConstructs: (struct) => ({ + string: { + "date-time": "Date", + }, + }), +}); ``` -See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times) - -## 📄 Mass media - -- [5 Lessons learned about swagger-typescript-api](https://christo8989.medium.com/5-lessons-learned-about-swagger-typescript-api-511240b34c1) -- [Why Swagger schemes are needed in frontend development ?](https://dev.to/js2me/why-swagger-schemes-are-needed-in-frontend-development-2cb4) -- [Migration en douceur vers TypeScript (French)](https://www.premieroctet.com/blog/migration-typescript/) -- [swagger-typescript-api usage (Japanese)](https://zenn.dev/watahaya/articles/2f4a716c47903b) - -## 🛠️ Contribution - -❗❗❗ Please use the `next` branch :) - -If you need to check your changes at schemas in `tests` folder before create a PR just run command `npm run test-all` - -## Contributors ✨ - -Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sergey S. Volkov
Sergey S. Volkov

💻 📖 🎨 💡 🚧 🤔 🐛
Filimonov Andrey
Filimonov Andrey

💻 🤔 🎨
Rafael Fakhreev
Rafael Fakhreev

💻 🤔
Lucas Azzola
Lucas Azzola

💻 🤔 🎨
Jennie
Jennie

💻 🤔
Jose Enrique Marquez
Jose Enrique Marquez

💻 🐛
Benjamin Dobell
Benjamin Dobell

💻 🐛
Larry Botha
Larry Botha

💻 🐛
Nikolay Lukinykh
Nikolay Lukinykh

💻 🤔 🐛
Marius Bråthen
Marius Bråthen

🛡️
Evgeny Vlasov
Evgeny Vlasov

🤔
Fabio
Fabio

🐛 💻
Fabien
Fabien

🐛
Rousseau Julien
Rousseau Julien

🐛
Sebastián Arias
Sebastián Arias

🐛
Stijn Lammens
Stijn Lammens

🐛 💻
Emile Cantin
Emile Cantin

🐛 💻
Adam Snyder
Adam Snyder

💻 🐛
James Poyser
James Poyser

💻 🤔
Alexey
Alexey

🐛
江麻妞
江麻妞

💻
Kasper Moskwiak
Kasper Moskwiak

💻 🤔
baggoedw
baggoedw

💻
Marcus Dunn
Marcus Dunn

💻 🐛
Daniel Playfair Cal
Daniel Playfair Cal

💻 🐛
Patrick Shaw
Patrick Shaw

👀
Brook Jordan
Brook Jordan

💻
RoCat
RoCat

💻 🤔 🎨
Oleg Kuzava
Oleg Kuzava

💻 🐛
Niklas Frank
Niklas Frank

💻 🐛
Quentin Brunet
Quentin Brunet

💻
Gor Rustamyan
Gor Rustamyan

💻 🐛
Jochen Diekenbrock
Jochen Diekenbrock

💻 🐛
- - - - - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! - -## 🚀 How it looks - -![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/npx.gif) - -![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/auth-example.gif) - -![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/typings1.gif) - - -## 📝 License +See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times) + +## 📄 Mass media + +- [5 Lessons learned about swagger-typescript-api](https://christo8989.medium.com/5-lessons-learned-about-swagger-typescript-api-511240b34c1) +- [Why Swagger schemes are needed in frontend development ?](https://dev.to/js2me/why-swagger-schemes-are-needed-in-frontend-development-2cb4) +- [Migration en douceur vers TypeScript (French)](https://www.premieroctet.com/blog/migration-typescript/) +- [swagger-typescript-api usage (Japanese)](https://zenn.dev/watahaya/articles/2f4a716c47903b) + +## 🛠️ Contribution + +❗❗❗ Please use the `next` branch :) + +If you need to check your changes at schemas in `tests` folder before create a PR just run command `npm run test-all` + +## 🚀 How it looks + +![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/npx.gif) + +![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/auth-example.gif) + +![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/typings1.gif) + +## 📝 License + Licensed under the [MIT License](https://github.com/acacode/swagger-typescript-api/blob/master/LICENSE). diff --git a/biome.json b/biome.json index 394d1ad5..fc39d28b 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,17 @@ { "$schema": "node_modules/@biomejs/biome/configuration_schema.json", + "files": { + "ignore": [ + "package.json", + "tests/**/*.json", + "tests/**/expected.ts", + "tests/**/expected/**", + "tests/**/generated/**", + "tests/**/schema.d.ts", + "tests/**/schema.js", + "tests/**/schema.ts" + ] + }, "formatter": { "enabled": true, "indentStyle": "space" diff --git a/cli/constants.js b/cli/constants.js index ed50bc9f..02b90d01 100644 --- a/cli/constants.js +++ b/cli/constants.js @@ -1,7 +1,7 @@ -const root_command = Symbol('root'); -const skip_command = Symbol('skip'); +const root_command = Symbol("root"); +const skip_command = Symbol("skip"); -const reservedOptions = ['version', 'help']; +const reservedOptions = ["version", "help"]; module.exports = { root_command, diff --git a/cli/execute.js b/cli/execute.js index 263ffd85..ee403844 100644 --- a/cli/execute.js +++ b/cli/execute.js @@ -1,7 +1,7 @@ -const _ = require('lodash'); -const { root_command, skip_command } = require('./constants'); -const { parseArgs } = require('./parse-args'); -const didYouMean = require('didyoumean'); +const _ = require("lodash"); +const { root_command, skip_command } = require("./constants"); +const { parseArgs } = require("./parse-args"); +const didYouMean = require("didyoumean"); didYouMean.threshold = 0.5; @@ -19,7 +19,7 @@ const execute = (params, commands, instance) => { if (!usageOptions.length && command.name === root_command) { usageOptions.push( - command.options.find((option) => option.flags.name === 'help'), + command.options.find((option) => option.flags.name === "help"), ); } @@ -32,7 +32,7 @@ const execute = (params, commands, instance) => { }); return; } else { - let error = ''; + let error = ""; const processUserOptionData = (userOption, option) => { if (userOption) { @@ -43,7 +43,7 @@ const execute = (params, commands, instance) => { if (option.flags.value) { if (option.flags.value.variadic) { return data.reduce((acc, d) => { - acc.push(...d.split(',').map(option.flags.value.formatter)); + acc.push(...d.split(",").map(option.flags.value.formatter)); return acc; }, []); } else { @@ -94,7 +94,7 @@ const processArgs = (commands, args) => { let command = null; let usageOptions = []; let walkingOption = null; - let error = ''; + let error = ""; let allFlagKeys = []; @@ -104,10 +104,10 @@ const processArgs = (commands, args) => { if (i === 0) { command = commands[arg]; - if (!command && !arg.startsWith('-')) { + if (!command && !arg.startsWith("-")) { const tip = didYouMean(arg, _.keys(commands)); error = `unknown command ${arg}${ - tip ? `\n(Did you mean ${tip} ?)` : '' + tip ? `\n(Did you mean ${tip} ?)` : "" }`; } else if (!command) { command = commands[root_command]; @@ -123,7 +123,7 @@ const processArgs = (commands, args) => { if (error) return; - if (arg.startsWith('-')) { + if (arg.startsWith("-")) { const option = command.options.find((option) => option.flags.keys.includes(arg), ); @@ -131,7 +131,7 @@ const processArgs = (commands, args) => { if (!option) { const tip = didYouMean(arg, allFlagKeys); error = `unknown option ${arg}${ - tip ? `\n(Did you mean ${tip} ?)` : '' + tip ? `\n(Did you mean ${tip} ?)` : "" }`; } diff --git a/cli/index.js b/cli/index.js index 9d867f4f..13e85d19 100644 --- a/cli/index.js +++ b/cli/index.js @@ -1,9 +1,9 @@ -const _ = require('lodash'); -const { reservedOptions, root_command } = require('./constants'); -const { processOption } = require('./process-option'); -const { execute } = require('./execute'); -const { displayHelp } = require('./operations/display-help'); -const { displayVersion } = require('./operations/display-version'); +const _ = require("lodash"); +const { reservedOptions, root_command } = require("./constants"); +const { processOption } = require("./process-option"); +const { execute } = require("./execute"); +const { displayHelp } = require("./operations/display-help"); +const { displayVersion } = require("./operations/display-version"); const cli = (input) => { const commands = {}; @@ -11,15 +11,15 @@ const cli = (input) => { const addCommand = (command, { addVersion = false, addHelp = true } = {}) => { commands[command.name] = { name: command.name, - description: `${command.description || ''}`, + description: `${command.description || ""}`, options: _.compact(_.map(command.options, processOption)), }; if (addVersion) { commands[command.name].options.unshift( processOption({ - flags: '-v, --version', - description: 'output the current version', + flags: "-v, --version", + description: "output the current version", operation: () => displayVersion(instance), }), ); @@ -28,8 +28,8 @@ const cli = (input) => { if (addHelp) { commands[command.name].options.push( processOption({ - flags: '-h, --help', - description: 'display help for command', + flags: "-h, --help", + description: "display help for command", operation: () => displayHelp(commands, instance, commands[command.name]), }), @@ -63,7 +63,7 @@ const cli = (input) => { if (!processed) return; if (reservedOptions.includes(processed.name)) { - console.warn('reserved option', processed.name); + console.warn("reserved option", processed.name); return; } @@ -72,16 +72,16 @@ const cli = (input) => { commands[root_command].options.unshift( processOption({ - flags: '-v, --version', - description: 'output the current version', + flags: "-v, --version", + description: "output the current version", operation: () => displayVersion(instance), }), ); commands[root_command].options.push( processOption({ - flags: '-h, --help', - description: 'display help for command', + flags: "-h, --help", + description: "display help for command", operation: () => displayHelp(commands, instance, commands[root_command]), }), ); diff --git a/cli/operations/display-help.js b/cli/operations/display-help.js index c1267908..149209ea 100644 --- a/cli/operations/display-help.js +++ b/cli/operations/display-help.js @@ -1,18 +1,18 @@ -const _ = require('lodash'); -const { root_command } = require('../constants'); +const _ = require("lodash"); +const { root_command } = require("../constants"); const generateOptionsOutput = (options) => options.reduce( (acc, option) => { - const flags = `${option.flags.keys.join(', ')}${ - option.flags.value?.raw ? ` ${option.flags.value?.raw}` : '' + const flags = `${option.flags.keys.join(", ")}${ + option.flags.value?.raw ? ` ${option.flags.value?.raw}` : "" }`; - const description = `${option.description || ''}${ + const description = `${option.description || ""}${ option.default === undefined || (option.flags.isNoFlag && option.default === true) - ? '' + ? "" : ` (default: ${ - typeof option.default === 'string' + typeof option.default === "string" ? `"${option.default}"` : option.default })` @@ -37,10 +37,10 @@ const generateOptionsOutput = (options) => const generateOptionsTextOutput = (options, maxLength, spaces) => options .map((option) => { - const spacesText = Array(spaces).fill(' ').join(''); - const leftStr = `${spacesText}${option.flags.padEnd(maxLength, ' ')} `; - const leftStrFiller = Array(leftStr.length).fill(' ').join(''); - const descriptionLines = option.description.split('\n'); + const spacesText = Array(spaces).fill(" ").join(""); + const leftStr = `${spacesText}${option.flags.padEnd(maxLength, " ")} `; + const leftStrFiller = Array(leftStr.length).fill(" ").join(""); + const descriptionLines = option.description.split("\n"); return ( leftStr + @@ -52,10 +52,10 @@ const generateOptionsTextOutput = (options, maxLength, spaces) => return `\n${leftStrFiller}${line}`; }) - .join('') + .join("") ); }) - .join('\n'); + .join("\n"); const displayAllHelp = (commands, instance) => { const { options, maxLength: maxOptionLength } = generateOptionsOutput( @@ -68,7 +68,7 @@ const displayAllHelp = (commands, instance) => { ).reduce( (acc, command) => { const options = generateOptionsOutput(command.options); - const name = `${command.name}${options.length ? ' [options]' : ''}`; + const name = `${command.name}${options.length ? " [options]" : ""}`; const description = command.description; const maxLength = Math.max(name.length, options.maxLength); @@ -95,10 +95,10 @@ const displayAllHelp = (commands, instance) => { .map((commandLabel) => { const leftStr = ` ${commandLabel.name.padEnd( maxCommandLength, - ' ', + " ", )} `; - const leftStrFiller = Array(leftStr.length).fill(' ').join(''); - const descriptionLines = commandLabel.description.split('\n'); + const leftStrFiller = Array(leftStr.length).fill(" ").join(""); + const descriptionLines = commandLabel.description.split("\n"); const optionsTextOutput = generateOptionsTextOutput( commandLabel.options.options, maxCommandLength, @@ -115,11 +115,11 @@ const displayAllHelp = (commands, instance) => { return `\n${leftStrFiller}${line}`; }) - .join('') + - (optionsTextOutput.length ? `\n${optionsTextOutput}` : '') + .join("") + + (optionsTextOutput.length ? `\n${optionsTextOutput}` : "") ); }) - .join('\n'); + .join("\n"); const outputTest = [ optionsOutput && @@ -130,12 +130,12 @@ ${optionsOutput}`, ${commandsOutput}`, ] .filter(Boolean) - .join('\n\n'); + .join("\n\n"); console.log(`Usage: ${[instance.input.name, instance.input.alias] .filter(Boolean) - .join('|')}${optionsOutput ? ' [options]' : ''}${ - commandsOutput ? ' [command]' : '' + .join("|")}${optionsOutput ? " [options]" : ""}${ + commandsOutput ? " [command]" : "" } ${ instance.input.description && @@ -160,10 +160,10 @@ const displayHelp = (commands, instance, command) => { ${optionsOutput}`, ] .filter(Boolean) - .join('\n\n'); + .join("\n\n"); console.log(`Usage: ${instance.input.name} ${command.name}${ - optionsOutput ? ' [options]' : '' + optionsOutput ? " [options]" : "" } ${ command.description && diff --git a/cli/parse-args.js b/cli/parse-args.js index 4f961d6f..b99f14fc 100644 --- a/cli/parse-args.js +++ b/cli/parse-args.js @@ -1,18 +1,18 @@ const parseArgs = (args, type) => { if (args == null || !Array.isArray(args)) { - throw 'args should be array'; + throw "args should be array"; } const argsCopy = args.slice(); switch (type) { - case 'electron': { + case "electron": { if (process.defaultApp) { return argsCopy.slice(2); } return argsCopy.slice(1); } - case 'user': { + case "user": { return argsCopy; } default: { diff --git a/cli/process-option.js b/cli/process-option.js index 7a96d5f7..750ee67f 100644 --- a/cli/process-option.js +++ b/cli/process-option.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); const optionFormatters = { number: (str) => +str, @@ -13,16 +13,16 @@ const processFlags = (flags) => { let name = null; const keys = []; let value = null; - const isNoFlag = flags.includes('--no-'); + const isNoFlag = flags.includes("--no-"); - _.compact(_.split(flags, ' ').map((str) => str.replace(/,/g, ''))).forEach( + _.compact(_.split(flags, " ").map((str) => str.replace(/,/g, ""))).forEach( (str) => { - if (str.startsWith('-')) { + if (str.startsWith("-")) { keys.push(str); } else if (value === null) { - if (str.startsWith('{') || str.startsWith('[') || str.startsWith('<')) { - const rawValue = str.replace(/[{[<>}\].]/g, ''); - const variadic = str.includes('...'); + if (str.startsWith("{") || str.startsWith("[") || str.startsWith("<")) { + const rawValue = str.replace(/[{[<>}\].]/g, ""); + const variadic = str.includes("..."); value = { raw: str, variadic, @@ -38,9 +38,9 @@ const processFlags = (flags) => { if (!_.isEmpty(longestKey)) { name = _.camelCase( - (isNoFlag ? longestKey.replace('--no-', '') : longestKey).replace( + (isNoFlag ? longestKey.replace("--no-", "") : longestKey).replace( /(--?)/, - '', + "", ), ); } @@ -58,13 +58,13 @@ const processOption = (option) => { const processedFlags = processFlags(option.flags); if (!processedFlags.name) { - console.warn('invalid option', option); + console.warn("invalid option", option); return null; } return { required: !!option.required, - description: `${option.description || ''}`, + description: `${option.description || ""}`, default: option.default, flags: processedFlags, operation: option.operation, diff --git a/index.d.ts b/index.d.ts index 9f063a38..ed8b5164 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import {MonoSchemaParser} from "./src/schema-parser/mono-schema-parser"; +import type { MonoSchemaParser } from "./src/schema-parser/mono-schema-parser"; type HttpClientType = "axios" | "fetch"; @@ -145,7 +145,9 @@ interface GenerateApiParamsBase { */ addReadonly?: boolean; - primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial; + primitiveTypeConstructs?: ( + struct: PrimitiveTypeStruct, + ) => Partial; codeGenConstructs?: (struct: CodeGenConstruct) => Partial; @@ -213,17 +215,17 @@ interface GenerateApiParamsBase { /** fallback name for specific arg name resolver */ specificArgNameResolverName?: string; schemaParsers?: { - complexOneOf?:MonoSchemaParser; - complexAllOf?:MonoSchemaParser; - complexAnyOf?:MonoSchemaParser; - complexNot?:MonoSchemaParser; - enum?:MonoSchemaParser; - object?:MonoSchemaParser; - complex?:MonoSchemaParser; - primitive?:MonoSchemaParser; - discriminator?:MonoSchemaParser; + complexOneOf?: MonoSchemaParser; + complexAllOf?: MonoSchemaParser; + complexAnyOf?: MonoSchemaParser; + complexNot?: MonoSchemaParser; + enum?: MonoSchemaParser; + object?: MonoSchemaParser; + complex?: MonoSchemaParser; + primitive?: MonoSchemaParser; + discriminator?: MonoSchemaParser; array?: MonoSchemaParser; - } + }; } type CodeGenConstruct = { @@ -270,11 +272,18 @@ type CodeGenConstruct = { type PrimitiveTypeStructValue = | string - | ((schema: Record, parser: import("./src/schema-parser/schema-parser").SchemaParser) => string); + | (( + schema: Record, + parser: import("./src/schema-parser/schema-parser").SchemaParser, + ) => string); type PrimitiveTypeStruct = Record< "integer" | "number" | "boolean" | "object" | "file" | "string" | "array", - string | ({ $default: PrimitiveTypeStructValue } & Record) + | string + | ({ $default: PrimitiveTypeStructValue } & Record< + string, + PrimitiveTypeStructValue + >) >; interface GenerateApiParamsFromPath extends GenerateApiParamsBase { @@ -298,7 +307,10 @@ interface GenerateApiParamsFromSpecLiteral extends GenerateApiParamsBase { spec: import("swagger-schema-official").Spec; } -export type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral; +export type GenerateApiParams = + | GenerateApiParamsFromPath + | GenerateApiParamsFromUrl + | GenerateApiParamsFromSpecLiteral; type BuildRouteParam = { /** {bar} */ @@ -328,11 +340,20 @@ export interface Hooks { /** calls after parse\process route path */ onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void; /** calls before insert path param name into string path interpolation */ - onInsertPathParam: (paramName: string, index: number, arr: BuildRouteParam[], resultRoute: string) => string | void; + onInsertPathParam: ( + paramName: string, + index: number, + arr: BuildRouteParam[], + resultRoute: string, + ) => string | void; /** calls after parse schema component */ onCreateComponent: (component: SchemaComponent) => SchemaComponent | void; /** calls before parse any kind of schema */ - onPreParseSchema: (originalSchema: any, typeName: string, schemaType: string) => any; + onPreParseSchema: ( + originalSchema: any, + typeName: string, + schemaType: string, + ) => any; /** calls after parse any kind of schema */ onParseSchema: (originalSchema: any, parsedSchema: any) => any | void; /** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */ @@ -343,18 +364,32 @@ export interface Hooks { codeGenProcess: import("./src/code-gen-process").CodeGenProcess, ) => C | void; /** customize configuration object before sending it to ETA templates */ - onPrepareConfig?: (currentConfiguration: C) => C | void; + onPrepareConfig?: ( + currentConfiguration: C, + ) => C | void; /** customize route name as you need */ - onCreateRouteName?: (routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo) => RouteNameInfo | void; + onCreateRouteName?: ( + routeNameInfo: RouteNameInfo, + rawRouteInfo: RawRouteInfo, + ) => RouteNameInfo | void; /** customize request params (path params, query params) */ - onCreateRequestParams?: (rawType: SchemaComponent["rawTypeData"]) => SchemaComponent["rawTypeData"] | void; + onCreateRequestParams?: ( + rawType: SchemaComponent["rawTypeData"], + ) => SchemaComponent["rawTypeData"] | void; /** customize name of model type */ - onFormatTypeName?: (typeName: string, rawTypeName?: string, schemaType?: "type-name" | "enum-key") => string | void; + onFormatTypeName?: ( + typeName: string, + rawTypeName?: string, + schemaType?: "type-name" | "enum-key", + ) => string | void; /** customize name of route (operationId), you can do it with using onCreateRouteName too */ - onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | void; + onFormatRouteName?: ( + routeInfo: RawRouteInfo, + templateRouteName: string, + ) => string | void; } -export interface RouteNameRouteInfo {} +export type RouteNameRouteInfo = {}; export type RouteNameInfo = { usage: string; @@ -424,10 +459,16 @@ export interface SchemaComponent { discriminator?: { propertyName?: string; }; - $parsed: ParsedSchema; + $parsed: ParsedSchema< + | SchemaTypeObjectContent + | SchemaTypeEnumContent + | SchemaTypePrimitiveContent + >; }; componentName: "schemas" | "paths"; - typeData: ParsedSchema | null; + typeData: ParsedSchema< + SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent + > | null; } export enum RequestContentKind { @@ -495,7 +536,10 @@ export enum SCHEMA_TYPES { COMPLEX_UNKNOWN = "__unknown", } -type MAIN_SCHEMA_TYPES = SCHEMA_TYPES.PRIMITIVE | SCHEMA_TYPES.OBJECT | SCHEMA_TYPES.ENUM; +type MAIN_SCHEMA_TYPES = + | SCHEMA_TYPES.PRIMITIVE + | SCHEMA_TYPES.OBJECT + | SCHEMA_TYPES.ENUM; type ExtractingOptions = { requestBodySuffix: string[]; @@ -505,13 +549,31 @@ type ExtractingOptions = { enumSuffix: string[]; discriminatorMappingSuffix: string[]; discriminatorAbstractPrefix: string[]; - requestBodyNameResolver: (name: string, reservedNames: string) => string | undefined; - responseBodyNameResolver: (name: string, reservedNames: string) => string | undefined; - responseErrorNameResolver: (name: string, reservedNames: string) => string | undefined; - requestParamsNameResolver: (name: string, reservedNames: string) => string | undefined; + requestBodyNameResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; + responseBodyNameResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; + responseErrorNameResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; + requestParamsNameResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; enumNameResolver: (name: string, reservedNames: string) => string | undefined; - discriminatorMappingNameResolver: (name: string, reservedNames: string) => string | undefined; - discriminatorAbstractResolver: (name: string, reservedNames: string) => string | undefined; + discriminatorMappingNameResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; + discriminatorAbstractResolver: ( + name: string, + reservedNames: string, + ) => string | undefined; }; export interface GenerateApiConfiguration { @@ -588,7 +650,9 @@ export interface GenerateApiConfiguration { typeNameResolverName: string; specificArgNameResolverName: string; /** do not use constructor args, it can break functionality of this property, just send class reference */ - customTranslator?: new (...args: never[]) => typeof import("./src/translators/translator").Translator; + customTranslator?: new ( + ...args: never[] + ) => typeof import("./src/translators/translator").Translator; internalTemplateOptions: { addUtilRequiredKeysType: boolean; }; @@ -635,16 +699,28 @@ export interface GenerateApiConfiguration { /** @deprecated */ classNameCase: (value: string) => string; pascalCase: (value: string) => string; - getInlineParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => string; - getParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => ModelType; + getInlineParseContent: ( + rawTypeData: SchemaComponent["rawTypeData"], + typeName?: string, + ) => string; + getParseContent: ( + rawTypeData: SchemaComponent["rawTypeData"], + typeName?: string, + ) => ModelType; getComponentByRef: (ref: string) => SchemaComponent; parseSchema: ( rawSchema: string | SchemaComponent["rawTypeData"], typeName?: string, formattersMap?: Record string>, ) => ModelType; - formatters: Record string>; - inlineExtraFormatters: Record, (schema: ModelType) => string>; + formatters: Record< + MAIN_SCHEMA_TYPES, + (content: string | object | string[] | object[]) => string + >; + inlineExtraFormatters: Record< + Exclude, + (schema: ModelType) => string + >; formatModelName: (name: string) => string; fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string; _: import("lodash").LoDashStatic; @@ -664,17 +740,28 @@ type FileInfo = { export interface GenerateApiOutput { configuration: GenerateApiConfiguration; files: FileInfo[]; - createFile: (params: { path: string; fileName: string; content: string; withPrefix?: boolean }) => void; + createFile: (params: { + path: string; + fileName: string; + content: string; + withPrefix?: boolean; + }) => void; renderTemplate: ( templateContent: string, data: Record, etaOptions?: import("eta/dist/types/config").PartialConfig, ) => string; - getTemplate: (params: { fileName?: string; name?: string; path?: string }) => string; + getTemplate: (params: { + fileName?: string; + name?: string; + path?: string; + }) => string; formatTSContent: (content: string) => Promise; } -export declare function generateApi(params: GenerateApiParams): Promise; +export declare function generateApi( + params: GenerateApiParams, +): Promise; export interface GenerateTemplatesParams { cleanOutput?: boolean; @@ -684,6 +771,9 @@ export interface GenerateTemplatesParams { silent?: boolean; } -export interface GenerateTemplatesOutput extends Pick {} +export interface GenerateTemplatesOutput + extends Pick {} -export declare function generateTemplates(params: GenerateTemplatesParams): Promise; +export declare function generateTemplates( + params: GenerateTemplatesParams, +): Promise; diff --git a/index.js b/index.js index 9302d910..042182ff 100755 --- a/index.js +++ b/index.js @@ -6,294 +6,294 @@ // License text available at https://opensource.org/licenses/MIT // Repository https://github.com/acacode/swagger-typescript-api -const { version, name } = require('./package.json'); -const { cli } = require('./cli'); -const { generateApi, generateTemplates } = require('./src'); -const { HTTP_CLIENT } = require('./src/constants'); -const { resolve } = require('path'); -const { CodeGenConfig } = require('./src/configuration'); +const { version, name } = require("./package.json"); +const { cli } = require("./cli"); +const { generateApi, generateTemplates } = require("./src"); +const { HTTP_CLIENT } = require("./src/constants"); +const { resolve } = require("node:path"); +const { CodeGenConfig } = require("./src/configuration"); const { TemplatesGenConfig, -} = require('./src/commands/generate-templates/configuration'); +} = require("./src/commands/generate-templates/configuration"); const codeGenBaseConfig = new CodeGenConfig({}); const templateGenBaseConfig = new TemplatesGenConfig({}); const program = cli({ name: name, - alias: 'sta', + alias: "sta", version: version, description: - 'Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.', + "Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.", options: [ { - flags: '-p, --path ', - description: 'path/url to swagger scheme', + flags: "-p, --path ", + description: "path/url to swagger scheme", required: true, }, { - flags: '-o, --output ', - description: 'output path of typescript api file', - default: './', + flags: "-o, --output ", + description: "output path of typescript api file", + default: "./", }, { - flags: '-n, --name ', - description: 'name of output typescript api file', + flags: "-n, --name ", + description: "name of output typescript api file", default: codeGenBaseConfig.fileName, }, { - flags: '-t, --templates ', - description: 'path to folder containing templates', + flags: "-t, --templates ", + description: "path to folder containing templates", }, { - flags: '-d, --default-as-success', + flags: "-d, --default-as-success", description: 'use "default" response status code as success response too.\n' + 'some swagger schemas use "default" response status code as success response type by default.', default: codeGenBaseConfig.defaultResponseAsSuccess, - internal: { name: 'defaultResponseAsSuccess' }, + internal: { name: "defaultResponseAsSuccess" }, }, { - flags: '-r, --responses', + flags: "-r, --responses", description: - 'generate additional information about request responses\n' + - 'also add typings for bad responses', + "generate additional information about request responses\n" + + "also add typings for bad responses", default: codeGenBaseConfig.generateResponses, - internal: { name: 'generateResponses' }, + internal: { name: "generateResponses" }, }, { - flags: '--union-enums', + flags: "--union-enums", description: 'generate all "enum" types as union types (T1 | T2 | TN)', default: codeGenBaseConfig.generateUnionEnums, - internal: { name: 'generateUnionEnums' }, + internal: { name: "generateUnionEnums" }, }, { - flags: '--add-readonly', - description: 'generate readonly properties', + flags: "--add-readonly", + description: "generate readonly properties", default: codeGenBaseConfig.addReadonly, }, { - flags: '--route-types', - description: 'generate type definitions for API routes', + flags: "--route-types", + description: "generate type definitions for API routes", default: codeGenBaseConfig.generateRouteTypes, - internal: { name: 'generateRouteTypes' }, + internal: { name: "generateRouteTypes" }, }, { - flags: '--no-client', - description: 'do not generate an API class', + flags: "--no-client", + description: "do not generate an API class", default: codeGenBaseConfig.generateClient, }, { - flags: '--enum-names-as-values', + flags: "--enum-names-as-values", description: "use values in 'x-enumNames' as enum values (not only as keys)", default: codeGenBaseConfig.enumNamesAsValues, }, { - flags: '--extract-request-params', + flags: "--extract-request-params", description: - 'extract request params to data contract (Also combine path params and query params into one object)', + "extract request params to data contract (Also combine path params and query params into one object)", default: codeGenBaseConfig.extractRequestParams, internal: { formatter: Boolean }, }, { - flags: '--extract-request-body', - description: 'extract request body type to data contract', + flags: "--extract-request-body", + description: "extract request body type to data contract", default: codeGenBaseConfig.extractRequestBody, internal: { formatter: Boolean }, }, { - flags: '--extract-response-body', - description: 'extract response body type to data contract', + flags: "--extract-response-body", + description: "extract response body type to data contract", default: codeGenBaseConfig.extractResponseBody, internal: { formatter: Boolean }, }, { - flags: '--extract-response-error', - description: 'extract response error type to data contract', + flags: "--extract-response-error", + description: "extract response error type to data contract", default: codeGenBaseConfig.extractResponseError, internal: { formatter: Boolean }, }, { - flags: '--extract-responses', - description: 'extract all responses described in /components/responses', + flags: "--extract-responses", + description: "extract all responses described in /components/responses", default: codeGenBaseConfig.extractResponses, internal: { formatter: Boolean }, }, { - flags: '--modular', + flags: "--modular", description: - 'generate separated files for http client, data contracts, and routes', + "generate separated files for http client, data contracts, and routes", default: codeGenBaseConfig.modular, internal: { formatter: Boolean }, }, { - flags: '--js', - description: 'generate js api module with declaration file', + flags: "--js", + description: "generate js api module with declaration file", default: codeGenBaseConfig.toJS, - internal: { formatter: Boolean, name: 'toJS' }, + internal: { formatter: Boolean, name: "toJS" }, }, { - flags: '--module-name-index ', + flags: "--module-name-index ", description: - 'determines which path index should be used for routes separation (example: GET:/fruites/getFruit -> index:0 -> moduleName -> fruites)', + "determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)", default: codeGenBaseConfig.moduleNameIndex, internal: { formatter: (moduleNameIndex) => +moduleNameIndex || 0 }, }, { - flags: '--module-name-first-tag', - description: 'splits routes based on the first tag', + flags: "--module-name-first-tag", + description: "splits routes based on the first tag", default: codeGenBaseConfig.moduleNameFirstTag, }, { - flags: '--disableStrictSSL', - description: 'disabled strict SSL', + flags: "--disableStrictSSL", + description: "disabled strict SSL", default: codeGenBaseConfig.disableStrictSSL, internal: { formatter: Boolean }, }, { - flags: '--disableProxy', - description: 'disabled proxy', + flags: "--disableProxy", + description: "disabled proxy", default: codeGenBaseConfig.disableProxy, internal: { formatter: Boolean }, }, { - flags: '--axios', - description: 'generate axios http client', + flags: "--axios", + description: "generate axios http client", default: codeGenBaseConfig.httpClientType === HTTP_CLIENT.AXIOS, }, { - flags: '--unwrap-response-data', - description: 'unwrap the data item from the response', + flags: "--unwrap-response-data", + description: "unwrap the data item from the response", default: codeGenBaseConfig.unwrapResponseData, }, { - flags: '--disable-throw-on-error', - description: 'Do not throw an error when response.ok is not true', + flags: "--disable-throw-on-error", + description: "Do not throw an error when response.ok is not true", default: codeGenBaseConfig.disableThrowOnError, }, { - flags: '--single-http-client', - description: 'Ability to send HttpClient instance to Api constructor', + flags: "--single-http-client", + description: "Ability to send HttpClient instance to Api constructor", default: codeGenBaseConfig.singleHttpClient, internal: { formatter: Boolean }, }, { - flags: '--silent', - description: 'Output only errors to console', + flags: "--silent", + description: "Output only errors to console", default: codeGenBaseConfig.silent, internal: { formatter: Boolean }, }, { - flags: '--default-response ', - description: 'default type for empty response schema', + flags: "--default-response ", + description: "default type for empty response schema", default: codeGenBaseConfig.defaultResponseType, - internal: { name: 'defaultResponseType' }, + internal: { name: "defaultResponseType" }, }, { - flags: '--type-prefix ', - description: 'data contract name prefix', + flags: "--type-prefix ", + description: "data contract name prefix", default: codeGenBaseConfig.typePrefix, }, { - flags: '--type-suffix ', - description: 'data contract name suffix', + flags: "--type-suffix ", + description: "data contract name suffix", default: codeGenBaseConfig.typeSuffix, }, { - flags: '--clean-output', + flags: "--clean-output", description: - 'clean output folder before generate api. WARNING: May cause data loss', + "clean output folder before generate api. WARNING: May cause data loss", default: codeGenBaseConfig.cleanOutput, internal: { formatter: Boolean }, }, { - flags: '--api-class-name ', - description: 'name of the api class', + flags: "--api-class-name ", + description: "name of the api class", default: codeGenBaseConfig.apiClassName, }, { - flags: '--patch', - description: 'fix up small errors in the swagger source definition', + flags: "--patch", + description: "fix up small errors in the swagger source definition", default: codeGenBaseConfig.patch, internal: { formatter: Boolean }, }, { - flags: '--debug', - description: 'additional information about processes inside this tool', + flags: "--debug", + description: "additional information about processes inside this tool", default: codeGenBaseConfig.debug, }, { - flags: '--another-array-type', - description: 'generate array types as Array (by default Type[])', + flags: "--another-array-type", + description: "generate array types as Array (by default Type[])", default: codeGenBaseConfig.anotherArrayType, }, { - flags: '--sort-types', - description: 'sort fields and types', + flags: "--sort-types", + description: "sort fields and types", default: codeGenBaseConfig.sortTypes, }, { - flags: '--extract-enums', + flags: "--extract-enums", description: - 'extract all enums from inline interface\\type content to typescript enum construction', + "extract all enums from inline interface\\type content to typescript enum construction", default: codeGenBaseConfig.extractEnums, }, { - flags: '--sort-routes', - description: 'sort routes in alphabetical order', + flags: "--sort-routes", + description: "sort routes in alphabetical order", default: codeGenBaseConfig.sortRoutes, }, { - flags: '--custom-config ', - description: 'custom config: primitiveTypeConstructs, hooks, ... ', - default: '', + flags: "--custom-config ", + description: "custom config: primitiveTypeConstructs, hooks, ... ", + default: "", }, ], }); program.addCommand({ - name: 'generate-templates', + name: "generate-templates", description: `Generate ".ejs" templates needed for generate api`, options: [ { - flags: '-o, --output ', - description: 'output path of generated templates', + flags: "-o, --output ", + description: "output path of generated templates", default: templateGenBaseConfig.output, }, { - flags: '-m, --modular', + flags: "-m, --modular", description: - 'generate templates needed to separate files for http client, data contracts, and routes', + "generate templates needed to separate files for http client, data contracts, and routes", default: templateGenBaseConfig.modular, internal: { formatter: Boolean }, }, { - flags: '--http-client ', + flags: "--http-client ", description: `http client type (possible values: ${Object.values( HTTP_CLIENT, ) .map((v) => `"${v}"`) - .join(', ')})`, + .join(", ")})`, default: templateGenBaseConfig.httpClientType, - internal: { name: 'httpClientType' }, + internal: { name: "httpClientType" }, }, { - flags: '-c, --clean-output', + flags: "-c, --clean-output", description: - 'clean output folder before generate template. WARNING: May cause data loss', + "clean output folder before generate template. WARNING: May cause data loss", default: templateGenBaseConfig.cleanOutput, internal: { formatter: Boolean }, }, { - flags: '-r, --rewrite', - description: 'rewrite content in existing templates', + flags: "-r, --rewrite", + description: "rewrite content in existing templates", default: templateGenBaseConfig.rewrite, internal: { formatter: Boolean }, }, { - flags: '--silent', - description: 'Output only errors to console', + flags: "--silent", + description: "Output only errors to console", default: templateGenBaseConfig.silent, internal: { formatter: Boolean }, }, @@ -326,12 +326,12 @@ const main = async () => { generateClient: !!(options.axios || options.client), httpClientType: options.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH, input: resolve(process.cwd(), options.path), - output: resolve(process.cwd(), options.output || '.'), + output: resolve(process.cwd(), options.output || "."), ...customConfig, }); break; } - case 'generate-templates': { + case "generate-templates": { await generateTemplates(options); break; } @@ -342,7 +342,6 @@ const main = async () => { } catch (e) { console.error(e); process.exit(1); - return; } process.exit(0); }; diff --git a/package.json b/package.json index 3b988bd7..6f469a94 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "cli:help": "node index.js -h", "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts", "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts", - "contributors": "all-contributors generate", "generate": "node tests/generate.js", "generate-extended": "node tests/generate-extended.js", "node": "node swagger-test-cli/generate.js", @@ -122,7 +121,6 @@ "@types/lodash": "^4.14.195", "@types/node": "^20.4.1", "@types/prettier": "^2.7.3", - "all-contributors-cli": "^6.26.1", "axios": "^1.4.0", "cross-env": "^7.0.3", "dotenv": "^16.3.1", diff --git a/scripts_runner.js b/scripts_runner.js index b9bd3b9b..22ec34e1 100644 --- a/scripts_runner.js +++ b/scripts_runner.js @@ -1,5 +1,5 @@ -const packageJson = require('./package.json'); -const { spawn } = require('child_process'); +const packageJson = require("./package.json"); +const { spawn } = require("node:child_process"); const commands = process.argv.slice(2); @@ -8,25 +8,25 @@ const packageScripts = Object.keys(packageJson.scripts); const execute = (scriptName) => new Promise((resolve, reject) => { console.log(`yarn ${scriptName}`); - const spawned = spawn('yarn', [scriptName]); + const spawned = spawn("yarn", [scriptName]); - spawned.stdout.on('data', (data) => { + spawned.stdout.on("data", (data) => { process.stdout.write(data); }); - spawned.stderr.on('data', (data) => { + spawned.stderr.on("data", (data) => { process.stderr.write(data); }); - spawned.on('error', (error) => { + spawned.on("error", (error) => { console.error(error); }); - spawned.on('message', (message) => { + spawned.on("message", (message) => { console.log(message); }); - spawned.on('close', (code) => { + spawned.on("close", (code) => { if (code) { reject(code); } else { @@ -43,8 +43,8 @@ const run = async () => { await execute(scriptName); } - if (command.includes('*')) { - const commandPart = command.replace('*', ''); + if (command.includes("*")) { + const commandPart = command.replace("*", ""); // TODO: refactor if ( scriptName.startsWith(commandPart) || diff --git a/src/code-formatter.js b/src/code-formatter.js index a9bfa88e..90141fba 100644 --- a/src/code-formatter.js +++ b/src/code-formatter.js @@ -1,6 +1,6 @@ -const _ = require('lodash'); -const ts = require('typescript'); -const prettier = require('prettier'); +const _ = require("lodash"); +const ts = require("typescript"); +const prettier = require("prettier"); class CodeFormatter { /** @@ -13,13 +13,13 @@ class CodeFormatter { } removeUnusedImports = (content) => { - const tempFileName = 'file.ts'; + const tempFileName = "file.ts"; const host = new TsLanguageServiceHost(tempFileName, content); const languageService = ts.createLanguageService(host); const fileTextChanges = languageService.organizeImports( - { type: 'file', fileName: tempFileName }, + { type: "file", fileName: tempFileName }, { newLineCharacter: ts.sys.newLine }, )[0]; @@ -79,7 +79,7 @@ class TsLanguageServiceHost { } getNewLine() { - return 'newLine' in ts.sys ? ts.sys.newLine : '\n'; + return "newLine" in ts.sys ? ts.sys.newLine : "\n"; } getScriptFileNames() { return [this.fileName]; diff --git a/src/code-gen-process.js b/src/code-gen-process.js index 22d12b49..0c352497 100644 --- a/src/code-gen-process.js +++ b/src/code-gen-process.js @@ -1,32 +1,32 @@ -const { SwaggerSchemaResolver } = require('./swagger-schema-resolver.js'); -const { SchemaComponentsMap } = require('./schema-components-map.js'); -const { NameResolver } = require('./util/name-resolver'); -const { Logger } = require('./util/logger.js'); -const { TypeNameFormatter } = require('./type-name-formatter.js'); -const _ = require('lodash'); -const { SchemaParserFabric } = require('./schema-parser/schema-parser-fabric'); -const { SchemaRoutes } = require('./schema-routes/schema-routes.js'); -const { CodeGenConfig } = require('./configuration.js'); -const { SchemaWalker } = require('./schema-walker'); -const { FileSystem } = require('./util/file-system'); -const { TemplatesWorker } = require('./templates-worker'); -const { JavascriptTranslator } = require('./translators/javascript'); -const ts = require('typescript'); -const { CodeFormatter } = require('./code-formatter'); -const { pascalCase } = require('./util/pascal-case'); -const { internalCase } = require('./util/internal-case'); -const { sortByProperty } = require('./util/sort-by-property'); +const { SwaggerSchemaResolver } = require("./swagger-schema-resolver.js"); +const { SchemaComponentsMap } = require("./schema-components-map.js"); +const { NameResolver } = require("./util/name-resolver"); +const { Logger } = require("./util/logger.js"); +const { TypeNameFormatter } = require("./type-name-formatter.js"); +const _ = require("lodash"); +const { SchemaParserFabric } = require("./schema-parser/schema-parser-fabric"); +const { SchemaRoutes } = require("./schema-routes/schema-routes.js"); +const { CodeGenConfig } = require("./configuration.js"); +const { SchemaWalker } = require("./schema-walker"); +const { FileSystem } = require("./util/file-system"); +const { TemplatesWorker } = require("./templates-worker"); +const { JavascriptTranslator } = require("./translators/javascript"); +const ts = require("typescript"); +const { CodeFormatter } = require("./code-formatter"); +const { pascalCase } = require("./util/pascal-case"); +const { internalCase } = require("./util/internal-case"); +const { sortByProperty } = require("./util/sort-by-property"); const PATCHABLE_INSTANCES = [ - 'schemaWalker', - 'swaggerSchemaResolver', - 'schemaComponentsMap', - 'typeNameFormatter', - 'templatesWorker', - 'codeFormatter', - 'schemaParserFabric', - 'schemaRoutes', - 'javascriptTranslator', + "schemaWalker", + "swaggerSchemaResolver", + "schemaComponentsMap", + "typeNameFormatter", + "templatesWorker", + "codeFormatter", + "schemaParserFabric", + "schemaRoutes", + "javascriptTranslator", ]; class CodeGenProcess { @@ -92,10 +92,10 @@ class CodeGenProcess { originalSchema: swagger.originalSchema, }); - this.schemaWalker.addSchema('$usage', swagger.usageSchema); - this.schemaWalker.addSchema('$original', swagger.originalSchema); + this.schemaWalker.addSchema("$usage", swagger.usageSchema); + this.schemaWalker.addSchema("$original", swagger.originalSchema); - this.logger.event('start generating your typescript api'); + this.logger.event("start generating your typescript api"); this.config.update( this.config.hooks.onInit(this.config, this) || this.config, @@ -107,7 +107,7 @@ class CodeGenProcess { _.each(component, (rawTypeData, typeName) => { this.schemaComponentsMap.createComponent( this.schemaComponentsMap.createRef([ - 'components', + "components", componentName, typeName, ]), @@ -120,7 +120,7 @@ class CodeGenProcess { * @type {SchemaComponent[]} */ const componentsToParse = this.schemaComponentsMap.filter( - _.compact(['schemas', this.config.extractResponses && 'responses']), + _.compact(["schemas", this.config.extractResponses && "responses"]), ); const parsedSchemas = componentsToParse.map((schemaComponent) => { @@ -186,7 +186,7 @@ class CodeGenProcess { }); this.logger.success( - `api file`, + "api file", `"${file.fileName}${file.fileExtension}"`, `created in ${this.config.output}`, ); @@ -225,7 +225,7 @@ class CodeGenProcess { formatters: this.schemaParserFabric.schemaFormatters.base, formatModelName: this.typeNameFormatter.format, fmtToJSDocLine: function fmtToJSDocLine(line, { eol = true }) { - return ` * ${line}${eol ? '\n' : ''}`; + return ` * ${line}${eol ? "\n" : ""}`; }, NameResolver: NameResolver, _, @@ -240,8 +240,8 @@ class CodeGenProcess { let modelTypes = []; const modelTypeComponents = _.compact([ - 'schemas', - this.config.extractResponses && 'responses', + "schemas", + this.config.extractResponses && "responses", ]); const getSchemaComponentsCount = () => @@ -266,7 +266,7 @@ class CodeGenProcess { } if (this.config.sortTypes) { - return modelTypes.sort(sortByProperty('name')); + return modelTypes.sort(sortByProperty("name")); } return modelTypes; @@ -487,7 +487,7 @@ class CodeGenProcess { templatesToRender.api, configuration, ), - ]).join('\n'), + ]).join("\n"), ); }; @@ -503,7 +503,7 @@ class CodeGenProcess { const fileExtension = ts.Extension.Ts; if (configuration.translateToJavaScript) { - this.logger.debug('using js translator for', fileName); + this.logger.debug("using js translator for", fileName); return await this.javascriptTranslator.translate({ fileName: fileName, fileExtension: fileExtension, @@ -512,7 +512,7 @@ class CodeGenProcess { } if (configuration.customTranslator) { - this.logger.debug('using custom translator for', fileName); + this.logger.debug("using custom translator for", fileName); return await configuration.customTranslator.translate({ fileName: fileName, fileExtension: fileExtension, @@ -520,7 +520,7 @@ class CodeGenProcess { }); } - this.logger.debug('generating output for', `${fileName}${fileExtension}`); + this.logger.debug("generating output for", `${fileName}${fileExtension}`); return [ { @@ -533,8 +533,8 @@ class CodeGenProcess { createApiConfig = (swaggerSchema) => { const { info, servers, host, basePath, externalDocs, tags } = swaggerSchema; - const server = (servers && servers[0]) || { url: '' }; - const { title = 'No title', version } = info || {}; + const server = (servers && servers[0]) || { url: "" }; + const { title = "No title", version } = info || {}; const { url: serverUrl } = server; return { @@ -544,8 +544,8 @@ class CodeGenProcess { host, externalDocs: _.merge( { - url: '', - description: '', + url: "", + description: "", }, externalDocs, ), diff --git a/src/commands/generate-templates/configuration.js b/src/commands/generate-templates/configuration.js index e9aaabc0..dd1529c2 100644 --- a/src/commands/generate-templates/configuration.js +++ b/src/commands/generate-templates/configuration.js @@ -1,5 +1,5 @@ -const { objectAssign } = require('../../util/object-assign'); -const { HTTP_CLIENT, PROJECT_VERSION } = require('../../constants'); +const { objectAssign } = require("../../util/object-assign"); +const { HTTP_CLIENT, PROJECT_VERSION } = require("../../constants"); /** * @type {GenerateTemplatesParams}} diff --git a/src/commands/generate-templates/index.js b/src/commands/generate-templates/index.js index 2abc69cf..d32283b1 100644 --- a/src/commands/generate-templates/index.js +++ b/src/commands/generate-templates/index.js @@ -6,7 +6,7 @@ // License text available at https://opensource.org/licenses/MIT // Repository https://github.com/acacode/swagger-typescript-api -const { TemplatesGenProcess } = require('./templates-gen-process'); +const { TemplatesGenProcess } = require("./templates-gen-process"); module.exports = { generateTemplates: async (config) => { diff --git a/src/commands/generate-templates/templates-gen-process.js b/src/commands/generate-templates/templates-gen-process.js index 186e1420..15ba87f3 100644 --- a/src/commands/generate-templates/templates-gen-process.js +++ b/src/commands/generate-templates/templates-gen-process.js @@ -1,7 +1,7 @@ -const { TemplatesGenConfig } = require('./configuration'); -const { FileSystem } = require('../../util/file-system'); -const { Logger } = require('../../util/logger'); -const path = require('path'); +const { TemplatesGenConfig } = require("./configuration"); +const { FileSystem } = require("../../util/file-system"); +const { Logger } = require("../../util/logger"); +const path = require("node:path"); class TemplatesGenProcess { /** @@ -17,16 +17,16 @@ class TemplatesGenProcess { */ logger; - rootDir = path.resolve(__dirname, '../../../'); + rootDir = path.resolve(__dirname, "../../../"); paths = { - baseTemplates: 'templates/base', - httpClientTemplates: 'templates/base/http-clients', - moduleApiTemplates: 'templates/modular', - defaultApiTemplates: 'templates/default', + baseTemplates: "templates/base", + httpClientTemplates: "templates/base/http-clients", + moduleApiTemplates: "templates/modular", + defaultApiTemplates: "templates/default", }; - importTemplatePrefixes = ['@base', '@modular', '@default']; + importTemplatePrefixes = ["@base", "@modular", "@default"]; constructor(config) { this.config = new TemplatesGenConfig(config); @@ -45,7 +45,7 @@ class TemplatesGenProcess { const templates = this.getTemplates(); if (this.config.output) { - this.logger.log('preparing output directory for source templates'); + this.logger.log("preparing output directory for source templates"); const outputPath = path.resolve(process.cwd(), this.config.output); if (this.fileSystem.pathIsExist(outputPath)) { @@ -122,7 +122,7 @@ class TemplatesGenProcess { template.startsWith(`${this.config.httpClientType}-`), ); - let httpClientTemplateContent = ''; + let httpClientTemplateContent = ""; if (usingHttpClientTemplate) { httpClientTemplateContent = this.fixTemplateContent( @@ -134,7 +134,7 @@ class TemplatesGenProcess { for (const fileName of baseTemplates) { const templateContent = - (fileName === 'http-client.ejs' && httpClientTemplateContent) || + (fileName === "http-client.ejs" && httpClientTemplateContent) || this.fixTemplateContent( this.getTemplateContent(`${this.paths.baseTemplates}/${fileName}`), ); @@ -162,34 +162,34 @@ class TemplatesGenProcess { const importsRegExp1 = new RegExp( `includeFile\\("(${this.importTemplatePrefixes .map((v) => `(${v})`) - .join('|')})/`, - 'g', + .join("|")})/`, + "g", ); // includeFile(`@base/ const importsRegExp2 = new RegExp( `includeFile\\(\`(${this.importTemplatePrefixes .map((v) => `(${v})`) - .join('|')})/`, - 'g', + .join("|")})/`, + "g", ); // includeFile('@base/ const importsRegExp3 = new RegExp( `includeFile\\('(${this.importTemplatePrefixes .map((v) => `(${v})`) - .join('|')})/`, - 'g', + .join("|")})/`, + "g", ); return content .replace(importsRegExp1, 'includeFile("./') - .replace(importsRegExp2, 'includeFile(`./') + .replace(importsRegExp2, "includeFile(`./") .replace(importsRegExp3, "includeFile('./"); }; getTemplateNamesFromDir = (dir) => { return this.fileSystem .readDir(path.resolve(this.rootDir, dir)) - .filter((file) => file.endsWith('.ejs')); + .filter((file) => file.endsWith(".ejs")); }; getTemplateContent = (pathToFile) => { diff --git a/src/component-type-name-resolver.js b/src/component-type-name-resolver.js index 1d64b885..63dde60d 100644 --- a/src/component-type-name-resolver.js +++ b/src/component-type-name-resolver.js @@ -1,5 +1,5 @@ -const { getRandomInt } = require('./util/random'); -const { NameResolver } = require('./util/name-resolver'); +const { getRandomInt } = require("./util/random"); +const { NameResolver } = require("./util/name-resolver"); class ComponentTypeNameResolver extends NameResolver { counter = 1; @@ -22,7 +22,7 @@ class ComponentTypeNameResolver extends NameResolver { this.countersByVariant.set(randomVariant, variantCounter); const dirtyResolvedName = `${randomVariant}${variantCounter}`; this.logger.debug( - 'generated dirty resolved type name for component - ', + "generated dirty resolved type name for component - ", dirtyResolvedName, ); return dirtyResolvedName; @@ -31,7 +31,7 @@ class ComponentTypeNameResolver extends NameResolver { const fallbackName = `${this.config.componentTypeNameResolver}${this .fallbackNameCounter++}`; this.logger.debug( - 'generated fallback type name for component - ', + "generated fallback type name for component - ", fallbackName, ); return fallbackName; diff --git a/src/configuration.js b/src/configuration.js index 10e52905..5d238884 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -1,34 +1,34 @@ /* eslint-disable no-unused-vars */ -const { objectAssign } = require('./util/object-assign'); -const _ = require('lodash'); -const CONSTANTS = require('./constants'); -const { ComponentTypeNameResolver } = require('./component-type-name-resolver'); -const { cosmiconfigSync } = require('cosmiconfig'); -const ts = require('typescript'); +const { objectAssign } = require("./util/object-assign"); +const _ = require("lodash"); +const CONSTANTS = require("./constants"); +const { ComponentTypeNameResolver } = require("./component-type-name-resolver"); +const { cosmiconfigSync } = require("cosmiconfig"); +const ts = require("typescript"); const TsKeyword = { - Number: 'number', - String: 'string', - Boolean: 'boolean', - Any: 'any', - Void: 'void', - Unknown: 'unknown', - Null: 'null', - Undefined: 'undefined', - Object: 'object', - File: 'File', - Date: 'Date', - Type: 'type', - Enum: 'enum', - Interface: 'interface', - Array: 'Array', - Record: 'Record', - Intersection: '&', - Union: '|', + Number: "number", + String: "string", + Boolean: "boolean", + Any: "any", + Void: "void", + Unknown: "unknown", + Null: "null", + Undefined: "undefined", + Object: "object", + File: "File", + Date: "Date", + Type: "type", + Enum: "enum", + Interface: "interface", + Array: "Array", + Record: "Record", + Intersection: "&", + Union: "|", }; const TsCodeGenKeyword = { - UtilRequiredKeys: 'UtilRequiredKeys', + UtilRequiredKeys: "UtilRequiredKeys", }; /** @@ -37,7 +37,7 @@ const TsCodeGenKeyword = { class CodeGenConfig { version = CONSTANTS.PROJECT_VERSION; /** CLI flag */ - templates = ''; + templates = ""; /** CLI flag */ generateResponses = false; /** CLI flag */ @@ -77,10 +77,10 @@ class CodeGenConfig { extractResponses = false; extractEnums = false; fileNames = { - dataContracts: 'data-contracts', - routeTypes: 'route-types', - httpClient: 'http-client', - outOfModuleApi: 'Common', + dataContracts: "data-contracts", + routeTypes: "route-types", + httpClient: "http-client", + outOfModuleApi: "Common", }; routeNameDuplicatesMap = new Map(); prettierOptions = { ...CONSTANTS.PRETTIER_OPTIONS }; @@ -108,28 +108,28 @@ class CodeGenConfig { sortRoutes = false; templatePaths = { /** `templates/base` */ - base: '', + base: "", /** `templates/default` */ - default: '', + default: "", /** `templates/modular` */ - modular: '', + modular: "", /** usage path if `--templates` option is not set */ - original: '', + original: "", /** custom path to templates (`--templates`) */ - custom: '', + custom: "", }; /** Record */ templatesToRender = { - api: '', - dataContracts: '', - dataContractJsDoc: '', - interfaceDataContract: '', - typeDataContract: '', - enumDataContract: '', - objectFieldJsDoc: '', - httpClient: '', - routeTypes: '', - routeName: '', + api: "", + dataContracts: "", + dataContractJsDoc: "", + interfaceDataContract: "", + typeDataContract: "", + enumDataContract: "", + objectFieldJsDoc: "", + httpClient: "", + routeTypes: "", + routeName: "", }; /** * @type {Record MonoSchemaParser>} @@ -137,68 +137,68 @@ class CodeGenConfig { schemaParsers = {}; toJS = false; silent = false; - typePrefix = ''; - typeSuffix = ''; - enumKeyPrefix = ''; - enumKeySuffix = ''; + typePrefix = ""; + typeSuffix = ""; + enumKeyPrefix = ""; + enumKeySuffix = ""; patch = false; /** @type {ComponentTypeNameResolver} */ componentTypeNameResolver; /** name of the main exported class */ - apiClassName = 'Api'; + apiClassName = "Api"; debug = false; anotherArrayType = false; internalTemplateOptions = { addUtilRequiredKeysType: false, }; extraTemplates = []; - input = ''; + input = ""; modular = false; - output = ''; - url = ''; + output = ""; + url = ""; cleanOutput = false; spec = null; - fileName = 'Api.ts'; + fileName = "Api.ts"; authorizationToken = void 0; requestOptions = null; jsPrimitiveTypes = []; jsEmptyTypes = []; - fixInvalidTypeNamePrefix = 'Type'; - fixInvalidEnumKeyPrefix = 'Value'; + fixInvalidTypeNamePrefix = "Type"; + fixInvalidEnumKeyPrefix = "Value"; - enumKeyResolverName = 'Value'; - typeNameResolverName = 'ComponentType'; - specificArgNameResolverName = 'arg'; + enumKeyResolverName = "Value"; + typeNameResolverName = "ComponentType"; + specificArgNameResolverName = "arg"; successResponseStatusRange = [200, 299]; /** @type {ExtractingOptions} */ extractingOptions = { - requestBodySuffix: ['Payload', 'Body', 'Input'], - requestParamsSuffix: ['Params'], - responseBodySuffix: ['Data', 'Result', 'Output'], + requestBodySuffix: ["Payload", "Body", "Input"], + requestParamsSuffix: ["Params"], + responseBodySuffix: ["Data", "Result", "Output"], responseErrorSuffix: [ - 'Error', - 'Fail', - 'Fails', - 'ErrorData', - 'HttpError', - 'BadResponse', + "Error", + "Fail", + "Fails", + "ErrorData", + "HttpError", + "BadResponse", ], - enumSuffix: ['Enum'], - discriminatorMappingSuffix: ['Mapping', 'Mapper', 'MapType'], + enumSuffix: ["Enum"], + discriminatorMappingSuffix: ["Mapping", "Mapper", "MapType"], discriminatorAbstractPrefix: [ - 'Base', - 'Abstract', - 'Discriminator', - 'Internal', - 'Polymorph', + "Base", + "Abstract", + "Discriminator", + "Internal", + "Polymorph", ], }; compilerTsConfig = { - module: 'ESNext', + module: "ESNext", noImplicitReturns: true, alwaysStrict: true, target: ts.ScriptTarget.ESNext, @@ -241,7 +241,7 @@ class CodeGenConfig { /** * $A */ - NullValue: (content) => `null`, + NullValue: (content) => "null", /** * $A1 | $A2 */ @@ -250,7 +250,7 @@ class CodeGenConfig { /** * ($A1) */ - ExpressionGroup: (content) => (content ? `(${content})` : ''), + ExpressionGroup: (content) => (content ? `(${content})` : ""), /** * $A1 & $A2 */ @@ -266,12 +266,12 @@ class CodeGenConfig { */ TypeField: ({ readonly, key, optional, value }) => _.compact([ - readonly && 'readonly ', + readonly && "readonly ", key, - optional && '?', - ': ', + optional && "?", + ": ", value, - ]).join(''), + ]).join(""), /** * [key: $A1]: $A2 */ @@ -294,7 +294,7 @@ class CodeGenConfig { _.map( contents, ({ key, value }) => ` ${this.Ts.EnumField(key, value)}`, - ).join(',\n'), + ).join(",\n"), /** * {\n $A \n} */ @@ -306,21 +306,21 @@ class CodeGenConfig { [ ...(contents.length === 1 ? [`/** ${contents[0]} */`] - : ['/**', ...contents.map((content) => ` * ${content}`), ' */']), + : ["/**", ...contents.map((content) => ` * ${content}`), " */"]), ].map((part) => `${formatFn ? formatFn(part) : part}\n`), /** * $A1<...$A2.join(,)> */ TypeWithGeneric: (typeName, genericArgs) => { return `${typeName}${ - genericArgs.length ? `<${genericArgs.join(',')}>` : '' + genericArgs.length ? `<${genericArgs.join(",")}>` : "" }`; }, /** * [$A1, $A2, ...$AN] */ Tuple: (values) => { - return `[${values.join(', ')}]`; + return `[${values.join(", ")}]`; }, }; @@ -341,39 +341,39 @@ class CodeGenConfig { /** formats */ binary: () => this.Ts.Keyword.File, file: () => this.Ts.Keyword.File, - 'date-time': () => this.Ts.Keyword.String, + "date-time": () => this.Ts.Keyword.String, time: () => this.Ts.Keyword.String, date: () => this.Ts.Keyword.String, duration: () => this.Ts.Keyword.String, email: () => this.Ts.Keyword.String, - 'idn-email': () => this.Ts.Keyword.String, - 'idn-hostname': () => this.Ts.Keyword.String, + "idn-email": () => this.Ts.Keyword.String, + "idn-hostname": () => this.Ts.Keyword.String, ipv4: () => this.Ts.Keyword.String, ipv6: () => this.Ts.Keyword.String, uuid: () => this.Ts.Keyword.String, uri: () => this.Ts.Keyword.String, - 'uri-reference': () => this.Ts.Keyword.String, - 'uri-template': () => this.Ts.Keyword.String, - 'json-pointer': () => this.Ts.Keyword.String, - 'relative-json-pointer': () => this.Ts.Keyword.String, + "uri-reference": () => this.Ts.Keyword.String, + "uri-template": () => this.Ts.Keyword.String, + "json-pointer": () => this.Ts.Keyword.String, + "relative-json-pointer": () => this.Ts.Keyword.String, regex: () => this.Ts.Keyword.String, }, }; templateInfos = [ - { name: 'api', fileName: 'api' }, - { name: 'dataContracts', fileName: 'data-contracts' }, - { name: 'dataContractJsDoc', fileName: 'data-contract-jsdoc' }, - { name: 'interfaceDataContract', fileName: 'interface-data-contract' }, - { name: 'typeDataContract', fileName: 'type-data-contract' }, - { name: 'enumDataContract', fileName: 'enum-data-contract' }, - { name: 'objectFieldJsDoc', fileName: 'object-field-jsdoc' }, - { name: 'httpClient', fileName: 'http-client' }, - { name: 'routeTypes', fileName: 'route-types' }, - { name: 'routeName', fileName: 'route-name' }, + { name: "api", fileName: "api" }, + { name: "dataContracts", fileName: "data-contracts" }, + { name: "dataContractJsDoc", fileName: "data-contract-jsdoc" }, + { name: "interfaceDataContract", fileName: "interface-data-contract" }, + { name: "typeDataContract", fileName: "type-data-contract" }, + { name: "enumDataContract", fileName: "enum-data-contract" }, + { name: "objectFieldJsDoc", fileName: "object-field-jsdoc" }, + { name: "httpClient", fileName: "http-client" }, + { name: "routeTypes", fileName: "route-types" }, + { name: "routeName", fileName: "route-name" }, ]; - templateExtensions = ['.eta', '.ejs']; + templateExtensions = [".eta", ".ejs"]; /** * @param config {Partial} @@ -429,12 +429,12 @@ class CodeGenConfig { } const getDefaultPrettierOptions = () => { - const prettier = cosmiconfigSync('prettier').search(); + const prettier = cosmiconfigSync("prettier").search(); if (prettier) { return { ...prettier.config, - parser: 'typescript', + parser: "typescript", }; } diff --git a/src/constants.js b/src/constants.js index 61b55e14..d6916fd5 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,33 +1,33 @@ -const packageJson = require('../package.json'); -const RESERVED_QUERY_ARG_NAMES = ['query', 'queryParams', 'queryArg']; -const RESERVED_BODY_ARG_NAMES = ['data', 'body', 'reqBody']; +const packageJson = require("../package.json"); +const RESERVED_QUERY_ARG_NAMES = ["query", "queryParams", "queryArg"]; +const RESERVED_BODY_ARG_NAMES = ["data", "body", "reqBody"]; const RESERVED_REQ_PARAMS_ARG_NAMES = [ - 'params', - 'requestParams', - 'reqParams', - 'httpParams', + "params", + "requestParams", + "reqParams", + "httpParams", ]; -const RESERVED_PATH_ARG_NAMES = ['path', 'pathParams']; -const RESERVED_HEADER_ARG_NAMES = ['headers', 'headersParams']; +const RESERVED_PATH_ARG_NAMES = ["path", "pathParams"]; +const RESERVED_HEADER_ARG_NAMES = ["headers", "headersParams"]; const SCHEMA_TYPES = { - ARRAY: 'array', - OBJECT: 'object', - ENUM: 'enum', - REF: '$ref', - PRIMITIVE: 'primitive', - COMPLEX: 'complex', - DISCRIMINATOR: 'discriminator', - COMPLEX_ONE_OF: 'oneOf', - COMPLEX_ANY_OF: 'anyOf', - COMPLEX_ALL_OF: 'allOf', - COMPLEX_NOT: 'not', - COMPLEX_UNKNOWN: '__unknown', + ARRAY: "array", + OBJECT: "object", + ENUM: "enum", + REF: "$ref", + PRIMITIVE: "primitive", + COMPLEX: "complex", + DISCRIMINATOR: "discriminator", + COMPLEX_ONE_OF: "oneOf", + COMPLEX_ANY_OF: "anyOf", + COMPLEX_ALL_OF: "allOf", + COMPLEX_NOT: "not", + COMPLEX_UNKNOWN: "__unknown", }; const HTTP_CLIENT = { - FETCH: 'fetch', - AXIOS: 'axios', + FETCH: "fetch", + AXIOS: "axios", }; const PROJECT_VERSION = packageJson.version; @@ -47,7 +47,7 @@ const FILE_PREFIX = `/* eslint-disable */ module.exports = { FILE_PREFIX, - DEFAULT_BODY_ARG_NAME: 'data', + DEFAULT_BODY_ARG_NAME: "data", PROJECT_VERSION, SCHEMA_TYPES, HTTP_CLIENT, @@ -59,7 +59,7 @@ module.exports = { PRETTIER_OPTIONS: { printWidth: 120, tabWidth: 2, - trailingComma: 'all', - parser: 'typescript', + trailingComma: "all", + parser: "typescript", }, }; diff --git a/src/index.js b/src/index.js index cfbce631..e8950158 100644 --- a/src/index.js +++ b/src/index.js @@ -6,9 +6,9 @@ // License text available at https://opensource.org/licenses/MIT // Repository https://github.com/acacode/swagger-typescript-api -const constants = require('./constants'); -const { CodeGenProcess } = require('./code-gen-process.js'); -const { generateTemplates } = require('./commands/generate-templates'); +const constants = require("./constants"); +const { CodeGenProcess } = require("./code-gen-process.js"); +const { generateTemplates } = require("./commands/generate-templates"); module.exports = { constants: constants, diff --git a/src/schema-components-map.js b/src/schema-components-map.js index 7062788d..d196636c 100644 --- a/src/schema-components-map.js +++ b/src/schema-components-map.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); class SchemaComponentsMap { /** @type {SchemaComponent[]} */ @@ -15,11 +15,11 @@ class SchemaComponentsMap { } createRef = (paths) => { - return ['#', ...paths].join('/'); + return ["#", ...paths].join("/"); }; parseRef = (ref) => { - return ref.split('/'); + return ref.split("/"); }; createComponent($ref, rawTypeData) { diff --git a/src/schema-parser/base-schema-parsers/array.js b/src/schema-parser/base-schema-parsers/array.js index 977153f5..7245ca11 100644 --- a/src/schema-parser/base-schema-parsers/array.js +++ b/src/schema-parser/base-schema-parsers/array.js @@ -1,6 +1,6 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); class ArraySchemaParser extends MonoSchemaParser { parse() { diff --git a/src/schema-parser/base-schema-parsers/complex.js b/src/schema-parser/base-schema-parsers/complex.js index a23dac4c..49a46f28 100644 --- a/src/schema-parser/base-schema-parsers/complex.js +++ b/src/schema-parser/base-schema-parsers/complex.js @@ -1,6 +1,6 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); class ComplexSchemaParser extends MonoSchemaParser { parse() { @@ -23,8 +23,8 @@ class ComplexSchemaParser extends MonoSchemaParser { name: this.typeName, description: this.schemaFormatters.formatDescription( this.schema.description || - _.compact(_.map(this.schema[complexType], 'description'))[0] || - '', + _.compact(_.map(this.schema[complexType], "description"))[0] || + "", ), content: this.config.Ts.IntersectionType( diff --git a/src/schema-parser/base-schema-parsers/discriminator.js b/src/schema-parser/base-schema-parsers/discriminator.js index 478cd3e3..f28f6bea 100644 --- a/src/schema-parser/base-schema-parsers/discriminator.js +++ b/src/schema-parser/base-schema-parsers/discriminator.js @@ -1,6 +1,6 @@ -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); -const { MonoSchemaParser } = require('../mono-schema-parser'); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); +const { MonoSchemaParser } = require("../mono-schema-parser"); class DiscriminatorSchemaParser extends MonoSchemaParser { parse() { @@ -54,8 +54,8 @@ class DiscriminatorSchemaParser extends MonoSchemaParser { const ts = this.config.Ts; const refPath = this.schemaComponentsMap.createRef([ - 'components', - 'schemas', + "components", + "schemas", this.typeName, ]); const { discriminator } = this.schema; @@ -85,18 +85,18 @@ class DiscriminatorSchemaParser extends MonoSchemaParser { ts.ObjectWrapper( ts.TypeField({ key: ts.StringValue(discriminator.propertyName), - value: 'Key', + value: "Key", }), ), - 'Type', + "Type", ]); const component = this.schemaParserFabric.createParsedComponent({ typeName: generatedTypeName, schema: { - type: 'object', + type: "object", properties: {}, - genericArgs: [{ name: 'Key' }, { name: 'Type' }], + genericArgs: [{ name: "Key" }, { name: "Type" }], internal: true, }, }); @@ -138,7 +138,7 @@ class DiscriminatorSchemaParser extends MonoSchemaParser { for (const [mappingKey, schema] of mappingEntries) { const mappingSchema = - typeof schema === 'string' ? { $ref: schema } : schema; + typeof schema === "string" ? { $ref: schema } : schema; this.mutateMappingDependentSchema({ discPropertyName: discriminator.propertyName, @@ -169,7 +169,7 @@ class DiscriminatorSchemaParser extends MonoSchemaParser { let mappingPropertySchemaEnumKeysMap = {}; let mappingPropertySchema = _.get( abstractSchemaStruct?.component?.rawTypeData, - ['properties', discPropertyName], + ["properties", discPropertyName], ); if (this.schemaUtils.isRefSchema(mappingPropertySchema)) { mappingPropertySchema = this.schemaUtils.getSchemaRefType( @@ -271,7 +271,7 @@ class DiscriminatorSchemaParser extends MonoSchemaParser { resolver: this.config.extractingOptions.discriminatorAbstractResolver, }); const component = this.schemaComponentsMap.createComponent( - this.schemaComponentsMap.createRef(['components', 'schemas', typeName]), + this.schemaComponentsMap.createRef(["components", "schemas", typeName]), { ...schema, internal: true, diff --git a/src/schema-parser/base-schema-parsers/enum.js b/src/schema-parser/base-schema-parsers/enum.js index 9a9f18dc..af380c42 100644 --- a/src/schema-parser/base-schema-parsers/enum.js +++ b/src/schema-parser/base-schema-parsers/enum.js @@ -1,7 +1,7 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); -const { EnumKeyResolver } = require('../util/enum-key-resolver'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); +const { EnumKeyResolver } = require("../util/enum-key-resolver"); class EnumSchemaParser extends MonoSchemaParser { /** @type {EnumKeyResolver} */ @@ -19,8 +19,8 @@ class EnumSchemaParser extends MonoSchemaParser { }); const customComponent = this.schemaComponentsMap.createComponent( this.schemaComponentsMap.createRef([ - 'components', - 'schemas', + "components", + "schemas", generatedTypeName, ]), { @@ -49,9 +49,9 @@ class EnumSchemaParser extends MonoSchemaParser { return this.schemaParserFabric.parseSchema( { oneOf: this.schema.enum.map((enumNames) => ({ - type: 'array', + type: "array", items: enumNames.map((enumName) => ({ - type: 'string', + type: "string", enum: [enumName], })), })), @@ -70,12 +70,12 @@ class EnumSchemaParser extends MonoSchemaParser { return this.config.Ts.NullValue(value); } if ( - _.includes(keyType, this.schemaUtils.getSchemaType({ type: 'number' })) + _.includes(keyType, this.schemaUtils.getSchemaType({ type: "number" })) ) { return this.config.Ts.NumberValue(value); } if ( - _.includes(keyType, this.schemaUtils.getSchemaType({ type: 'boolean' })) + _.includes(keyType, this.schemaUtils.getSchemaType({ type: "boolean" })) ) { return this.config.Ts.BooleanValue(value); } @@ -139,13 +139,13 @@ class EnumSchemaParser extends MonoSchemaParser { if (key) { formatted = this.typeNameFormatter.format(key, { - type: 'enum-key', + type: "enum-key", }); } if (!formatted) { formatted = this.typeNameFormatter.format(`${value}`, { - type: 'enum-key', + type: "enum-key", }); } diff --git a/src/schema-parser/base-schema-parsers/object.js b/src/schema-parser/base-schema-parsers/object.js index 034b20ed..53fb7815 100644 --- a/src/schema-parser/base-schema-parsers/object.js +++ b/src/schema-parser/base-schema-parsers/object.js @@ -1,6 +1,6 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); class ObjectSchemaParser extends MonoSchemaParser { parse() { @@ -36,7 +36,7 @@ class ObjectSchemaParser extends MonoSchemaParser { ); const rawTypeData = _.get( this.schemaUtils.getSchemaRefType(property), - 'rawTypeData', + "rawTypeData", {}, ); const nullable = !!(rawTypeData.nullable || property.nullable); @@ -60,17 +60,17 @@ class ObjectSchemaParser extends MonoSchemaParser { _.compact( _.map( property[this.schemaUtils.getComplexType(property)], - 'description', + "description", ), )[0] || rawTypeData.description || _.compact( _.map( rawTypeData[this.schemaUtils.getComplexType(rawTypeData)], - 'description', + "description", ), )[0] || - '', + "", isRequired: required, isNullable: nullable, name: fieldName, @@ -87,7 +87,7 @@ class ObjectSchemaParser extends MonoSchemaParser { if (additionalProperties) { propertiesContent.push({ $$raw: { additionalProperties }, - description: '', + description: "", isRequired: false, field: this.config.Ts.InterfaceDynamicField( this.config.Ts.Keyword.String, diff --git a/src/schema-parser/base-schema-parsers/primitive.js b/src/schema-parser/base-schema-parsers/primitive.js index 48fee765..3a01962d 100644 --- a/src/schema-parser/base-schema-parsers/primitive.js +++ b/src/schema-parser/base-schema-parsers/primitive.js @@ -1,6 +1,6 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../../constants'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../../constants"); class PrimitiveSchemaParser extends MonoSchemaParser { parse() { diff --git a/src/schema-parser/complex-schema-parsers/all-of.js b/src/schema-parser/complex-schema-parsers/all-of.js index 8cbe0df5..8992c5fc 100644 --- a/src/schema-parser/complex-schema-parsers/all-of.js +++ b/src/schema-parser/complex-schema-parsers/all-of.js @@ -1,5 +1,5 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); // T1 & T2 class AllOfSchemaParser extends MonoSchemaParser { diff --git a/src/schema-parser/complex-schema-parsers/any-of.js b/src/schema-parser/complex-schema-parsers/any-of.js index 4d81b3da..667c307f 100644 --- a/src/schema-parser/complex-schema-parsers/any-of.js +++ b/src/schema-parser/complex-schema-parsers/any-of.js @@ -1,5 +1,5 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); // T1 | T2 class AnyOfSchemaParser extends MonoSchemaParser { diff --git a/src/schema-parser/complex-schema-parsers/not.js b/src/schema-parser/complex-schema-parsers/not.js index b4b9bc71..cc6bfddd 100644 --- a/src/schema-parser/complex-schema-parsers/not.js +++ b/src/schema-parser/complex-schema-parsers/not.js @@ -1,4 +1,4 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); +const { MonoSchemaParser } = require("../mono-schema-parser"); class NotSchemaParser extends MonoSchemaParser { parse() { diff --git a/src/schema-parser/complex-schema-parsers/one-of.js b/src/schema-parser/complex-schema-parsers/one-of.js index ec8edf38..58117de0 100644 --- a/src/schema-parser/complex-schema-parsers/one-of.js +++ b/src/schema-parser/complex-schema-parsers/one-of.js @@ -1,5 +1,5 @@ -const { MonoSchemaParser } = require('../mono-schema-parser'); -const _ = require('lodash'); +const { MonoSchemaParser } = require("../mono-schema-parser"); +const _ = require("lodash"); // T1 | T2 class OneOfSchemaParser extends MonoSchemaParser { diff --git a/src/schema-parser/mono-schema-parser.js b/src/schema-parser/mono-schema-parser.js index 6c4d2aa9..f5d6e0d3 100644 --- a/src/schema-parser/mono-schema-parser.js +++ b/src/schema-parser/mono-schema-parser.js @@ -35,7 +35,7 @@ class MonoSchemaParser { } parse() { - throw new Error('not implemented'); + throw new Error("not implemented"); } buildTypeNameFromPath = () => { diff --git a/src/schema-parser/schema-formatters.js b/src/schema-parser/schema-formatters.js index 2ef9f229..4a079e13 100644 --- a/src/schema-parser/schema-formatters.js +++ b/src/schema-parser/schema-formatters.js @@ -1,5 +1,5 @@ -const { SCHEMA_TYPES } = require('../constants'); -const _ = require('lodash'); +const { SCHEMA_TYPES } = require("../constants"); +const _ = require("lodash"); class SchemaFormatters { /** @type {CodeGenConfig} */ @@ -100,22 +100,22 @@ class SchemaFormatters { * @param parsedSchema {Record} * @param formatType {"base" | "inline"} */ - formatSchema = (parsedSchema, formatType = 'base') => { + formatSchema = (parsedSchema, formatType = "base") => { const schemaType = - _.get(parsedSchema, ['schemaType']) || - _.get(parsedSchema, ['$parsed', 'schemaType']); + _.get(parsedSchema, ["schemaType"]) || + _.get(parsedSchema, ["$parsed", "schemaType"]); const formatterFn = _.get(this, [formatType, schemaType]); return (formatterFn && formatterFn(parsedSchema)) || parsedSchema; }; formatDescription = (description, inline) => { - if (!description) return ''; + if (!description) return ""; let prettified = description; - prettified = _.replace(prettified, /\*\//g, '*/'); + prettified = _.replace(prettified, /\*\//g, "*/"); - const hasMultipleLines = _.includes(prettified, '\n'); + const hasMultipleLines = _.includes(prettified, "\n"); if (!hasMultipleLines) return prettified; @@ -124,18 +124,18 @@ class SchemaFormatters { .split(/\n/g) .map((part) => _.trim(part)) .compact() - .join(' ') + .join(" ") .valueOf(); } - return _.replace(prettified, /\n$/g, ''); + return _.replace(prettified, /\n$/g, ""); }; formatObjectContent = (content) => { const fields = []; for (const part of content) { - const extraSpace = ' '; + const extraSpace = " "; const result = `${extraSpace}${part.field},\n`; const renderedJsDoc = this.templatesWorker.renderTemplate( @@ -146,9 +146,9 @@ class SchemaFormatters { ); const routeNameFromTemplate = renderedJsDoc - .split('\n') + .split("\n") .map((c) => `${extraSpace}${c}`) - .join('\n'); + .join("\n"); if (routeNameFromTemplate) { fields.push(`${routeNameFromTemplate}${result}`); @@ -157,7 +157,7 @@ class SchemaFormatters { } } - return fields.join(''); + return fields.join(""); }; } diff --git a/src/schema-parser/schema-parser-fabric.js b/src/schema-parser/schema-parser-fabric.js index fbe93a45..044aa2c4 100644 --- a/src/schema-parser/schema-parser-fabric.js +++ b/src/schema-parser/schema-parser-fabric.js @@ -1,7 +1,7 @@ -const _ = require('lodash'); -const { SchemaFormatters } = require('./schema-formatters'); -const { SchemaUtils } = require('./schema-utils'); -const { SchemaParser } = require('./schema-parser'); +const _ = require("lodash"); +const { SchemaFormatters } = require("./schema-formatters"); +const { SchemaUtils } = require("./schema-utils"); +const { SchemaParser } = require("./schema-parser"); class SchemaParserFabric { /** @type {CodeGenConfig} */ @@ -75,7 +75,7 @@ class SchemaParserFabric { createParsedComponent = ({ typeName, schema, schemaPath }) => { const schemaCopy = _.cloneDeep(schema); const customComponent = this.schemaComponentsMap.createComponent( - this.schemaComponentsMap.createRef(['components', 'schemas', typeName]), + this.schemaComponentsMap.createRef(["components", "schemas", typeName]), schemaCopy, ); const parsed = this.parseSchema(schemaCopy, null, schemaPath); diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index 53e4a969..b4cc4b56 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -1,21 +1,21 @@ /* eslint-disable no-unused-vars */ -const { SCHEMA_TYPES } = require('../constants.js'); -const _ = require('lodash'); -const { SchemaFormatters } = require('./schema-formatters'); -const { SchemaUtils } = require('./schema-utils'); +const { SCHEMA_TYPES } = require("../constants.js"); +const _ = require("lodash"); +const { SchemaFormatters } = require("./schema-formatters"); +const { SchemaUtils } = require("./schema-utils"); const { DiscriminatorSchemaParser, -} = require('./base-schema-parsers/discriminator'); -const { EnumSchemaParser } = require('./base-schema-parsers/enum'); -const { ObjectSchemaParser } = require('./base-schema-parsers/object'); -const { PrimitiveSchemaParser } = require('./base-schema-parsers/primitive'); -const { ComplexSchemaParser } = require('./base-schema-parsers/complex'); -const { OneOfSchemaParser } = require('./complex-schema-parsers/one-of'); -const { AllOfSchemaParser } = require('./complex-schema-parsers/all-of'); -const { AnyOfSchemaParser } = require('./complex-schema-parsers/any-of'); -const { NotSchemaParser } = require('./complex-schema-parsers/not'); -const { ArraySchemaParser } = require('./base-schema-parsers/array'); -const { sortByProperty } = require('../util/sort-by-property'); +} = require("./base-schema-parsers/discriminator"); +const { EnumSchemaParser } = require("./base-schema-parsers/enum"); +const { ObjectSchemaParser } = require("./base-schema-parsers/object"); +const { PrimitiveSchemaParser } = require("./base-schema-parsers/primitive"); +const { ComplexSchemaParser } = require("./base-schema-parsers/complex"); +const { OneOfSchemaParser } = require("./complex-schema-parsers/one-of"); +const { AllOfSchemaParser } = require("./complex-schema-parsers/all-of"); +const { AnyOfSchemaParser } = require("./complex-schema-parsers/any-of"); +const { NotSchemaParser } = require("./complex-schema-parsers/not"); +const { ArraySchemaParser } = require("./base-schema-parsers/array"); +const { sortByProperty } = require("../util/sort-by-property"); class SchemaParser { /** @type {SchemaParserFabric} */ @@ -184,7 +184,7 @@ class SchemaParser { let schemaType = null; let parsedSchema = null; - if (typeof this.schema === 'string') { + if (typeof this.schema === "string") { return this.schema; } @@ -209,13 +209,13 @@ class SchemaParser { this.schema.enum.length === 1 && this.schema.enum[0] == null ) { - this.logger.debug('invalid enum schema', this.schema); + this.logger.debug("invalid enum schema", this.schema); this.schema = { type: this.config.Ts.Keyword.Null }; } // schema is response schema if ( - 'content' in this.schema && - typeof this.schema['content'] === 'object' + "content" in this.schema && + typeof this.schema["content"] === "object" ) { const schema = this.extractSchemaFromResponseStruct(this.schema); const schemaParser = this.schemaParserFabric.createSchemaParser({ @@ -254,7 +254,7 @@ class SchemaParser { Array.isArray(this.schema.$parsed?.content) ) { this.schema.$parsed.content = this.schema.$parsed.content.sort( - sortByProperty('name'), + sortByProperty("name"), ); } } @@ -268,7 +268,7 @@ class SchemaParser { const parsedSchema = this.parseSchema(); const formattedSchema = this.schemaFormatters.formatSchema( parsedSchema, - 'inline', + "inline", ); return formattedSchema.content; }; @@ -277,7 +277,7 @@ class SchemaParser { const parsedSchema = this.parseSchema(); const formattedSchema = this.schemaFormatters.formatSchema( parsedSchema, - 'base', + "base", ); return formattedSchema.content; }; @@ -286,13 +286,13 @@ class SchemaParser { const { content, ...extras } = responseStruct; const firstResponse = _.first(_.values(content)); - const firstSchema = _.get(firstResponse, 'schema'); + const firstSchema = _.get(firstResponse, "schema"); if (!firstSchema) return; return { ...extras, - ..._.omit(firstResponse, 'schema'), + ..._.omit(firstResponse, "schema"), ...firstSchema, }; }; diff --git a/src/schema-parser/schema-utils.js b/src/schema-parser/schema-utils.js index 79133645..f297f181 100644 --- a/src/schema-parser/schema-utils.js +++ b/src/schema-parser/schema-utils.js @@ -1,8 +1,8 @@ -const _ = require('lodash'); -const { SCHEMA_TYPES } = require('../constants'); -const { internalCase } = require('../util/internal-case'); -const { pascalCase } = require('../util/pascal-case'); -const { camelCase } = require('lodash'); +const _ = require("lodash"); +const { SCHEMA_TYPES } = require("../constants"); +const { internalCase } = require("../util/internal-case"); +const { pascalCase } = require("../util/pascal-case"); +const { camelCase } = require("lodash"); class SchemaUtils { /** @type {CodeGenConfig} */ @@ -33,15 +33,15 @@ class SchemaUtils { }; isRefSchema = (schema) => { - return !!(schema && schema['$ref']); + return !!(schema && schema["$ref"]); }; getEnumNames = (schema) => { return ( - schema['x-enumNames'] || - schema['xEnumNames'] || - schema['x-enumnames'] || - schema['x-enum-varnames'] + schema["x-enumNames"] || + schema["xEnumNames"] || + schema["x-enumnames"] || + schema["x-enum-varnames"] ); }; @@ -52,15 +52,15 @@ class SchemaUtils { }; isPropertyRequired = (name, propertySchema, rootSchema) => { - if (propertySchema['x-omitempty'] === false) { + if (propertySchema["x-omitempty"] === false) { return true; } const isRequired = _.isBoolean(propertySchema.required) ? !!propertySchema.required : _.isArray(rootSchema.required) - ? rootSchema.required.includes(name) - : !!rootSchema.required; + ? rootSchema.required.includes(name) + : !!rootSchema.required; if (this.config.convertedFromSwagger2) { return typeof propertySchema.nullable === this.config.Ts.Keyword.Undefined @@ -74,7 +74,7 @@ class SchemaUtils { const { nullable, type: schemaType } = schema || {}; return ( (nullable || - !!_.get(schema, 'x-nullable') || + !!_.get(schema, "x-nullable") || schemaType === this.config.Ts.Keyword.Null) && _.isString(type) && !type.includes(` ${this.config.Ts.Keyword.Null}`) && @@ -112,7 +112,7 @@ class SchemaUtils { }; checkAndAddRequiredKeys = (schema, resultType) => { - if ('$$requiredKeys' in schema && schema.$$requiredKeys.length) { + if ("$$requiredKeys" in schema && schema.$$requiredKeys.length) { this.config.update({ internalTemplateOptions: { addUtilRequiredKeysType: true, @@ -261,7 +261,7 @@ class SchemaUtils { const typeAlias = _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || - _.get(this.config.primitiveTypes, [primitiveType, '$default']) || + _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || this.config.primitiveTypes[primitiveType]; if (_.isFunction(typeAlias)) { @@ -288,24 +288,24 @@ class SchemaUtils { return pascalCase( camelCase( - _.uniq([schemaPath[0], schemaPath[schemaPath.length - 1]]).join('_'), + _.uniq([schemaPath[0], schemaPath[schemaPath.length - 1]]).join("_"), ), ); }; isConstantSchema(schema) { - return 'const' in schema; + return "const" in schema; } formatJsValue = (value) => { switch (typeof value) { - case 'string': { + case "string": { return this.config.Ts.StringValue(value); } - case 'boolean': { + case "boolean": { return this.config.Ts.BooleanValue(value); } - case 'number': { + case "number": { return this.config.Ts.NumberValue(value); } default: { diff --git a/src/schema-parser/util/enum-key-resolver.js b/src/schema-parser/util/enum-key-resolver.js index 8db6a226..b609e5fa 100644 --- a/src/schema-parser/util/enum-key-resolver.js +++ b/src/schema-parser/util/enum-key-resolver.js @@ -1,4 +1,4 @@ -const { NameResolver } = require('../../util/name-resolver'); +const { NameResolver } = require("../../util/name-resolver"); class EnumKeyResolver extends NameResolver { counter = 1; @@ -13,7 +13,7 @@ class EnumKeyResolver extends NameResolver { (variants[0] && `${variants[0]}${this.counter++}`) || `${this.config.enumKeyResolverName}${this.counter++}`; this.logger.debug( - 'generated fallback type name for enum key - ', + "generated fallback type name for enum key - ", generatedVariant, ); return generatedVariant; diff --git a/src/schema-routes/schema-routes.js b/src/schema-routes/schema-routes.js index 365f2328..81a73a8f 100644 --- a/src/schema-routes/schema-routes.js +++ b/src/schema-routes/schema-routes.js @@ -1,24 +1,24 @@ -const _ = require('lodash'); -const { generateId } = require('../util/id.js'); +const _ = require("lodash"); +const { generateId } = require("../util/id.js"); const { SpecificArgNameResolver, -} = require('./util/specific-arg-name-resolver'); +} = require("./util/specific-arg-name-resolver"); const { DEFAULT_BODY_ARG_NAME, RESERVED_BODY_ARG_NAMES, RESERVED_HEADER_ARG_NAMES, RESERVED_PATH_ARG_NAMES, RESERVED_QUERY_ARG_NAMES, -} = require('../constants.js'); -const { camelCase } = require('lodash'); +} = require("../constants.js"); +const { camelCase } = require("lodash"); const CONTENT_KIND = { - JSON: 'JSON', - URL_ENCODED: 'URL_ENCODED', - FORM_DATA: 'FORM_DATA', - IMAGE: 'IMAGE', - OTHER: 'OTHER', - TEXT: 'TEXT', + JSON: "JSON", + URL_ENCODED: "URL_ENCODED", + FORM_DATA: "FORM_DATA", + IMAGE: "IMAGE", + OTHER: "OTHER", + TEXT: "TEXT", }; class SchemaRoutes { @@ -75,20 +75,20 @@ class SchemaRoutes { this.templatesWorker = templatesWorker; this.FORM_DATA_TYPES = _.uniq([ - this.schemaUtils.getSchemaType({ type: 'string', format: 'file' }), - this.schemaUtils.getSchemaType({ type: 'string', format: 'binary' }), + this.schemaUtils.getSchemaType({ type: "string", format: "file" }), + this.schemaUtils.getSchemaType({ type: "string", format: "binary" }), ]); } createRequestsMap = (routeInfoByMethodsMap) => { - const parameters = _.get(routeInfoByMethodsMap, 'parameters'); + const parameters = _.get(routeInfoByMethodsMap, "parameters"); return _.reduce( routeInfoByMethodsMap, (acc, requestInfo, method) => { if ( - _.startsWith(method, 'x-') || - ['parameters', '$ref'].includes(method) + _.startsWith(method, "x-") || + ["parameters", "$ref"].includes(method) ) { return acc; } @@ -109,7 +109,7 @@ class SchemaRoutes { this.config.hooks.onPreBuildRoutePath(originalRouteName) || originalRouteName; - const pathParamMatches = (routeName || '').match( + const pathParamMatches = (routeName || "").match( /({(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?})|(:(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?:?)/g, ); @@ -117,24 +117,24 @@ class SchemaRoutes { const pathParams = _.reduce( pathParamMatches, (pathParams, match) => { - const paramName = _.replace(match, /\{|\}|:/g, ''); + const paramName = _.replace(match, /\{|\}|:/g, ""); if (!paramName) return pathParams; - if (_.includes(paramName, '-')) { - this.logger.warn('wrong path param name', paramName); + if (_.includes(paramName, "-")) { + this.logger.warn("wrong path param name", paramName); } pathParams.push({ $match: match, name: _.camelCase(paramName), required: true, - type: 'string', - description: '', + type: "string", + description: "", schema: { - type: 'string', + type: "string", }, - in: 'path', + in: "path", }); return pathParams; @@ -154,7 +154,7 @@ class SchemaRoutes { ) || pathParam.name; return _.replace(fixedRoute, pathParam.$match, `\${${insertion}}`); }, - routeName || '', + routeName || "", ); const queryParamMatches = fixedRoute.match(/(\{\?.*\})/g); @@ -162,35 +162,35 @@ class SchemaRoutes { if (queryParamMatches && queryParamMatches.length) { queryParamMatches.forEach((match) => { - fixedRoute = fixedRoute.replace(match, ''); + fixedRoute = fixedRoute.replace(match, ""); }); _.uniq( queryParamMatches - .join(',') - .replace(/(\{\?)|(\})|\s/g, '') - .split(','), + .join(",") + .replace(/(\{\?)|(\})|\s/g, "") + .split(","), ).forEach((paramName) => { - if (_.includes(paramName, '-')) { - this.logger.warn('wrong query param name', paramName); + if (_.includes(paramName, "-")) { + this.logger.warn("wrong query param name", paramName); } queryParams.push({ $match: paramName, name: _.camelCase(paramName), required: true, - type: 'string', - description: '', + type: "string", + description: "", schema: { - type: 'string', + type: "string", }, - in: 'query', + in: "query", }); }); } const result = { - originalRoute: originalRouteName || '', + originalRoute: originalRouteName || "", route: fixedRoute, pathParams, queryParams, @@ -246,7 +246,7 @@ class SchemaRoutes { }; } - if (routeParam.in === 'path') { + if (routeParam.in === "path") { if (!routeParam.name) return; routeParam.name = _.camelCase(routeParam.name); @@ -300,29 +300,29 @@ class SchemaRoutes { getContentKind = (contentTypes) => { if ( _.some(contentTypes, (contentType) => - _.startsWith(contentType, 'application/json'), + _.startsWith(contentType, "application/json"), ) || - _.some(contentTypes, (contentType) => _.endsWith(contentType, '+json')) + _.some(contentTypes, (contentType) => _.endsWith(contentType, "+json")) ) { return CONTENT_KIND.JSON; } - if (contentTypes.includes('application/x-www-form-urlencoded')) { + if (contentTypes.includes("application/x-www-form-urlencoded")) { return CONTENT_KIND.URL_ENCODED; } - if (contentTypes.includes('multipart/form-data')) { + if (contentTypes.includes("multipart/form-data")) { return CONTENT_KIND.FORM_DATA; } if ( - _.some(contentTypes, (contentType) => _.includes(contentType, 'image/')) + _.some(contentTypes, (contentType) => _.includes(contentType, "image/")) ) { return CONTENT_KIND.IMAGE; } if ( - _.some(contentTypes, (contentType) => _.startsWith(contentType, 'text/')) + _.some(contentTypes, (contentType) => _.startsWith(contentType, "text/")) ) { return CONTENT_KIND.TEXT; } @@ -331,13 +331,13 @@ class SchemaRoutes { }; isSuccessStatus = (status) => - (this.config.defaultResponseAsSuccess && status === 'default') || + (this.config.defaultResponseAsSuccess && status === "default") || (+status >= this.config.successResponseStatusRange[0] && +status <= this.config.successResponseStatusRange[1]) || - status === '2xx'; + status === "2xx"; getSchemaFromRequestType = (requestInfo) => { - const content = _.get(requestInfo, 'content'); + const content = _.get(requestInfo, "content"); if (!content) return null; @@ -398,7 +398,7 @@ class SchemaRoutes { const typeNameWithoutOpId = _.replace( refTypeInfo.typeName, operationId, - '', + "", ); if ( _.find(parsedSchemas, (schema) => schema.name === typeNameWithoutOpId) @@ -407,10 +407,10 @@ class SchemaRoutes { } switch (refTypeInfo.componentName) { - case 'schemas': + case "schemas": return this.typeNameFormatter.format(refTypeInfo.typeName); - case 'responses': - case 'requestBodies': + case "responses": + case "requestBodies": return this.schemaParserFabric.getInlineParseContent( this.getSchemaFromRequestType(refTypeInfo.rawTypeData), refTypeInfo.typeName || null, @@ -456,7 +456,7 @@ class SchemaRoutes { ), description: this.schemaParserFabric.schemaFormatters.formatDescription( - requestInfo.description || '', + requestInfo.description || "", true, ), status: _.isNaN(+status) ? status : +status, @@ -472,7 +472,7 @@ class SchemaRoutes { const contentTypes = this.getContentTypes(responses, [ ...(produces || []), - routeInfo['x-accepts'], + routeInfo["x-accepts"], ]); const responseInfos = this.getRequestInfoTypes({ @@ -492,7 +492,7 @@ class SchemaRoutes { const handleResponseHeaders = (src) => { if (!src) { - return 'headers: {},'; + return "headers: {},"; } const headerTypes = Object.fromEntries( Object.entries(src).map(([k, v]) => { @@ -501,7 +501,7 @@ class SchemaRoutes { ); const r = `headers: { ${Object.entries(headerTypes) .map(([k, v]) => `"${k}": ${v}`) - .join(',')} },`; + .join(",")} },`; return r; }; @@ -545,7 +545,7 @@ class SchemaRoutes { let usageName = `${schemaPart.name}`; - if (usageName.includes('.')) { + if (usageName.includes(".")) { usageName = camelCase(usageName); } @@ -564,7 +564,7 @@ class SchemaRoutes { }, { properties: {}, - type: 'object', + type: "object", }, ); }; @@ -576,7 +576,7 @@ class SchemaRoutes { const contentTypes = this.getContentTypes( [requestBody], - [...(consumes || []), routeInfo['x-contentType']], + [...(consumes || []), routeInfo["x-contentType"]], ); let contentKind = this.getContentKind(contentTypes); @@ -650,7 +650,7 @@ class SchemaRoutes { type: content, required: requestBody && - (typeof requestBody.required === 'undefined' || !!requestBody.required), + (typeof requestBody.required === "undefined" || !!requestBody.required), }; }; @@ -669,7 +669,7 @@ class SchemaRoutes { if (pathArgSchema.name) { acc[pathArgSchema.name] = { ...pathArgSchema, - in: 'path', + in: "path", }; } @@ -679,12 +679,12 @@ class SchemaRoutes { ); const fixedQueryParams = _.reduce( - _.get(queryObjectSchema, 'properties', {}), + _.get(queryObjectSchema, "properties", {}), (acc, property, name) => { if (name && _.isObject(property)) { acc[name] = { ...property, - in: 'query', + in: "query", }; } @@ -784,17 +784,17 @@ class SchemaRoutes { title: errorSchemas .map((schema) => schema.title) .filter(Boolean) - .join(' '), + .join(" "), description: errorSchemas .map((schema) => schema.description) .filter(Boolean) - .join('\n'), + .join("\n"), }, null, [routeInfo.operationId], ); const component = this.schemaComponentsMap.createComponent( - this.schemaComponentsMap.createRef(['components', 'schemas', typeName]), + this.schemaComponentsMap.createRef(["components", "schemas", typeName]), { ...schema }, ); responseBodyInfo.error.schemas = [component]; @@ -843,7 +843,7 @@ class SchemaRoutes { const duplicates = routeNameDuplicatesMap.get(duplicateIdentifier); const routeNameInfo = { - usage: routeName + (duplicates > 1 ? duplicates : ''), + usage: routeName + (duplicates > 1 ? duplicates : ""), original: routeName, duplicate: duplicates > 1, }; @@ -891,7 +891,7 @@ class SchemaRoutes { const moduleName = moduleNameFirstTag && firstTag ? _.camelCase(firstTag) - : _.camelCase(_.compact(_.split(route, '/'))[moduleNameIndex]); + : _.camelCase(_.compact(_.split(route, "/"))[moduleNameIndex]); let hasSecurity = !!(globalSecurity && globalSecurity.length); if (security) { hasSecurity = security.length > 0; @@ -1059,7 +1059,7 @@ class SchemaRoutes { return { id: routeId, - namespace: _.replace(moduleName, /^(\d)/, 'v$1'), + namespace: _.replace(moduleName, /^(\d)/, "v$1"), routeName, routeParams, requestBodyInfo, @@ -1156,7 +1156,7 @@ class SchemaRoutes { const routeGroups = _.reduce( groupedRoutes, (acc, routesGroup, moduleName) => { - if (moduleName === '$outOfModule') { + if (moduleName === "$outOfModule") { acc.outOfModule = routesGroup; } else { if (!acc.combined) acc.combined = []; diff --git a/src/schema-routes/util/specific-arg-name-resolver.js b/src/schema-routes/util/specific-arg-name-resolver.js index ca3c64f3..cd624f46 100644 --- a/src/schema-routes/util/specific-arg-name-resolver.js +++ b/src/schema-routes/util/specific-arg-name-resolver.js @@ -1,4 +1,4 @@ -const { NameResolver } = require('../../util/name-resolver'); +const { NameResolver } = require("../../util/name-resolver"); class SpecificArgNameResolver extends NameResolver { counter = 1; @@ -13,7 +13,7 @@ class SpecificArgNameResolver extends NameResolver { (variants[0] && `${variants[0]}${this.counter++}`) || `${this.config.specificArgNameResolverName}${this.counter++}`; this.logger.debug( - 'generated fallback type name for specific arg - ', + "generated fallback type name for specific arg - ", generatedVariant, ); return generatedVariant; diff --git a/src/schema-walker.js b/src/schema-walker.js index 01c05f9d..e2055c31 100644 --- a/src/schema-walker.js +++ b/src/schema-walker.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); // TODO: WIP // this class will be needed to walk by schema everywhere @@ -32,7 +32,7 @@ class SchemaWalker { * @returns {any} */ findByRef = (ref) => { - this.logger.debug('try to resolve ref by path', ref); + this.logger.debug("try to resolve ref by path", ref); if (this.caches.has(ref)) { return this.caches.get(ref); @@ -47,10 +47,10 @@ class SchemaWalker { } } } else if (this._isRemoteRef(ref)) { - this.logger.debug('remote refs not supported', ref); + this.logger.debug("remote refs not supported", ref); return null; } else { - const [address, path] = path.split('#'); + const [address, path] = path.split("#"); let swaggerSchemaObject; if (this.schemas.has(address)) { @@ -71,15 +71,15 @@ class SchemaWalker { }; _isLocalRef = (ref) => { - return ref.startsWith('#'); + return ref.startsWith("#"); }; _isRemoteRef = (ref) => { - return ref.startsWith('http://') || ref.startsWith('https://'); + return ref.startsWith("http://") || ref.startsWith("https://"); }; _getRefDataFromSchema = (schema, ref) => { - const path = ref.replace('#', '').split('/'); + const path = ref.replace("#", "").split("/"); const refData = _.get(schema, path); if (refData) { this.caches.set(ref, refData); diff --git a/src/swagger-schema-resolver.js b/src/swagger-schema-resolver.js index 6725e666..1196650f 100644 --- a/src/swagger-schema-resolver.js +++ b/src/swagger-schema-resolver.js @@ -1,7 +1,7 @@ -const _ = require('lodash'); -const converter = require('swagger2openapi'); -const yaml = require('js-yaml'); -const { Request } = require('./util/request'); +const _ = require("lodash"); +const converter = require("swagger2openapi"); +const yaml = require("js-yaml"); +const { Request } = require("./util/request"); class SwaggerSchemaResolver { /** @@ -70,8 +70,8 @@ class SwaggerSchemaResolver { const result = _.cloneDeep(swaggerSchema); result.info = _.merge( { - title: 'No title', - version: '', + title: "No title", + version: "", }, result.info, ); @@ -84,14 +84,14 @@ class SwaggerSchemaResolver { { ...converterOptions, warnOnly: true, - refSiblings: 'preserve', - rbname: 'requestBodyName', + refSiblings: "preserve", + rbname: "requestBodyName", }, (err, options) => { const parsedSwaggerSchema = _.get( err, - 'options.openapi', - _.get(options, 'openapi'), + "options.openapi", + _.get(options, "openapi"), ); if (!parsedSwaggerSchema && err) { throw new Error(err); @@ -138,7 +138,7 @@ class SwaggerSchemaResolver { } processSwaggerSchemaFile(file) { - if (typeof file !== 'string') return file; + if (typeof file !== "string") return file; try { return JSON.parse(file); @@ -148,8 +148,8 @@ class SwaggerSchemaResolver { } fixSwaggerSchema({ usageSchema, originalSchema }) { - const usagePaths = _.get(usageSchema, 'paths'); - const originalPaths = _.get(originalSchema, 'paths'); + const usagePaths = _.get(usageSchema, "paths"); + const originalPaths = _.get(originalSchema, "paths"); // walk by routes _.each(usagePaths, (usagePathObject, route) => { @@ -158,10 +158,10 @@ class SwaggerSchemaResolver { // walk by methods _.each(usagePathObject, (usageRouteInfo, methodName) => { const originalRouteInfo = _.get(originalPathObject, methodName); - const usageRouteParams = _.get(usageRouteInfo, 'parameters', []); - const originalRouteParams = _.get(originalRouteInfo, 'parameters', []); + const usageRouteParams = _.get(usageRouteInfo, "parameters", []); + const originalRouteParams = _.get(originalRouteInfo, "parameters", []); - if (typeof usageRouteInfo === 'object') { + if (typeof usageRouteInfo === "object") { usageRouteInfo.consumes = _.uniq( _.compact([ ...(usageRouteInfo.consumes || []), diff --git a/src/templates-worker.js b/src/templates-worker.js index 8fed4e3a..9d4e3214 100644 --- a/src/templates-worker.js +++ b/src/templates-worker.js @@ -1,7 +1,7 @@ -const { resolve } = require('path'); -const _ = require('lodash'); -const Eta = require('eta'); -const path = require('path'); +const { resolve } = require("node:path"); +const _ = require("lodash"); +const Eta = require("eta"); +const path = require("node:path"); class TemplatesWorker { /** @@ -34,9 +34,9 @@ class TemplatesWorker { * @returns {CodeGenConfig.templatePaths} */ getTemplatePaths = (config) => { - const baseTemplatesPath = resolve(__dirname, '../templates/base'); - const defaultTemplatesPath = resolve(__dirname, '../templates/default'); - const modularTemplatesPath = resolve(__dirname, '../templates/modular'); + const baseTemplatesPath = resolve(__dirname, "../templates/base"); + const defaultTemplatesPath = resolve(__dirname, "../templates/default"); + const modularTemplatesPath = resolve(__dirname, "../templates/modular"); const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath; @@ -59,12 +59,12 @@ class TemplatesWorker { cropExtension = (path) => this.config.templateExtensions.reduce( - (path, ext) => (_.endsWith(path, ext) ? path.replace(ext, '') : path), + (path, ext) => (_.endsWith(path, ext) ? path.replace(ext, "") : path), path, ); getTemplateFullPath = (path, fileName) => { - const raw = resolve(path, './', this.cropExtension(fileName)); + const raw = resolve(path, "./", this.cropExtension(fileName)); const pathVariants = this.config.templateExtensions.map( (extension) => `${raw}${extension}`, ); @@ -76,13 +76,16 @@ class TemplatesWorker { requireFnFromTemplate = (packageOrPath) => { const isPath = - _.startsWith(packageOrPath, './') || _.startsWith(packageOrPath, '../'); + _.startsWith(packageOrPath, "./") || _.startsWith(packageOrPath, "../"); if (isPath) { - return require(path.resolve( - this.config.templatePaths.custom || this.config.templatePaths.original, - packageOrPath, - )); + return require( + path.resolve( + this.config.templatePaths.custom || + this.config.templatePaths.original, + packageOrPath, + ), + ); } return require(packageOrPath); @@ -95,7 +98,7 @@ class TemplatesWorker { return this.fileSystem.getFileContent(path); } - if (!fileName) return ''; + if (!fileName) return ""; const customFullPath = templatePaths.custom && @@ -120,7 +123,7 @@ class TemplatesWorker { `"${_.lowerCase(name)}" template not found in "${ templatePaths.custom }"`, - `\nCode generator will use the default template`, + "\nCode generator will use the default template", ); } else { this.logger.log( @@ -202,7 +205,7 @@ class TemplatesWorker { return this.fileSystem.getFileContent(originalPath); } - return ''; + return ""; }; /** @@ -212,7 +215,7 @@ class TemplatesWorker { * @returns {Promise} */ renderTemplate = (template, configuration, options) => { - if (!template) return ''; + if (!template) return ""; return Eta.render( template, diff --git a/src/translators/javascript.js b/src/translators/javascript.js index 75e4959a..133980fc 100644 --- a/src/translators/javascript.js +++ b/src/translators/javascript.js @@ -1,5 +1,5 @@ -const ts = require('typescript'); -const { Translator } = require('./translator'); +const ts = require("typescript"); +const { Translator } = require("./translator"); class JavascriptTranslator extends Translator { /** @@ -51,17 +51,17 @@ class JavascriptTranslator extends Translator { const dtsFileName = `${input.fileName}${ts.Extension.Dts}`; const sourceContent = compiled[jsFileName]; const tsImportRows = input.fileContent - .split('\n') - .filter((line) => line.startsWith('import ')); + .split("\n") + .filter((line) => line.startsWith("import ")); const declarationContent = compiled[dtsFileName] - .split('\n') + .split("\n") .map((line) => { - if (line.startsWith('import ')) { + if (line.startsWith("import ")) { return tsImportRows.shift(); } return line; }) - .join('\n'); + .join("\n"); return [ { diff --git a/src/translators/translator.js b/src/translators/translator.js index e6b2d72e..1d68168e 100644 --- a/src/translators/translator.js +++ b/src/translators/translator.js @@ -26,7 +26,7 @@ class Translator { */ // eslint-disable-next-line no-unused-vars translate(input) { - throw new Error('not implemented'); + throw new Error("not implemented"); } } diff --git a/src/type-name-formatter.js b/src/type-name-formatter.js index 49bc1aee..f8806471 100644 --- a/src/type-name-formatter.js +++ b/src/type-name-formatter.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); /** * @typedef {"enum-key" | "type-name"} FormattingSchemaType @@ -30,27 +30,27 @@ class TypeNameFormatter { /** * @type {FormattingSchemaType} */ - const schemaType = options.type || 'type-name'; + const schemaType = options.type || "type-name"; const typePrefix = - schemaType === 'enum-key' + schemaType === "enum-key" ? this.config.enumKeyPrefix : this.config.typePrefix; const typeSuffix = - schemaType === 'enum-key' + schemaType === "enum-key" ? this.config.enumKeySuffix : this.config.typeSuffix; const hashKey = `${typePrefix}_${name}_${typeSuffix}`; - if (typeof name !== 'string') { - this.logger.warn('wrong name of the model name', name); + if (typeof name !== "string") { + this.logger.warn("wrong name of the model name", name); return name; } // constant names like LEFT_ARROW, RIGHT_FORWARD, ETC_KEY, _KEY_NUM_ if (/^([A-Z_]{1,})$/g.test(name)) { - return _.compact([typePrefix, name, typeSuffix]).join('_'); + return _.compact([typePrefix, name, typeSuffix]).join("_"); } if (this.formattedModelNamesMap.has(hashKey)) { @@ -62,7 +62,7 @@ class TypeNameFormatter { const formattedName = _.replace( _.startCase(`${typePrefix}_${fixedModelName}_${typeSuffix}`), /\s/g, - '', + "", ); const formattedResultName = this.config.hooks.onFormatTypeName(formattedName, name, schemaType) || @@ -86,22 +86,22 @@ class TypeNameFormatter { if (!this.isValidName(name)) { if (!/^[a-zA-Z_$]/g.test(name)) { const fixPrefix = - type === 'enum-key' + type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix; name = `${fixPrefix} ${name}`; } // specific replaces for TSOA 3.x - if (name.includes('.')) + if (name.includes(".")) name = name - .replace(/Exclude_keyof[A-Za-z]+/g, () => 'ExcludeKeys') - .replace(/%22~AND~%22/g, 'And') - .replace(/%22~OR~%22/g, 'Or') - .replace(/(\.?%22)|\./g, '_') - .replace(/__+$/, ''); + .replace(/Exclude_keyof[A-Za-z]+/g, () => "ExcludeKeys") + .replace(/%22~AND~%22/g, "And") + .replace(/%22~OR~%22/g, "Or") + .replace(/(\.?%22)|\./g, "_") + .replace(/__+$/, ""); - if (name.includes('-')) name = _.startCase(name).replace(/ /g, ''); + if (name.includes("-")) name = _.startCase(name).replace(/ /g, ""); } return name; diff --git a/src/util/file-system.js b/src/util/file-system.js index e99ba03d..9408bb57 100644 --- a/src/util/file-system.js +++ b/src/util/file-system.js @@ -1,8 +1,8 @@ -const fs = require('fs'); -const makeDir = require('make-dir'); -const { resolve } = require('path'); -const _ = require('lodash'); -const { Logger } = require('./logger'); +const fs = require("node:fs"); +const makeDir = require("make-dir"); +const { resolve } = require("node:path"); +const _ = require("lodash"); +const { Logger } = require("./logger"); const FILE_PREFIX = `/* eslint-disable */ /* tslint:disable */ @@ -21,12 +21,12 @@ class FileSystem { /** @type {Logger} */ logger; - constructor({ logger = new Logger('file-system') } = {}) { + constructor({ logger = new Logger("file-system") } = {}) { this.logger = logger; } getFileContent = (path) => { - return fs.readFileSync(path, { encoding: 'UTF-8' }); + return fs.readFileSync(path, { encoding: "UTF-8" }); }; readDir = (path) => { @@ -45,24 +45,24 @@ class FileSystem { }; cropExtension = (fileName) => { - const fileNameParts = _.split(fileName, '.'); + const fileNameParts = _.split(fileName, "."); if (fileNameParts.length > 1) { fileNameParts.pop(); } - return fileNameParts.join('.'); + return fileNameParts.join("."); }; removeDir = (path) => { try { - if (typeof fs.rmSync === 'function') { + if (typeof fs.rmSync === "function") { fs.rmSync(path, { recursive: true }); } else { fs.rmdirSync(path, { recursive: true }); } } catch (e) { - this.logger.debug('failed to remove dir', e); + this.logger.debug("failed to remove dir", e); } }; @@ -70,7 +70,7 @@ class FileSystem { try { makeDir.sync(path); } catch (e) { - this.logger.debug('failed to create dir', e); + this.logger.debug("failed to create dir", e); } }; @@ -85,7 +85,7 @@ class FileSystem { createFile = ({ path, fileName, content, withPrefix }) => { const absolutePath = resolve(__dirname, path, `./${fileName}`); - const fileContent = `${withPrefix ? FILE_PREFIX : ''}${content}`; + const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`; return fs.writeFileSync(absolutePath, fileContent, _.noop); }; diff --git a/src/util/id.js b/src/util/id.js index 95847a64..d4c6b30e 100644 --- a/src/util/id.js +++ b/src/util/id.js @@ -1,6 +1,6 @@ -const { customAlphabet } = require('nanoid'); +const { customAlphabet } = require("nanoid"); -const ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'; +const ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789"; const generateId = customAlphabet(ALPHABET, 12); diff --git a/src/util/internal-case.js b/src/util/internal-case.js index bc6727f5..81ae2b60 100644 --- a/src/util/internal-case.js +++ b/src/util/internal-case.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); module.exports = { internalCase: (value) => _.camelCase(_.lowerCase(value)), diff --git a/src/util/logger.js b/src/util/logger.js index 141fce11..52119a8f 100644 --- a/src/util/logger.js +++ b/src/util/logger.js @@ -1,5 +1,5 @@ -const { emojify } = require('node-emoji'); -const _ = require('lodash'); +const { emojify } = require("node-emoji"); +const _ = require("lodash"); class Logger { firstLog = true; @@ -22,43 +22,43 @@ class Logger { this.log( `swagger-typescript-api(${this.config.version}),${ process.env.npm_config_user_agent || `nodejs(${process.version})` - },debug mode ${this.config.debug ? 'ENABLED' : 'DISABLED'}`, + },debug mode ${this.config.debug ? "ENABLED" : "DISABLED"}`, ); } - if (type === 'debug' || this.config.debug) { + if (type === "debug" || this.config.debug) { const trace = new Error().stack - .split('\n') + .split("\n") .splice(3) .filter( (line) => - !line.includes('swagger-typescript-api\\node_modules') && - !line.includes('swagger-typescript-api/node_modules'), + !line.includes("swagger-typescript-api\\node_modules") && + !line.includes("swagger-typescript-api/node_modules"), ) .slice(0, 10); const logFn = console[type] || console.log; logFn(`${emoji} [${type}]`, new Date().toISOString()); if (this.config.debugExtras && Array.isArray(this.config.debugExtras)) { - logFn(`[${this.config.debugExtras.join(' ')}]`); + logFn(`[${this.config.debugExtras.join(" ")}]`); } logFn( - '[message]', + "[message]", ..._.map(messages, (message) => - _.startsWith(message, '\n') - ? `\n ${message.replace(/\n/, '')}` + _.startsWith(message, "\n") + ? `\n ${message.replace(/\n/, "")}` : message, ), ); - logFn(trace.join('\n') + '\n---'); + logFn(trace.join("\n") + "\n---"); return; } console[type]( emoji, - ' ', + " ", ..._.map(messages, (message) => - _.startsWith(message, '\n') - ? `\n${emoji} ${message.replace(/\n/, '')}` + _.startsWith(message, "\n") + ? `\n${emoji} ${message.replace(/\n/, "")}` : message, ), ); @@ -70,8 +70,8 @@ class Logger { */ log = (...messages) => this.createLogMessage({ - type: 'log', - emojiName: ':sparkles:', + type: "log", + emojiName: ":sparkles:", messages, }); @@ -82,8 +82,8 @@ class Logger { */ event = (...messages) => this.createLogMessage({ - type: 'log', - emojiName: ':star:', + type: "log", + emojiName: ":star:", messages, }); @@ -94,8 +94,8 @@ class Logger { */ success = (...messages) => this.createLogMessage({ - type: 'log', - emojiName: ':white_check_mark:', + type: "log", + emojiName: ":white_check_mark:", messages, }); @@ -106,8 +106,8 @@ class Logger { */ warn = (...messages) => this.createLogMessage({ - type: 'warn', - emojiName: ':exclamation:', + type: "warn", + emojiName: ":exclamation:", messages, }); @@ -118,8 +118,8 @@ class Logger { */ error = (...messages) => this.createLogMessage({ - type: 'error', - emojiName: ':no_entry:', + type: "error", + emojiName: ":no_entry:", messages, }); @@ -132,8 +132,8 @@ class Logger { if (!this.config.debug) return; this.createLogMessage({ - type: 'debug', - emojiName: ':black_large_square:', + type: "debug", + emojiName: ":black_large_square:", messages, }); }; diff --git a/src/util/name-resolver.js b/src/util/name-resolver.js index 4671c560..5c816407 100644 --- a/src/util/name-resolver.js +++ b/src/util/name-resolver.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); class NameResolver { reservedNames = []; @@ -51,14 +51,14 @@ class NameResolver { * @returns {string | null} */ resolve(variants, resolver, extras, shouldReserve = true) { - if (typeof resolver === 'function') { + if (typeof resolver === "function") { let usageName = null; while (usageName === null) { const variant = resolver(variants, extras); if (variant === undefined) { this.logger.warn( - 'unable to resolve name. current reserved names: ', + "unable to resolve name. current reserved names: ", this.reservedNames, ); return null; @@ -86,14 +86,14 @@ class NameResolver { } this.logger.debug( - 'trying to resolve name with using fallback name generator using variants', + "trying to resolve name with using fallback name generator using variants", variants, ); return this.resolve(variants, this.getFallbackName, extras); } this.logger.debug( - 'problem with reserving names. current reserved names: ', + "problem with reserving names. current reserved names: ", this.reservedNames, ); return null; diff --git a/src/util/object-assign.js b/src/util/object-assign.js index 8dde53c9..365c5a18 100644 --- a/src/util/object-assign.js +++ b/src/util/object-assign.js @@ -1,9 +1,9 @@ -const _ = require('lodash'); +const _ = require("lodash"); const objectAssign = (target, updaterFn) => { if (!updaterFn) return; const update = - typeof updaterFn === 'function' ? updaterFn(target) : updaterFn; + typeof updaterFn === "function" ? updaterFn(target) : updaterFn; const undefinedKeys = _.map( update, (value, key) => value === undefined && key, diff --git a/src/util/pascal-case.js b/src/util/pascal-case.js index a78aed50..1bb41c49 100644 --- a/src/util/pascal-case.js +++ b/src/util/pascal-case.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const _ = require("lodash"); module.exports = { pascalCase: (value) => _.upperFirst(_.camelCase(value)), diff --git a/src/util/request.js b/src/util/request.js index bf22a16b..44db6c4e 100644 --- a/src/util/request.js +++ b/src/util/request.js @@ -1,6 +1,6 @@ -const _ = require('lodash'); -const https = require('https'); -const fetch = require('node-fetch-h2'); +const _ = require("lodash"); +const https = require("node:https"); +const fetch = require("node-fetch-h2"); class Request { /** @@ -31,7 +31,7 @@ class Request { */ const requestOptions = {}; - if (disableStrictSSL && !_.startsWith(url, 'http://')) { + if (disableStrictSSL && !_.startsWith(url, "http://")) { requestOptions.agent = new https.Agent({ rejectUnauthorized: false, }); @@ -49,7 +49,7 @@ class Request { return await response.text(); } catch (error) { const message = `error while fetching data from URL "${url}"`; - this.logger.error(message, 'response' in error ? error.response : error); + this.logger.error(message, "response" in error ? error.response : error); return message; } } diff --git a/tests/allSchemas.js b/tests/allSchemas.js index fdeb31cb..b94af4a7 100644 --- a/tests/allSchemas.js +++ b/tests/allSchemas.js @@ -1,4 +1,4 @@ -const { resolve } = require("path"); +const { resolve } = require("node:path"); const dotenv = require("dotenv"); const createSchemaInfos = require("./helpers/createSchemaInfos"); @@ -16,17 +16,31 @@ let allSchemas = [ ]; if (process.env.TEST_FILE_NAME) { - allSchemas = allSchemas.filter((schema) => schema.apiFileName === process.env.TEST_FILE_NAME); - console.warn("TEST ONLY", process.env.TEST_FILE_NAME, 'found:', allSchemas.map(it => it.apiFileName).join(', ') || ''); + allSchemas = allSchemas.filter( + (schema) => schema.apiFileName === process.env.TEST_FILE_NAME, + ); + console.warn( + "TEST ONLY", + process.env.TEST_FILE_NAME, + "found:", + allSchemas.map((it) => it.apiFileName).join(", ") || "", + ); } if (process.env.TEST_SCHEMA_VERSION) { - allSchemas = allSchemas.filter((schema) => schema.outputPath.endsWith(process.env.TEST_SCHEMA_VERSION)); - console.warn("TEST ONLY", process.env.TEST_SCHEMA_VERSION, 'found:', allSchemas.map(it => it.apiFileName).join(', ') || ''); + allSchemas = allSchemas.filter((schema) => + schema.outputPath.endsWith(process.env.TEST_SCHEMA_VERSION), + ); + console.warn( + "TEST ONLY", + process.env.TEST_SCHEMA_VERSION, + "found:", + allSchemas.map((it) => it.apiFileName).join(", ") || "", + ); } if (!allSchemas.length) { - console.warn("TEST SCHEMES NOT FOUND") + console.warn("TEST SCHEMES NOT FOUND"); } module.exports = allSchemas; diff --git a/tests/generate-extended.js b/tests/generate-extended.js index 1b98ce12..4bb4ef6e 100644 --- a/tests/generate-extended.js +++ b/tests/generate-extended.js @@ -1,5 +1,5 @@ const _ = require("lodash"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const dotenv = require("dotenv"); const allSchemas = require("./allSchemas"); const { generateApiForTest } = require("./helpers/generateApiForTest"); @@ -12,9 +12,14 @@ class GenerateExtendedError extends Error { const stackLines = _.split(this.stack, "\n"); const realStack = stackLines.slice(1); - const stackLineExtraSpace = (realStack[0] && realStack[0].split("at")[0]) || ""; + const stackLineExtraSpace = + (realStack[0] && realStack[0].split("at")[0]) || ""; - this.stack = [stackLines[0], `${stackLineExtraSpace}at ${resolve(outputPath, fileName)}`, ...realStack].join("\n"); + this.stack = [ + stackLines[0], + `${stackLineExtraSpace}at ${resolve(outputPath, fileName)}`, + ...realStack, + ].join("\n"); } } @@ -23,8 +28,8 @@ allSchemas.forEach(async ({ absolutePath, apiFileName, outputPath }) => { const input = absolutePath; const output = outputPath; - const typePrefix = 'IMySuperPrefix' - const typeSuffix = 'MySuperSuffix' + const typePrefix = "IMySuperPrefix"; + const typeSuffix = "MySuperSuffix"; await generateApiForTest({ name: name, @@ -50,30 +55,30 @@ allSchemas.forEach(async ({ absolutePath, apiFileName, outputPath }) => { if (modelType.name) { if (modelType.name.startsWith(`${typePrefix}${typePrefix}`)) { throw new GenerateExtendedError( - `[${outputPath}][${apiFileName}] modelType has prefix/suffix duplicates - ${modelType.name}`, - output, - name, + `[${outputPath}][${apiFileName}] modelType has prefix/suffix duplicates - ${modelType.name}`, + output, + name, ); } if (!modelType.name.startsWith(typePrefix)) { throw new GenerateExtendedError( - `[${outputPath}][${apiFileName}] modelType has not prefix/suffix - ${modelType.name}`, - output, - name, + `[${outputPath}][${apiFileName}] modelType has not prefix/suffix - ${modelType.name}`, + output, + name, ); } if (modelType.name.endsWith(`${typeSuffix}${typeSuffix}`)) { throw new GenerateExtendedError( - `[${outputPath}][${apiFileName}] modelType has prefix/suffix duplicates - ${modelType.name}`, - output, - name, + `[${outputPath}][${apiFileName}] modelType has prefix/suffix duplicates - ${modelType.name}`, + output, + name, ); } if (!modelType.name.endsWith(typeSuffix)) { throw new GenerateExtendedError( - `[${outputPath}][${apiFileName}] modelType has not prefix/suffix - ${modelType.name}`, - output, - name, + `[${outputPath}][${apiFileName}] modelType has not prefix/suffix - ${modelType.name}`, + output, + name, ); } } diff --git a/tests/helpers/assertGeneratedModule.js b/tests/helpers/assertGeneratedModule.js index 94b5dd3b..2e24e282 100644 --- a/tests/helpers/assertGeneratedModule.js +++ b/tests/helpers/assertGeneratedModule.js @@ -1,4 +1,4 @@ -const fs = require("fs"); +const fs = require("node:fs"); const gitDiff = require("git-diff"); const _ = require("lodash"); @@ -32,7 +32,10 @@ const assertGeneratedModule = (pathToModule1, pathToModule2) => { }; for (let i = 0; i < lines.length; i++) { const line = lines[i]; - if (line.startsWith(minusLinePrefix1) || line.startsWith(minusLinePrefix2)) { + if ( + line.startsWith(minusLinePrefix1) || + line.startsWith(minusLinePrefix2) + ) { lineStructs.push({ pos: i, id: Math.random().toString() + i, @@ -76,7 +79,10 @@ const assertGeneratedModule = (pathToModule1, pathToModule2) => { } const sortedLines = _.sortBy(_.uniqBy(computedLines, "id"), "pos"); - const maxLine = (sortedLines.map((v) => v.line).sort((a, b) => b.length - a.length)[0] || "").length; + const maxLine = ( + sortedLines.map((v) => v.line).sort((a, b) => b.length - a.length)[0] || + "" + ).length; const fixedLines = sortedLines.reduce((acc, computedLine, i, arr) => { const prev = arr[i - 1]; if ((prev && computedLine.pos - prev.pos > 10) || !i) { diff --git a/tests/helpers/createGeneratedApiInfos.js b/tests/helpers/createGeneratedApiInfos.js index 74902459..a3a22a5d 100644 --- a/tests/helpers/createGeneratedApiInfos.js +++ b/tests/helpers/createGeneratedApiInfos.js @@ -1,6 +1,7 @@ -const fs = require("fs"); -const { resolve } = require("path"); +const fs = require("node:fs"); +const { resolve } = require("node:path"); module.exports = (pathToApis) => - (fs.readdirSync(pathToApis) || []) - .map(fileName => resolve(pathToApis, fileName)) \ No newline at end of file + (fs.readdirSync(pathToApis) || []).map((fileName) => + resolve(pathToApis, fileName), + ); diff --git a/tests/helpers/createSchemaInfos.js b/tests/helpers/createSchemaInfos.js index eac996a1..a7ae4fd0 100644 --- a/tests/helpers/createSchemaInfos.js +++ b/tests/helpers/createSchemaInfos.js @@ -1,6 +1,6 @@ const _ = require("lodash"); -const fs = require("fs"); -const path = require("path"); +const fs = require("node:fs"); +const path = require("node:path"); /** * @@ -14,41 +14,57 @@ const path = require("path"); * }[]} */ const createSchemaInfos = ({ absolutePathToSchemas, absoluteOutputPath }) => { - return (fs.readdirSync(absolutePathToSchemas) || []).reduce((schemas, fileName) => { - if (fileName.endsWith(".yaml") || fileName.endsWith(".json") || fileName.endsWith(".yml")) { - const apiFileName = fileName.replace(/.(yaml|json|yml)/g, ".ts"); - const outputPath = absoluteOutputPath || path.resolve(__dirname, "./"); + return (fs.readdirSync(absolutePathToSchemas) || []).reduce( + (schemas, fileName) => { + if ( + fileName.endsWith(".yaml") || + fileName.endsWith(".json") || + fileName.endsWith(".yml") + ) { + const apiFileName = fileName.replace(/.(yaml|json|yml)/g, ".ts"); + const outputPath = absoluteOutputPath || path.resolve(__dirname, "./"); - schemas.push({ - absolutePath: path.resolve(absolutePathToSchemas, fileName), - schemaFileName: fileName, - apiFileName: apiFileName, - outputPath: outputPath, - Exception: class TestError extends Error { - constructor(message, ...datas) { - super(message); + schemas.push({ + absolutePath: path.resolve(absolutePathToSchemas, fileName), + schemaFileName: fileName, + apiFileName: apiFileName, + outputPath: outputPath, + Exception: class TestError extends Error { + constructor(message, ...datas) { + super(message); - const stackLines = _.split(this.stack, "\n"); - const realStack = stackLines.slice(1); - const stackLineExtraSpace = (realStack[0] && realStack[0].split("at")[0]) || ""; + const stackLines = _.split(this.stack, "\n"); + const realStack = stackLines.slice(1); + const stackLineExtraSpace = + (realStack[0] && realStack[0].split("at")[0]) || ""; - this.stack = [ - stackLines[0], - `${stackLineExtraSpace}at ${path.resolve(outputPath, apiFileName)}`, - ...realStack, - ].join("\n"); + this.stack = [ + stackLines[0], + `${stackLineExtraSpace}at ${path.resolve( + outputPath, + apiFileName, + )}`, + ...realStack, + ].join("\n"); - console.error(stackLines[0], ...datas); - console.error(`${stackLineExtraSpace}at ${path.resolve(outputPath, apiFileName)}`); - console.error(realStack.join("\n")); - process.exit(1); - } - }, - }); - } + console.error(stackLines[0], ...datas); + console.error( + `${stackLineExtraSpace}at ${path.resolve( + outputPath, + apiFileName, + )}`, + ); + console.error(realStack.join("\n")); + process.exit(1); + } + }, + }); + } - return schemas; - }, []); + return schemas; + }, + [], + ); }; module.exports = createSchemaInfos; diff --git a/tests/helpers/specGenerateOptions.js b/tests/helpers/specGenerateOptions.js index 4a461581..f57b2c9f 100644 --- a/tests/helpers/specGenerateOptions.js +++ b/tests/helpers/specGenerateOptions.js @@ -1,6 +1,6 @@ -const path = require("path") +const path = require("node:path"); module.exports = { name: "Api.ts", input: path.resolve(__dirname, "../schemas/v2.0/petstore-simple.yaml"), -} \ No newline at end of file +}; diff --git a/tests/helpers/validateGeneratedModule.js b/tests/helpers/validateGeneratedModule.js index 1af08d5e..2e796a8e 100644 --- a/tests/helpers/validateGeneratedModule.js +++ b/tests/helpers/validateGeneratedModule.js @@ -19,15 +19,29 @@ function compile(fileNames) { let program = ts.createProgram(fileNames, compilerOptions); let emitResult = program.emit(); - let allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + let allDiagnostics = ts + .getPreEmitDiagnostics(program) + .concat(emitResult.diagnostics); allDiagnostics.forEach((diagnostic) => { if (diagnostic.file) { - let { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); - console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + let { line, character } = ts.getLineAndCharacterOfPosition( + diagnostic.file, + diagnostic.start, + ); + let message = ts.flattenDiagnosticMessageText( + diagnostic.messageText, + "\n", + ); + console.error( + `${diagnostic.file.fileName} (${line + 1},${ + character + 1 + }): ${message}`, + ); } else { - console.error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")); + console.error( + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), + ); } }); diff --git a/tests/spec/additional-properties-2.0/test.js b/tests/spec/additional-properties-2.0/test.js index cb6eb22e..b4702dc7 100644 --- a/tests/spec/additional-properties-2.0/test.js +++ b/tests/spec/additional-properties-2.0/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/another-array-type/test.js b/tests/spec/another-array-type/test.js index 901a8e2e..3ae98179 100644 --- a/tests/spec/another-array-type/test.js +++ b/tests/spec/another-array-type/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { anotherArrayType: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/another-query-params/test.js b/tests/spec/another-query-params/test.js index 5d8496ca..4dda1565 100644 --- a/tests/spec/another-query-params/test.js +++ b/tests/spec/another-query-params/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/axios/test.js b/tests/spec/axios/test.js index ed47b590..8e84da14 100644 --- a/tests/spec/axios/test.js +++ b/tests/spec/axios/test.js @@ -1,10 +1,12 @@ -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { httpClientType: "axios", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/axiosSingleHttpClient/test.js b/tests/spec/axiosSingleHttpClient/test.js index 18bf067f..dce152fa 100644 --- a/tests/spec/axiosSingleHttpClient/test.js +++ b/tests/spec/axiosSingleHttpClient/test.js @@ -1,10 +1,12 @@ -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -18,6 +20,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { httpClientType: "axios", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/cli/test.js b/tests/spec/cli/test.js index a9d9df66..837b19c3 100644 --- a/tests/spec/cli/test.js +++ b/tests/spec/cli/test.js @@ -1,6 +1,9 @@ const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -validateGeneratedModule(resolve(__dirname, `./schema.ts`)); -assertGeneratedModule(resolve(__dirname, `./schema.ts`), resolve(__dirname, `./expected.ts`)); +validateGeneratedModule(resolve(__dirname, "./schema.ts")); +assertGeneratedModule( + resolve(__dirname, "./schema.ts"), + resolve(__dirname, "./expected.ts"), +); diff --git a/tests/spec/const-keyword/test.js b/tests/spec/const-keyword/test.js index ff7785e3..a46e7796 100644 --- a/tests/spec/const-keyword/test.js +++ b/tests/spec/const-keyword/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/custom-extensions/test.js b/tests/spec/custom-extensions/test.js index 877d7a26..2dc72722 100644 --- a/tests/spec/custom-extensions/test.js +++ b/tests/spec/custom-extensions/test.js @@ -1,10 +1,12 @@ const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -15,6 +17,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { output: resolve(__dirname, "./"), }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, "./expected.ts")); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/defaultAsSuccess/test.js b/tests/spec/defaultAsSuccess/test.js index c6eac255..b8f5b182 100644 --- a/tests/spec/defaultAsSuccess/test.js +++ b/tests/spec/defaultAsSuccess/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { defaultResponseAsSuccess: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/defaultResponse/test.js b/tests/spec/defaultResponse/test.js index afd5a8c8..255e03c3 100644 --- a/tests/spec/defaultResponse/test.js +++ b/tests/spec/defaultResponse/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { defaultResponseType: "unknown", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/deprecated/test.js b/tests/spec/deprecated/test.js index d1db7fd0..fab46f43 100644 --- a/tests/spec/deprecated/test.js +++ b/tests/spec/deprecated/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { queryParamsWithBrackets: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/discriminator/test.js b/tests/spec/discriminator/test.js index 67870298..3f98388e 100644 --- a/tests/spec/discriminator/test.js +++ b/tests/spec/discriminator/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/dot-path-params/test.js b/tests/spec/dot-path-params/test.js index c654f209..34c5c833 100644 --- a/tests/spec/dot-path-params/test.js +++ b/tests/spec/dot-path-params/test.js @@ -1,6 +1,6 @@ const _ = require("lodash"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); @@ -20,6 +20,9 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { generateClient: true, }).then((output) => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/enumNamesAsValues/test.js b/tests/spec/enumNamesAsValues/test.js index 63eddba0..5433d3d1 100644 --- a/tests/spec/enumNamesAsValues/test.js +++ b/tests/spec/enumNamesAsValues/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { enumNamesAsValues: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/enums-2.0/test.js b/tests/spec/enums-2.0/test.js index ebc7be6e..802558e7 100644 --- a/tests/spec/enums-2.0/test.js +++ b/tests/spec/enums-2.0/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -20,6 +22,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/extra-templates/test.js b/tests/spec/extra-templates/test.js index 42b667bc..ce7d4ba9 100644 --- a/tests/spec/extra-templates/test.js +++ b/tests/spec/extra-templates/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -26,7 +28,10 @@ schemas.forEach(({ absolutePath, apiFileName }) => { }, ], }).then(() => { - validateGeneratedModule(resolve(__dirname, `./external-template-name.ts`)); - assertGeneratedModule(resolve(__dirname, `./external-template-name.ts`), resolve(__dirname, `./expected.ts`)); + validateGeneratedModule(resolve(__dirname, "./external-template-name.ts")); + assertGeneratedModule( + resolve(__dirname, "./external-template-name.ts"), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/extract-enums/test.js b/tests/spec/extract-enums/test.js index 77e47fd1..3156738d 100644 --- a/tests/spec/extract-enums/test.js +++ b/tests/spec/extract-enums/test.js @@ -1,5 +1,5 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); @@ -7,48 +7,58 @@ const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemasv2 = resolve(__dirname, "./v2.0"); const schemasv3 = resolve(__dirname, "./v3.0"); -createSchemaInfos({ absolutePathToSchemas: schemasv2 }).forEach(({ absolutePath, apiFileName }) => { - generateApiForTest({ - testName: "--extract-enums (v2.0) option test", - silent: true, - name: apiFileName, - input: absolutePath, - output: resolve(schemasv2, "./"), - extractEnums: true, - extractRequestParams: true, - extractResponseBody: true, - extractResponseError: true, - generateClient: false, - fixInvalidEnumKeyPrefix: "InvalidKey", - enumKeyPrefix: "EnumKeyPrefix", - enumKeySuffix: "EnumKeySuffix", - typePrefix: "TypeNamePrefix", - typeSuffix: "TypeNameSuffix", - }).then(() => { - validateGeneratedModule(resolve(schemasv2, `./${apiFileName}`)); - assertGeneratedModule(resolve(schemasv2, `./${apiFileName}`), resolve(schemasv2, `./expected.ts`)); - }); -}); +createSchemaInfos({ absolutePathToSchemas: schemasv2 }).forEach( + ({ absolutePath, apiFileName }) => { + generateApiForTest({ + testName: "--extract-enums (v2.0) option test", + silent: true, + name: apiFileName, + input: absolutePath, + output: resolve(schemasv2, "./"), + extractEnums: true, + extractRequestParams: true, + extractResponseBody: true, + extractResponseError: true, + generateClient: false, + fixInvalidEnumKeyPrefix: "InvalidKey", + enumKeyPrefix: "EnumKeyPrefix", + enumKeySuffix: "EnumKeySuffix", + typePrefix: "TypeNamePrefix", + typeSuffix: "TypeNameSuffix", + }).then(() => { + validateGeneratedModule(resolve(schemasv2, `./${apiFileName}`)); + assertGeneratedModule( + resolve(schemasv2, `./${apiFileName}`), + resolve(schemasv2, "./expected.ts"), + ); + }); + }, +); -createSchemaInfos({ absolutePathToSchemas: resolve(schemasv3, "./") }).forEach(({ absolutePath, apiFileName }) => { - generateApiForTest({ - testName: "--extract-enums (v3.0) option test", - silent: true, - name: apiFileName, - input: absolutePath, - output: resolve(schemasv3, "./"), - extractEnums: true, - extractRequestParams: true, - extractResponseBody: true, - extractResponseError: true, - generateClient: false, - fixInvalidEnumKeyPrefix: "InvalidKey", - enumKeyPrefix: "EnumKeyPrefix", - enumKeySuffix: "EnumKeySuffix", - typePrefix: "TypeNamePrefix", - typeSuffix: "TypeNameSuffix", - }).then(() => { - validateGeneratedModule(resolve(schemasv3, `./${apiFileName}`)); - assertGeneratedModule(resolve(schemasv3, `./${apiFileName}`), resolve(schemasv3, `./expected.ts`)); - }); -}); +createSchemaInfos({ absolutePathToSchemas: resolve(schemasv3, "./") }).forEach( + ({ absolutePath, apiFileName }) => { + generateApiForTest({ + testName: "--extract-enums (v3.0) option test", + silent: true, + name: apiFileName, + input: absolutePath, + output: resolve(schemasv3, "./"), + extractEnums: true, + extractRequestParams: true, + extractResponseBody: true, + extractResponseError: true, + generateClient: false, + fixInvalidEnumKeyPrefix: "InvalidKey", + enumKeyPrefix: "EnumKeyPrefix", + enumKeySuffix: "EnumKeySuffix", + typePrefix: "TypeNamePrefix", + typeSuffix: "TypeNameSuffix", + }).then(() => { + validateGeneratedModule(resolve(schemasv3, `./${apiFileName}`)); + assertGeneratedModule( + resolve(schemasv3, `./${apiFileName}`), + resolve(schemasv3, "./expected.ts"), + ); + }); + }, +); diff --git a/tests/spec/extractRequestBody/test.js b/tests/spec/extractRequestBody/test.js index 4dcaf1b8..96cd716b 100644 --- a/tests/spec/extractRequestBody/test.js +++ b/tests/spec/extractRequestBody/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/extractRequestParams/test.js b/tests/spec/extractRequestParams/test.js index e1d6c4da..e89d798b 100644 --- a/tests/spec/extractRequestParams/test.js +++ b/tests/spec/extractRequestParams/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { extractRequestParams: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/extractResponseBody/test.js b/tests/spec/extractResponseBody/test.js index 1bdd8f62..1f3a9406 100644 --- a/tests/spec/extractResponseBody/test.js +++ b/tests/spec/extractResponseBody/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/extractResponseError/test.js b/tests/spec/extractResponseError/test.js index 714f26d1..697342e0 100644 --- a/tests/spec/extractResponseError/test.js +++ b/tests/spec/extractResponseError/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/js/test.js b/tests/spec/js/test.js index ec1ce2a5..1d798142 100644 --- a/tests/spec/js/test.js +++ b/tests/spec/js/test.js @@ -1,9 +1,11 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ diff --git a/tests/spec/jsAxios/test.js b/tests/spec/jsAxios/test.js index f51d30bb..21d8f855 100644 --- a/tests/spec/jsAxios/test.js +++ b/tests/spec/jsAxios/test.js @@ -1,9 +1,11 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ diff --git a/tests/spec/jsSingleHttpClientModular/test.js b/tests/spec/jsSingleHttpClientModular/test.js index 5d94c124..0b1d6abb 100644 --- a/tests/spec/jsSingleHttpClientModular/test.js +++ b/tests/spec/jsSingleHttpClientModular/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, Exception }) => { generateApiForTest({ diff --git a/tests/spec/modular/test.js b/tests/spec/modular/test.js index f9962d78..033ff249 100644 --- a/tests/spec/modular/test.js +++ b/tests/spec/modular/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, Exception }) => { generateApiForTest({ diff --git a/tests/spec/moduleNameFirstTag/test.js b/tests/spec/moduleNameFirstTag/test.js index f12d693a..4870e6c0 100644 --- a/tests/spec/moduleNameFirstTag/test.js +++ b/tests/spec/moduleNameFirstTag/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { moduleNameFirstTag: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/moduleNameIndex/test.js b/tests/spec/moduleNameIndex/test.js index 3a1d8bc2..58a3c476 100644 --- a/tests/spec/moduleNameIndex/test.js +++ b/tests/spec/moduleNameIndex/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { moduleNameIndex: 2, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/noClient/test.js b/tests/spec/noClient/test.js index 44f56d21..8c6da417 100644 --- a/tests/spec/noClient/test.js +++ b/tests/spec/noClient/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/nullable-2.0/test.js b/tests/spec/nullable-2.0/test.js index 61ffdf2c..89bd3f2a 100644 --- a/tests/spec/nullable-2.0/test.js +++ b/tests/spec/nullable-2.0/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/nullable-3.0/test.js b/tests/spec/nullable-3.0/test.js index dff0261d..542434b6 100644 --- a/tests/spec/nullable-3.0/test.js +++ b/tests/spec/nullable-3.0/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/object-types/test.js b/tests/spec/object-types/test.js index f2d7e2a9..f3dd720c 100644 --- a/tests/spec/object-types/test.js +++ b/tests/spec/object-types/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/on-insert-path-param/test.js b/tests/spec/on-insert-path-param/test.js index 70bb777a..e8173a97 100644 --- a/tests/spec/on-insert-path-param/test.js +++ b/tests/spec/on-insert-path-param/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -19,6 +21,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { }, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/partialBaseTemplate/test.js b/tests/spec/partialBaseTemplate/test.js index 47e3bdd2..3c1ed685 100644 --- a/tests/spec/partialBaseTemplate/test.js +++ b/tests/spec/partialBaseTemplate/test.js @@ -1,11 +1,13 @@ const _ = require("lodash"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName, Exception }) => { generateApiForTest({ @@ -17,11 +19,19 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { // because this script was called from package.json folder templates: "./tests/spec/partialBaseTemplate/spec_templates", }).then((output) => { - if (!_.includes(_.get(output.files, "[0].fileContent"), "/** PARTIAL TEMPLATES */")) { + if ( + !_.includes( + _.get(output.files, "[0].fileContent"), + "/** PARTIAL TEMPLATES */", + ) + ) { throw new Exception("Failed, spec templates are not applied"); } validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/partialDefaultTemplate/test.js b/tests/spec/partialDefaultTemplate/test.js index db301bb7..33325a91 100644 --- a/tests/spec/partialDefaultTemplate/test.js +++ b/tests/spec/partialDefaultTemplate/test.js @@ -1,11 +1,13 @@ const _ = require("lodash"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName, Exception }) => { generateApiForTest({ @@ -17,11 +19,19 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { // because this script was called from package.json folder templates: "./tests/spec/partialDefaultTemplate/spec_templates", }).then((output) => { - if (!_.includes(_.get(output.files, "[0].fileContent"), "/** PARTIAL TEMPLATES */")) { + if ( + !_.includes( + _.get(output.files, "[0].fileContent"), + "/** PARTIAL TEMPLATES */", + ) + ) { throw new Exception("Failed, spec templates are not applied"); } validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/patch/test.js b/tests/spec/patch/test.js index 2c2c4858..bf18b20e 100644 --- a/tests/spec/patch/test.js +++ b/tests/spec/patch/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { patch: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/primitive-type-constructs/test.js b/tests/spec/primitive-type-constructs/test.js index 70e7ef85..069a8efc 100644 --- a/tests/spec/primitive-type-constructs/test.js +++ b/tests/spec/primitive-type-constructs/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { const primitiveTypeConstructs = (constructs) => ({ @@ -45,13 +47,18 @@ schemas.forEach(({ absolutePath, apiFileName }) => { codeGenConstructs, }), ]).then((...args) => { - validateGeneratedModule(resolve(__dirname, `./another-array-type/${apiFileName}`)); + validateGeneratedModule( + resolve(__dirname, `./another-array-type/${apiFileName}`), + ); assertGeneratedModule( resolve(__dirname, `./another-array-type/${apiFileName}`), - resolve(__dirname, `./another-array-type/expected.ts`), + resolve(__dirname, "./another-array-type/expected.ts"), ); validateGeneratedModule(resolve(__dirname, `./base/${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./base/${apiFileName}`), resolve(__dirname, `./base/expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./base/${apiFileName}`), + resolve(__dirname, "./base/expected.ts"), + ); }); }); diff --git a/tests/spec/readonly/test.js b/tests/spec/readonly/test.js index 25986c73..1807c264 100644 --- a/tests/spec/readonly/test.js +++ b/tests/spec/readonly/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/responses/test.js b/tests/spec/responses/test.js index ff67ee80..8d4a7416 100644 --- a/tests/spec/responses/test.js +++ b/tests/spec/responses/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,7 +18,10 @@ schemas.forEach(({ absolutePath, apiFileName }) => { }) .then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }) .catch((e) => { console.error("responses option test failed."); diff --git a/tests/spec/routeTypes/test.js b/tests/spec/routeTypes/test.js index 58aae114..2cd01b0b 100644 --- a/tests/spec/routeTypes/test.js +++ b/tests/spec/routeTypes/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/singleHttpClient/test.js b/tests/spec/singleHttpClient/test.js index e50f0e05..42f71165 100644 --- a/tests/spec/singleHttpClient/test.js +++ b/tests/spec/singleHttpClient/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { singleHttpClient: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/sortTypes-false/test.js b/tests/spec/sortTypes-false/test.js index c3df414c..46a6e81b 100644 --- a/tests/spec/sortTypes-false/test.js +++ b/tests/spec/sortTypes-false/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { sortTypes: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/sortTypes/test.js b/tests/spec/sortTypes/test.js index d3acca01..77b3a16b 100644 --- a/tests/spec/sortTypes/test.js +++ b/tests/spec/sortTypes/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { sortTypes: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/specProperty/test.js b/tests/spec/specProperty/test.js index f514018a..9e28de0d 100644 --- a/tests/spec/specProperty/test.js +++ b/tests/spec/specProperty/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -17,6 +19,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/templates/test.js b/tests/spec/templates/test.js index ff4ab6a6..0a1be656 100644 --- a/tests/spec/templates/test.js +++ b/tests/spec/templates/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName, Exception }) => { generateApiForTest({ @@ -15,9 +17,11 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { output: resolve(__dirname, "./"), // because this script was called from package.json folder templates: "./tests/spec/templates/spec_templates", - }) - .then(() => { - validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); - }); + }).then(() => { + validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); + }); }); diff --git a/tests/spec/typeSuffixPrefix/test.js b/tests/spec/typeSuffixPrefix/test.js index ccf5eb12..9b016725 100644 --- a/tests/spec/typeSuffixPrefix/test.js +++ b/tests/spec/typeSuffixPrefix/test.js @@ -1,6 +1,6 @@ const _ = require("lodash"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); @@ -23,6 +23,9 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { generateResponses: true, }).then((output) => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/spec/unionEnums/test.js b/tests/spec/unionEnums/test.js index 8f11b56c..504a5814 100644 --- a/tests/spec/unionEnums/test.js +++ b/tests/spec/unionEnums/test.js @@ -1,10 +1,12 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); -const { resolve } = require("path"); +const { resolve } = require("node:path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); -const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); +const schemas = createSchemaInfos({ + absolutePathToSchemas: resolve(__dirname, "./"), +}); schemas.forEach(({ absolutePath, apiFileName }) => { generateApiForTest({ @@ -16,6 +18,9 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateUnionEnums: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); + assertGeneratedModule( + resolve(__dirname, `./${apiFileName}`), + resolve(__dirname, "./expected.ts"), + ); }); }); diff --git a/tests/validate.js b/tests/validate.js index 3495ec29..53f188b2 100644 --- a/tests/validate.js +++ b/tests/validate.js @@ -1,4 +1,4 @@ -const { resolve } = require("path"); +const { resolve } = require("node:path"); const allSchemas = require("./allSchemas"); const validateGeneratedModule = require("./helpers/validateGeneratedModule"); diff --git a/yarn.lock b/yarn.lock index d7926e02..53fb6ccb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -34,15 +34,6 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.18.9, @babel/runtime@npm:^7.7.6": - version: 7.24.5 - resolution: "@babel/runtime@npm:7.24.5" - dependencies: - regenerator-runtime: "npm:^0.14.0" - checksum: 10c0/05730e43e8ba6550eae9fd4fb5e7d9d3cb91140379425abcb2a1ff9cebad518a280d82c4c4b0f57ada26a863106ac54a748d90c775790c0e2cd0ddd85ccdf346 - languageName: node - linkType: hard - "@biomejs/biome@npm:1.7.2": version: 1.7.2 resolution: "@biomejs/biome@npm:1.7.2" @@ -199,39 +190,6 @@ __metadata: languageName: node linkType: hard -"all-contributors-cli@npm:^6.26.1": - version: 6.26.1 - resolution: "all-contributors-cli@npm:6.26.1" - dependencies: - "@babel/runtime": "npm:^7.7.6" - async: "npm:^3.1.0" - chalk: "npm:^4.0.0" - didyoumean: "npm:^1.2.1" - inquirer: "npm:^7.3.3" - json-fixer: "npm:^1.6.8" - lodash: "npm:^4.11.2" - node-fetch: "npm:^2.6.0" - pify: "npm:^5.0.0" - prettier: "npm:^2" - yargs: "npm:^15.0.1" - dependenciesMeta: - prettier: - optional: true - bin: - all-contributors: dist/cli.js - checksum: 10c0/da33f175aabbf95596e4b06f1582720cf05b2e2ceb363df85b104b7cb072b050d2f3f3adbb0af91142c61ddb10fcaa4d194f32f64551a467e665b2c2dcb3e561 - languageName: node - linkType: hard - -"ansi-escapes@npm:^4.2.1": - version: 4.3.2 - resolution: "ansi-escapes@npm:4.3.2" - dependencies: - type-fest: "npm:^0.21.3" - checksum: 10c0/da917be01871525a3dfcf925ae2977bc59e8c513d4423368645634bf5d4ceba5401574eb705c1e92b79f7292af5a656f78c5725a4b0e1cec97c4b413705c1d50 - languageName: node - linkType: hard - "ansi-regex@npm:^5.0.1": version: 5.0.1 resolution: "ansi-regex@npm:5.0.1" @@ -255,7 +213,7 @@ __metadata: languageName: node linkType: hard -"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": +"ansi-styles@npm:^4.0.0": version: 4.3.0 resolution: "ansi-styles@npm:4.3.0" dependencies: @@ -278,13 +236,6 @@ __metadata: languageName: node linkType: hard -"async@npm:^3.1.0": - version: 3.2.5 - resolution: "async@npm:3.2.5" - checksum: 10c0/1408287b26c6db67d45cb346e34892cee555b8b59e6c68e6f8c3e495cad5ca13b4f218180e871f3c2ca30df4ab52693b66f2f6ff43644760cab0b2198bda79c1 - languageName: node - linkType: hard - "asynckit@npm:^0.4.0": version: 0.4.0 resolution: "asynckit@npm:0.4.0" @@ -343,13 +294,6 @@ __metadata: languageName: node linkType: hard -"camelcase@npm:^5.0.0": - version: 5.3.1 - resolution: "camelcase@npm:5.3.1" - checksum: 10c0/92ff9b443bfe8abb15f2b1513ca182d16126359ad4f955ebc83dc4ddcc4ef3fdd2c078bc223f2673dc223488e75c99b16cc4d056624374b799e6a1555cf61b23 - languageName: node - linkType: hard - "chalk@npm:^2.3.2, chalk@npm:^2.4.2": version: 2.4.2 resolution: "chalk@npm:2.4.2" @@ -361,16 +305,6 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.2": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: "npm:^4.1.0" - supports-color: "npm:^7.1.0" - checksum: 10c0/4a3fef5cc34975c898ffe77141450f679721df9dde00f6c304353fa9c8b571929123b26a0e4617bde5018977eb655b31970c297b91b63ee83bb82aeb04666880 - languageName: node - linkType: hard - "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -378,40 +312,6 @@ __metadata: languageName: node linkType: hard -"chardet@npm:^0.7.0": - version: 0.7.0 - resolution: "chardet@npm:0.7.0" - checksum: 10c0/96e4731b9ec8050cbb56ab684e8c48d6c33f7826b755802d14e3ebfdc51c57afeece3ea39bc6b09acc359e4363525388b915e16640c1378053820f5e70d0f27d - languageName: node - linkType: hard - -"cli-cursor@npm:^3.1.0": - version: 3.1.0 - resolution: "cli-cursor@npm:3.1.0" - dependencies: - restore-cursor: "npm:^3.1.0" - checksum: 10c0/92a2f98ff9037d09be3dfe1f0d749664797fb674bf388375a2207a1203b69d41847abf16434203e0089212479e47a358b13a0222ab9fccfe8e2644a7ccebd111 - languageName: node - linkType: hard - -"cli-width@npm:^3.0.0": - version: 3.0.0 - resolution: "cli-width@npm:3.0.0" - checksum: 10c0/125a62810e59a2564268c80fdff56c23159a7690c003e34aeb2e68497dccff26911998ff49c33916fcfdf71e824322cc3953e3f7b48b27267c7a062c81348a9a - languageName: node - linkType: hard - -"cliui@npm:^6.0.0": - version: 6.0.0 - resolution: "cliui@npm:6.0.0" - dependencies: - string-width: "npm:^4.2.0" - strip-ansi: "npm:^6.0.0" - wrap-ansi: "npm:^6.2.0" - checksum: 10c0/35229b1bb48647e882104cac374c9a18e34bbf0bace0e2cf03000326b6ca3050d6b59545d91e17bfe3705f4a0e2988787aa5cde6331bf5cbbf0164732cef6492 - languageName: node - linkType: hard - "cliui@npm:^8.0.1": version: 8.0.1 resolution: "cliui@npm:8.0.1" @@ -513,13 +413,6 @@ __metadata: languageName: node linkType: hard -"decamelize@npm:^1.2.0": - version: 1.2.0 - resolution: "decamelize@npm:1.2.0" - checksum: 10c0/85c39fe8fbf0482d4a1e224ef0119db5c1897f8503bcef8b826adff7a1b11414972f6fef2d7dec2ee0b4be3863cf64ac1439137ae9e6af23a3d8dcbe26a5b4b2 - languageName: node - linkType: hard - "delayed-stream@npm:~1.0.0": version: 1.0.0 resolution: "delayed-stream@npm:1.0.0" @@ -527,7 +420,7 @@ __metadata: languageName: node linkType: hard -"didyoumean@npm:^1.2.1, didyoumean@npm:^1.2.2": +"didyoumean@npm:^1.2.2": version: 1.2.2 resolution: "didyoumean@npm:1.2.2" checksum: 10c0/95d0b53d23b851aacff56dfadb7ecfedce49da4232233baecfeecb7710248c4aa03f0aa8995062f0acafaf925adf8536bd7044a2e68316fd7d411477599bc27b @@ -613,17 +506,6 @@ __metadata: languageName: node linkType: hard -"external-editor@npm:^3.0.3": - version: 3.1.0 - resolution: "external-editor@npm:3.1.0" - dependencies: - chardet: "npm:^0.7.0" - iconv-lite: "npm:^0.4.24" - tmp: "npm:^0.0.33" - checksum: 10c0/c98f1ba3efdfa3c561db4447ff366a6adb5c1e2581462522c56a18bf90dfe4da382f9cd1feee3e330108c3595a854b218272539f311ba1b3298f841eb0fbf339 - languageName: node - linkType: hard - "fast-safe-stringify@npm:^2.0.7": version: 2.1.1 resolution: "fast-safe-stringify@npm:2.1.1" @@ -641,25 +523,6 @@ __metadata: languageName: node linkType: hard -"figures@npm:^3.0.0": - version: 3.2.0 - resolution: "figures@npm:3.2.0" - dependencies: - escape-string-regexp: "npm:^1.0.5" - checksum: 10c0/9c421646ede432829a50bc4e55c7a4eb4bcb7cc07b5bab2f471ef1ab9a344595bbebb6c5c21470093fbb730cd81bbca119624c40473a125293f656f49cb47629 - languageName: node - linkType: hard - -"find-up@npm:^4.1.0": - version: 4.1.0 - resolution: "find-up@npm:4.1.0" - dependencies: - locate-path: "npm:^5.0.0" - path-exists: "npm:^4.0.0" - checksum: 10c0/0406ee89ebeefa2d507feb07ec366bebd8a6167ae74aa4e34fb4c4abd06cf782a3ce26ae4194d70706f72182841733f00551c209fe575cb00bd92104056e78c1 - languageName: node - linkType: hard - "follow-redirects@npm:^1.15.6": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" @@ -714,7 +577,7 @@ __metadata: languageName: node linkType: hard -"get-caller-file@npm:^2.0.1, get-caller-file@npm:^2.0.5": +"get-caller-file@npm:^2.0.5": version: 2.0.5 resolution: "get-caller-file@npm:2.0.5" checksum: 10c0/c6c7b60271931fa752aeb92f2b47e355eac1af3a2673f47c9589e8f8a41adc74d45551c1bc57b5e66a80609f10ffb72b6f575e4370d61cc3f7f3aaff01757cde @@ -770,13 +633,6 @@ __metadata: languageName: node linkType: hard -"has-flag@npm:^4.0.0": - version: 4.0.0 - resolution: "has-flag@npm:4.0.0" - checksum: 10c0/2e789c61b7888d66993e14e8331449e525ef42aac53c627cc53d1c3334e768bcb6abdc4f5f0de1478a25beec6f0bd62c7549058b7ac53e924040d4f301f02fd1 - languageName: node - linkType: hard - "hasown@npm:^2.0.0": version: 2.0.2 resolution: "hasown@npm:2.0.2" @@ -793,15 +649,6 @@ __metadata: languageName: node linkType: hard -"iconv-lite@npm:^0.4.24": - version: 0.4.24 - resolution: "iconv-lite@npm:0.4.24" - dependencies: - safer-buffer: "npm:>= 2.1.2 < 3" - checksum: 10c0/c6886a24cc00f2a059767440ec1bc00d334a89f250db8e0f7feb4961c8727118457e27c495ba94d082e51d3baca378726cd110aaf7ded8b9bbfd6a44760cf1d4 - languageName: node - linkType: hard - "import-fresh@npm:^3.2.1": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -829,27 +676,6 @@ __metadata: languageName: node linkType: hard -"inquirer@npm:^7.3.3": - version: 7.3.3 - resolution: "inquirer@npm:7.3.3" - dependencies: - ansi-escapes: "npm:^4.2.1" - chalk: "npm:^4.1.0" - cli-cursor: "npm:^3.1.0" - cli-width: "npm:^3.0.0" - external-editor: "npm:^3.0.3" - figures: "npm:^3.0.0" - lodash: "npm:^4.17.19" - mute-stream: "npm:0.0.8" - run-async: "npm:^2.4.0" - rxjs: "npm:^6.6.0" - string-width: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - through: "npm:^2.3.6" - checksum: 10c0/96e75974cfd863fe6653c075e41fa5f1a290896df141189816db945debabcd92d3277145f11aef8d2cfca5409ab003ccdd18a099744814057b52a2f27aeb8c94 - languageName: node - linkType: hard - "interpret@npm:^1.0.0": version: 1.4.0 resolution: "interpret@npm:1.4.0" @@ -918,17 +744,6 @@ __metadata: languageName: node linkType: hard -"json-fixer@npm:^1.6.8": - version: 1.6.15 - resolution: "json-fixer@npm:1.6.15" - dependencies: - "@babel/runtime": "npm:^7.18.9" - chalk: "npm:^4.1.2" - pegjs: "npm:^0.10.0" - checksum: 10c0/8267add4ce0214abe2de69a85caf12ad2a79bf815df50f89d08a9155261800a2b8b635af2c6a385c05074526efe8ae9b7670e83c759a82a570bd13f47337b642 - languageName: node - linkType: hard - "json-parse-even-better-errors@npm:^2.3.0": version: 2.3.1 resolution: "json-parse-even-better-errors@npm:2.3.1" @@ -943,16 +758,7 @@ __metadata: languageName: node linkType: hard -"locate-path@npm:^5.0.0": - version: 5.0.0 - resolution: "locate-path@npm:5.0.0" - dependencies: - p-locate: "npm:^4.1.0" - checksum: 10c0/33a1c5247e87e022f9713e6213a744557a3e9ec32c5d0b5efb10aa3a38177615bf90221a5592674857039c1a0fd2063b82f285702d37b792d973e9e72ace6c59 - languageName: node - linkType: hard - -"lodash@npm:4.17.21, lodash@npm:^4.11.2, lodash@npm:^4.17.19": +"lodash@npm:4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: 10c0/d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c @@ -1007,13 +813,6 @@ __metadata: languageName: node linkType: hard -"mimic-fn@npm:^2.1.0": - version: 2.1.0 - resolution: "mimic-fn@npm:2.1.0" - checksum: 10c0/b26f5479d7ec6cc2bce275a08f146cf78f5e7b661b18114e2506dd91ec7ec47e7a25bf4360e5438094db0560bcc868079fb3b1fb3892b833c1ecbf63f80c95a4 - languageName: node - linkType: hard - "minimatch@npm:^3.1.1": version: 3.1.2 resolution: "minimatch@npm:3.1.2" @@ -1039,13 +838,6 @@ __metadata: languageName: node linkType: hard -"mute-stream@npm:0.0.8": - version: 0.0.8 - resolution: "mute-stream@npm:0.0.8" - checksum: 10c0/18d06d92e5d6d45e2b63c0e1b8f25376af71748ac36f53c059baa8b76ffac31c5ab225480494e7d35d30215ecdb18fed26ec23cafcd2f7733f2f14406bcd19e2 - languageName: node - linkType: hard - "nanoid@npm:3.3.6": version: 3.3.6 resolution: "nanoid@npm:3.3.6" @@ -1083,7 +875,7 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^2.6.0, node-fetch@npm:^2.6.1": +"node-fetch@npm:^2.6.1": version: 2.7.0 resolution: "node-fetch@npm:2.7.0" dependencies: @@ -1184,47 +976,6 @@ __metadata: languageName: node linkType: hard -"onetime@npm:^5.1.0": - version: 5.1.2 - resolution: "onetime@npm:5.1.2" - dependencies: - mimic-fn: "npm:^2.1.0" - checksum: 10c0/ffcef6fbb2692c3c40749f31ea2e22677a876daea92959b8a80b521d95cca7a668c884d8b2045d1d8ee7d56796aa405c405462af112a1477594cc63531baeb8f - languageName: node - linkType: hard - -"os-tmpdir@npm:~1.0.2": - version: 1.0.2 - resolution: "os-tmpdir@npm:1.0.2" - checksum: 10c0/f438450224f8e2687605a8dd318f0db694b6293c5d835ae509a69e97c8de38b6994645337e5577f5001115470414638978cc49da1cdcc25106dad8738dc69990 - languageName: node - linkType: hard - -"p-limit@npm:^2.2.0": - version: 2.3.0 - resolution: "p-limit@npm:2.3.0" - dependencies: - p-try: "npm:^2.0.0" - checksum: 10c0/8da01ac53efe6a627080fafc127c873da40c18d87b3f5d5492d465bb85ec7207e153948df6b9cbaeb130be70152f874229b8242ee2be84c0794082510af97f12 - languageName: node - linkType: hard - -"p-locate@npm:^4.1.0": - version: 4.1.0 - resolution: "p-locate@npm:4.1.0" - dependencies: - p-limit: "npm:^2.2.0" - checksum: 10c0/1b476ad69ad7f6059744f343b26d51ce091508935c1dbb80c4e0a2f397ffce0ca3a1f9f5cd3c7ce19d7929a09719d5c65fe70d8ee289c3f267cd36f2881813e9 - languageName: node - linkType: hard - -"p-try@npm:^2.0.0": - version: 2.2.0 - resolution: "p-try@npm:2.2.0" - checksum: 10c0/c36c19907734c904b16994e6535b02c36c2224d433e01a2f1ab777237f4d86e6289fd5fd464850491e940379d4606ed850c03e0f9ab600b0ebddb511312e177f - languageName: node - linkType: hard - "parent-module@npm:^1.0.0": version: 1.0.1 resolution: "parent-module@npm:1.0.1" @@ -1246,13 +997,6 @@ __metadata: languageName: node linkType: hard -"path-exists@npm:^4.0.0": - version: 4.0.0 - resolution: "path-exists@npm:4.0.0" - checksum: 10c0/8c0bd3f5238188197dc78dced15207a4716c51cc4e3624c44fc97acf69558f5ebb9a2afff486fe1b4ee148e0c133e96c5e11a9aa5c48a3006e3467da070e5e1b - languageName: node - linkType: hard - "path-is-absolute@npm:^1.0.0": version: 1.0.1 resolution: "path-is-absolute@npm:1.0.1" @@ -1291,15 +1035,6 @@ __metadata: languageName: node linkType: hard -"pegjs@npm:^0.10.0": - version: 0.10.0 - resolution: "pegjs@npm:0.10.0" - bin: - pegjs: bin/pegjs - checksum: 10c0/51f2aee312cd506c37c21a88fee2d921ccae81697c7aa3e61f0ad8e370d8c37e2a86680993fce405f53337a56ad471f9e7f4377b2eb3c780d5cf6ae8a16ce0a5 - languageName: node - linkType: hard - "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -1307,13 +1042,6 @@ __metadata: languageName: node linkType: hard -"pify@npm:^5.0.0": - version: 5.0.0 - resolution: "pify@npm:5.0.0" - checksum: 10c0/9f6f3cd1f159652692f514383efe401a06473af35a699962230ad1c4c9796df5999961461fc1a3b81eed8e3e74adb8bd032474fb3f93eb6bdbd9f33328da1ed2 - languageName: node - linkType: hard - "prettier@npm:3.0.0": version: 3.0.0 resolution: "prettier@npm:3.0.0" @@ -1323,15 +1051,6 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: 10c0/463ea8f9a0946cd5b828d8cf27bd8b567345cf02f56562d5ecde198b91f47a76b7ac9eae0facd247ace70e927143af6135e8cf411986b8cb8478784a4d6d724a - languageName: node - linkType: hard - "proxy-from-env@npm:^1.1.0": version: 1.1.0 resolution: "proxy-from-env@npm:1.1.0" @@ -1355,13 +1074,6 @@ __metadata: languageName: node linkType: hard -"regenerator-runtime@npm:^0.14.0": - version: 0.14.1 - resolution: "regenerator-runtime@npm:0.14.1" - checksum: 10c0/1b16eb2c4bceb1665c89de70dcb64126a22bc8eb958feef3cd68fe11ac6d2a4899b5cd1b80b0774c7c03591dc57d16631a7f69d2daa2ec98100e2f29f7ec4cc4 - languageName: node - linkType: hard - "require-directory@npm:^2.1.1": version: 2.1.1 resolution: "require-directory@npm:2.1.1" @@ -1369,13 +1081,6 @@ __metadata: languageName: node linkType: hard -"require-main-filename@npm:^2.0.0": - version: 2.0.0 - resolution: "require-main-filename@npm:2.0.0" - checksum: 10c0/db91467d9ead311b4111cbd73a4e67fa7820daed2989a32f7023785a2659008c6d119752d9c4ac011ae07e537eb86523adff99804c5fdb39cd3a017f9b401bb6 - languageName: node - linkType: hard - "resolve-from@npm:^4.0.0": version: 4.0.0 resolution: "resolve-from@npm:4.0.0" @@ -1409,16 +1114,6 @@ __metadata: languageName: node linkType: hard -"restore-cursor@npm:^3.1.0": - version: 3.1.0 - resolution: "restore-cursor@npm:3.1.0" - dependencies: - onetime: "npm:^5.1.0" - signal-exit: "npm:^3.0.2" - checksum: 10c0/8051a371d6aa67ff21625fa94e2357bd81ffdc96267f3fb0fc4aaf4534028343836548ef34c240ffa8c25b280ca35eb36be00b3cb2133fa4f51896d7e73c6b4f - languageName: node - linkType: hard - "rimraf@npm:^5.0.1": version: 5.0.5 resolution: "rimraf@npm:5.0.5" @@ -1430,29 +1125,6 @@ __metadata: languageName: node linkType: hard -"run-async@npm:^2.4.0": - version: 2.4.1 - resolution: "run-async@npm:2.4.1" - checksum: 10c0/35a68c8f1d9664f6c7c2e153877ca1d6e4f886e5ca067c25cdd895a6891ff3a1466ee07c63d6a9be306e9619ff7d509494e6d9c129516a36b9fd82263d579ee1 - languageName: node - linkType: hard - -"rxjs@npm:^6.6.0": - version: 6.6.7 - resolution: "rxjs@npm:6.6.7" - dependencies: - tslib: "npm:^1.9.0" - checksum: 10c0/e556a13a9aa89395e5c9d825eabcfa325568d9c9990af720f3f29f04a888a3b854f25845c2b55875d875381abcae2d8100af9cacdc57576e7ed6be030a01d2fe - languageName: node - linkType: hard - -"safer-buffer@npm:>= 2.1.2 < 3": - version: 2.1.2 - resolution: "safer-buffer@npm:2.1.2" - checksum: 10c0/7e3c8b2e88a1841c9671094bbaeebd94448111dd90a81a1f606f3f67708a6ec57763b3b47f06da09fc6054193e0e6709e77325415dc8422b04497a8070fa02d4 - languageName: node - linkType: hard - "semver@npm:^7.5.3": version: 7.6.0 resolution: "semver@npm:7.6.0" @@ -1464,13 +1136,6 @@ __metadata: languageName: node linkType: hard -"set-blocking@npm:^2.0.0": - version: 2.0.0 - resolution: "set-blocking@npm:2.0.0" - checksum: 10c0/9f8c1b2d800800d0b589de1477c753492de5c1548d4ade52f57f1d1f5e04af5481554d75ce5e5c43d4004b80a3eb714398d6907027dc0534177b7539119f4454 - languageName: node - linkType: hard - "shebang-command@npm:^2.0.0": version: 2.0.0 resolution: "shebang-command@npm:2.0.0" @@ -1563,13 +1228,6 @@ __metadata: languageName: node linkType: hard -"signal-exit@npm:^3.0.2": - version: 3.0.7 - resolution: "signal-exit@npm:3.0.7" - checksum: 10c0/25d272fa73e146048565e08f3309d5b942c1979a6f4a58a8c59d5fa299728e9c2fcd1a759ec870863b1fd38653670240cd420dad2ad9330c71f36608a6a1c912 - languageName: node - linkType: hard - "signal-exit@npm:^4.0.1": version: 4.1.0 resolution: "signal-exit@npm:4.1.0" @@ -1635,15 +1293,6 @@ __metadata: languageName: node linkType: hard -"supports-color@npm:^7.1.0": - version: 7.2.0 - resolution: "supports-color@npm:7.2.0" - dependencies: - has-flag: "npm:^4.0.0" - checksum: 10c0/afb4c88521b8b136b5f5f95160c98dee7243dc79d5432db7efc27efb219385bbc7d9427398e43dd6cc730a0f87d5085ce1652af7efbe391327bc0a7d0f7fc124 - languageName: node - linkType: hard - "supports-preserve-symlinks-flag@npm:^1.0.0": version: 1.0.0 resolution: "supports-preserve-symlinks-flag@npm:1.0.0" @@ -1667,7 +1316,6 @@ __metadata: "@types/node": "npm:^20.4.1" "@types/prettier": "npm:^2.7.3" "@types/swagger-schema-official": "npm:2.0.25" - all-contributors-cli: "npm:^6.26.1" axios: "npm:^1.4.0" cosmiconfig: "npm:8.2.0" cross-env: "npm:^7.0.3" @@ -1715,22 +1363,6 @@ __metadata: languageName: node linkType: hard -"through@npm:^2.3.6": - version: 2.3.8 - resolution: "through@npm:2.3.8" - checksum: 10c0/4b09f3774099de0d4df26d95c5821a62faee32c7e96fb1f4ebd54a2d7c11c57fe88b0a0d49cf375de5fee5ae6bf4eb56dbbf29d07366864e2ee805349970d3cc - languageName: node - linkType: hard - -"tmp@npm:^0.0.33": - version: 0.0.33 - resolution: "tmp@npm:0.0.33" - dependencies: - os-tmpdir: "npm:~1.0.2" - checksum: 10c0/69863947b8c29cabad43fe0ce65cec5bb4b481d15d4b4b21e036b060b3edbf3bc7a5541de1bacb437bb3f7c4538f669752627fdf9b4aaf034cebd172ba373408 - languageName: node - linkType: hard - "tr46@npm:~0.0.3": version: 0.0.3 resolution: "tr46@npm:0.0.3" @@ -1738,20 +1370,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.9.0": - version: 1.14.1 - resolution: "tslib@npm:1.14.1" - checksum: 10c0/69ae09c49eea644bc5ebe1bca4fa4cc2c82b7b3e02f43b84bd891504edf66dbc6b2ec0eef31a957042de2269139e4acff911e6d186a258fb14069cd7f6febce2 - languageName: node - linkType: hard - -"type-fest@npm:^0.21.3": - version: 0.21.3 - resolution: "type-fest@npm:0.21.3" - checksum: 10c0/902bd57bfa30d51d4779b641c2bc403cdf1371fb9c91d3c058b0133694fcfdb817aef07a47f40faf79039eecbaa39ee9d3c532deff244f3a19ce68cea71a61e8 - languageName: node - linkType: hard - "typescript@npm:5.4.5": version: 5.4.5 resolution: "typescript@npm:5.4.5" @@ -1810,13 +1428,6 @@ __metadata: languageName: node linkType: hard -"which-module@npm:^2.0.0": - version: 2.0.1 - resolution: "which-module@npm:2.0.1" - checksum: 10c0/087038e7992649eaffa6c7a4f3158d5b53b14cf5b6c1f0e043dccfacb1ba179d12f17545d5b85ebd94a42ce280a6fe65d0cbcab70f4fc6daad1dfae85e0e6a3e - languageName: node - linkType: hard - "which@npm:^2.0.1": version: 2.0.2 resolution: "which@npm:2.0.2" @@ -1839,17 +1450,6 @@ __metadata: languageName: node linkType: hard -"wrap-ansi@npm:^6.2.0": - version: 6.2.0 - resolution: "wrap-ansi@npm:6.2.0" - dependencies: - ansi-styles: "npm:^4.0.0" - string-width: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - checksum: 10c0/baad244e6e33335ea24e86e51868fe6823626e3a3c88d9a6674642afff1d34d9a154c917e74af8d845fd25d170c4ea9cf69a47133c3f3656e1252b3d462d9f6c - languageName: node - linkType: hard - "wrap-ansi@npm:^8.1.0": version: 8.1.0 resolution: "wrap-ansi@npm:8.1.0" @@ -1868,13 +1468,6 @@ __metadata: languageName: node linkType: hard -"y18n@npm:^4.0.0": - version: 4.0.3 - resolution: "y18n@npm:4.0.3" - checksum: 10c0/308a2efd7cc296ab2c0f3b9284fd4827be01cfeb647b3ba18230e3a416eb1bc887ac050de9f8c4fd9e7856b2e8246e05d190b53c96c5ad8d8cb56dffb6f81024 - languageName: node - linkType: hard - "y18n@npm:^5.0.5": version: 5.0.8 resolution: "y18n@npm:5.0.8" @@ -1896,16 +1489,6 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:^18.1.2": - version: 18.1.3 - resolution: "yargs-parser@npm:18.1.3" - dependencies: - camelcase: "npm:^5.0.0" - decamelize: "npm:^1.2.0" - checksum: 10c0/25df918833592a83f52e7e4f91ba7d7bfaa2b891ebf7fe901923c2ee797534f23a176913ff6ff7ebbc1cc1725a044cc6a6539fed8bfd4e13b5b16376875f9499 - languageName: node - linkType: hard - "yargs-parser@npm:^21.1.1": version: 21.1.1 resolution: "yargs-parser@npm:21.1.1" @@ -1913,25 +1496,6 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^15.0.1": - version: 15.4.1 - resolution: "yargs@npm:15.4.1" - dependencies: - cliui: "npm:^6.0.0" - decamelize: "npm:^1.2.0" - find-up: "npm:^4.1.0" - get-caller-file: "npm:^2.0.1" - require-directory: "npm:^2.1.1" - require-main-filename: "npm:^2.0.0" - set-blocking: "npm:^2.0.0" - string-width: "npm:^4.2.0" - which-module: "npm:^2.0.0" - y18n: "npm:^4.0.0" - yargs-parser: "npm:^18.1.2" - checksum: 10c0/f1ca680c974333a5822732825cca7e95306c5a1e7750eb7b973ce6dc4f97a6b0a8837203c8b194f461969bfe1fb1176d1d423036635285f6010b392fa498ab2d - languageName: node - linkType: hard - "yargs@npm:^17.0.1": version: 17.7.2 resolution: "yargs@npm:17.7.2"