From 8fef68d1bfe43b056b907ec3375055c278b741dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=23=E4=BA=91=E6=B7=A1=E7=84=B6?= Date: Fri, 24 Mar 2023 23:18:31 +0800 Subject: [PATCH] feat: oas-gen-ts -> openapi-axios --- CHANGELOG.md | 263 +++++++++++++++++++--------------------------- README.md | 85 +++++++-------- package-lock.json | 6 +- package.json | 13 +-- src/const.ts | 2 +- src/generator.ts | 15 ++- src/types.ts | 14 +-- 7 files changed, 183 insertions(+), 215 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3e345c..6e059f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,320 +1,279 @@ # Changelog -## [0.6.27](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.26...v0.6.27) (2023-03-19) - +## [0.6.27](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.26...v0.6.27) (2023-03-19) ### Bug Fixes -* update pretterrc ([3d264f6](https://github.com/cloudcome/oas-gen-ts/commit/3d264f6ca0e3752e51e58892b0ae8fe2469451ff)) -* update README.md ([3bcefab](https://github.com/cloudcome/oas-gen-ts/commit/3bcefabbd02257d4e2f14740e421c7289f60ee97)) -* 使用 cloudcome/publish-node-package-action@v1 进行版本发布 ([296ae78](https://github.com/cloudcome/oas-gen-ts/commit/296ae78c102d9a4bfb692268e76a64ea319dc644)) -* 修改 package author ([05bb81a](https://github.com/cloudcome/oas-gen-ts/commit/05bb81acb3b78de271b338ed4ce808a8ef6e1331)) - -## [0.6.26](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.25...v0.6.26) (2023-03-17) +- update pretterrc ([3d264f6](https://github.com/FrontEndDev-org/openapi-axios/commit/3d264f6ca0e3752e51e58892b0ae8fe2469451ff)) +- update README.md ([3bcefab](https://github.com/FrontEndDev-org/openapi-axios/commit/3bcefabbd02257d4e2f14740e421c7289f60ee97)) +- 使用 cloudcome/publish-node-package-action@v1 进行版本发布 ([296ae78](https://github.com/FrontEndDev-org/openapi-axios/commit/296ae78c102d9a4bfb692268e76a64ea319dc644)) +- 修改 package author ([05bb81a](https://github.com/FrontEndDev-org/openapi-axios/commit/05bb81acb3b78de271b338ed4ce808a8ef6e1331)) +## [0.6.26](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.25...v0.6.26) (2023-03-17) ### Bug Fixes -* 优化 actions 39 - 新增 dependency-review ([d929414](https://github.com/cloudcome/oas-gen-ts/commit/d9294145abe9acd3317f3c11891f0dab10aff5b4)) -* 优化 actions 39 - 移除 codecov ([3976be2](https://github.com/cloudcome/oas-gen-ts/commit/3976be2f74e54989bc780538f137661ddd613c33)) -* 优化 actions 40 ([5b44175](https://github.com/cloudcome/oas-gen-ts/commit/5b441753dbc1d822890f99763480ea4138b17024)) -* 优化 actions 40 - 更新 readme ([e317301](https://github.com/cloudcome/oas-gen-ts/commit/e317301970b1bfb2e6d2d01d4524f310407469c1)) - -## [0.6.25](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.24...v0.6.25) (2023-03-17) +- 优化 actions 39 - 新增 dependency-review ([d929414](https://github.com/FrontEndDev-org/openapi-axios/commit/d9294145abe9acd3317f3c11891f0dab10aff5b4)) +- 优化 actions 39 - 移除 codecov ([3976be2](https://github.com/FrontEndDev-org/openapi-axios/commit/3976be2f74e54989bc780538f137661ddd613c33)) +- 优化 actions 40 ([5b44175](https://github.com/FrontEndDev-org/openapi-axios/commit/5b441753dbc1d822890f99763480ea4138b17024)) +- 优化 actions 40 - 更新 readme ([e317301](https://github.com/FrontEndDev-org/openapi-axios/commit/e317301970b1bfb2e6d2d01d4524f310407469c1)) +## [0.6.25](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.24...v0.6.25) (2023-03-17) ### Bug Fixes -* 优化 actions 38 ([af3ba2d](https://github.com/cloudcome/oas-gen-ts/commit/af3ba2de90e705b9b9f70dbf10b23a185db0e4d0)) - -## [0.6.24](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.23...v0.6.24) (2023-03-17) +- 优化 actions 38 ([af3ba2d](https://github.com/FrontEndDev-org/openapi-axios/commit/af3ba2de90e705b9b9f70dbf10b23a185db0e4d0)) +## [0.6.24](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.23...v0.6.24) (2023-03-17) ### Bug Fixes -* 优化 actions 37 ([9fcc50b](https://github.com/cloudcome/oas-gen-ts/commit/9fcc50b607b69eacdf901df4c524ed808a21fe4f)) - -## [0.6.23](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.22...v0.6.23) (2023-03-17) +- 优化 actions 37 ([9fcc50b](https://github.com/FrontEndDev-org/openapi-axios/commit/9fcc50b607b69eacdf901df4c524ed808a21fe4f)) +## [0.6.23](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.22...v0.6.23) (2023-03-17) ### Bug Fixes -* 优化 actions 35 ([ae10697](https://github.com/cloudcome/oas-gen-ts/commit/ae106973059bec57b7f824d6ae04a0438418e964)) -* 优化 actions 36 ([d64f741](https://github.com/cloudcome/oas-gen-ts/commit/d64f7413c68d2166d7fadd3ebc0b478356b12932)) - -## [0.6.22](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.21...v0.6.22) (2023-03-17) +- 优化 actions 35 ([ae10697](https://github.com/FrontEndDev-org/openapi-axios/commit/ae106973059bec57b7f824d6ae04a0438418e964)) +- 优化 actions 36 ([d64f741](https://github.com/FrontEndDev-org/openapi-axios/commit/d64f7413c68d2166d7fadd3ebc0b478356b12932)) +## [0.6.22](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.21...v0.6.22) (2023-03-17) ### Bug Fixes -* 优化 actions 34 ([23b1367](https://github.com/cloudcome/oas-gen-ts/commit/23b136754063ca35527f2a017ce15460ae707720)) - -## [0.6.21](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.20...v0.6.21) (2023-03-17) +- 优化 actions 34 ([23b1367](https://github.com/FrontEndDev-org/openapi-axios/commit/23b136754063ca35527f2a017ce15460ae707720)) +## [0.6.21](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.20...v0.6.21) (2023-03-17) ### Bug Fixes -* 优化 actions 33 ([c10eb06](https://github.com/cloudcome/oas-gen-ts/commit/c10eb0628ebea8d97e0c83d15cc4a18facf82e7e)) - -## [0.6.20](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.19...v0.6.20) (2023-03-17) +- 优化 actions 33 ([c10eb06](https://github.com/FrontEndDev-org/openapi-axios/commit/c10eb0628ebea8d97e0c83d15cc4a18facf82e7e)) +## [0.6.20](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.19...v0.6.20) (2023-03-17) ### Bug Fixes -* 优化 actions 32 ([80b578c](https://github.com/cloudcome/oas-gen-ts/commit/80b578c1929e2928095c433c73550b1dd7b69b43)) - -## [0.6.19](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.18...v0.6.19) (2023-03-17) +- 优化 actions 32 ([80b578c](https://github.com/FrontEndDev-org/openapi-axios/commit/80b578c1929e2928095c433c73550b1dd7b69b43)) +## [0.6.19](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.18...v0.6.19) (2023-03-17) ### Bug Fixes -* 优化 actions 31 ([01ea251](https://github.com/cloudcome/oas-gen-ts/commit/01ea251499cb9cd5b5131101de733a9ffc6e3738)) - -## [0.6.18](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.17...v0.6.18) (2023-03-17) +- 优化 actions 31 ([01ea251](https://github.com/FrontEndDev-org/openapi-axios/commit/01ea251499cb9cd5b5131101de733a9ffc6e3738)) +## [0.6.18](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.17...v0.6.18) (2023-03-17) ### Bug Fixes -* 优化 actions 29 ([b0b7de2](https://github.com/cloudcome/oas-gen-ts/commit/b0b7de282de76aead3d8b48f0b8ff837cff97e50)) -* 优化 actions 30 ([dd04a6a](https://github.com/cloudcome/oas-gen-ts/commit/dd04a6a087c132b836623f724a09bf0b6a8facc0)) - -## [0.6.17](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.16...v0.6.17) (2023-03-17) +- 优化 actions 29 ([b0b7de2](https://github.com/FrontEndDev-org/openapi-axios/commit/b0b7de282de76aead3d8b48f0b8ff837cff97e50)) +- 优化 actions 30 ([dd04a6a](https://github.com/FrontEndDev-org/openapi-axios/commit/dd04a6a087c132b836623f724a09bf0b6a8facc0)) +## [0.6.17](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.16...v0.6.17) (2023-03-17) ### Bug Fixes -* 优化 actions 28 ([06d0cea](https://github.com/cloudcome/oas-gen-ts/commit/06d0cea9e7d7eec1dddb2d65f3612098df058d35)) - -## [0.6.16](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.15...v0.6.16) (2023-03-17) +- 优化 actions 28 ([06d0cea](https://github.com/FrontEndDev-org/openapi-axios/commit/06d0cea9e7d7eec1dddb2d65f3612098df058d35)) +## [0.6.16](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.15...v0.6.16) (2023-03-17) ### Bug Fixes -* 优化 actions 27 ([fc6c400](https://github.com/cloudcome/oas-gen-ts/commit/fc6c4007c982cbce1cff7e42973e094ae02270fc)) - -## [0.6.15](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.14...v0.6.15) (2023-03-17) +- 优化 actions 27 ([fc6c400](https://github.com/FrontEndDev-org/openapi-axios/commit/fc6c4007c982cbce1cff7e42973e094ae02270fc)) +## [0.6.15](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.14...v0.6.15) (2023-03-17) ### Bug Fixes -* 优化 actions 26 ([7998ef9](https://github.com/cloudcome/oas-gen-ts/commit/7998ef928a0491251fea26e72a495d55f3d67dae)) - -## [0.6.14](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.13...v0.6.14) (2023-03-17) +- 优化 actions 26 ([7998ef9](https://github.com/FrontEndDev-org/openapi-axios/commit/7998ef928a0491251fea26e72a495d55f3d67dae)) +## [0.6.14](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.13...v0.6.14) (2023-03-17) ### Bug Fixes -* 优化 actions 25 ([9c637e7](https://github.com/cloudcome/oas-gen-ts/commit/9c637e7b122fd43a6fbc9de11a8059ddeb52dc38)) - -## [0.6.13](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.12...v0.6.13) (2023-03-17) +- 优化 actions 25 ([9c637e7](https://github.com/FrontEndDev-org/openapi-axios/commit/9c637e7b122fd43a6fbc9de11a8059ddeb52dc38)) +## [0.6.13](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.12...v0.6.13) (2023-03-17) ### Bug Fixes -* 优化 actions 23 ([aa9593f](https://github.com/cloudcome/oas-gen-ts/commit/aa9593f26e4669631d2a396bb20930357e696981)) -* 优化 actions 24 ([5ae3eb1](https://github.com/cloudcome/oas-gen-ts/commit/5ae3eb1a6601709c3cd8354bfbb2909877528dcd)) - -## [0.6.12](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.11...v0.6.12) (2023-03-17) +- 优化 actions 23 ([aa9593f](https://github.com/FrontEndDev-org/openapi-axios/commit/aa9593f26e4669631d2a396bb20930357e696981)) +- 优化 actions 24 ([5ae3eb1](https://github.com/FrontEndDev-org/openapi-axios/commit/5ae3eb1a6601709c3cd8354bfbb2909877528dcd)) +## [0.6.12](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.11...v0.6.12) (2023-03-17) ### Bug Fixes -* 优化 actions 21 ([2725059](https://github.com/cloudcome/oas-gen-ts/commit/27250593a38957875eb9e234710b5a10c373cf2b)) -* 优化 actions 22 ([1c54242](https://github.com/cloudcome/oas-gen-ts/commit/1c542421c5241eab373e9f61041cbbf818edac0f)) - -## [0.6.11](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.10...v0.6.11) (2023-03-17) +- 优化 actions 21 ([2725059](https://github.com/FrontEndDev-org/openapi-axios/commit/27250593a38957875eb9e234710b5a10c373cf2b)) +- 优化 actions 22 ([1c54242](https://github.com/FrontEndDev-org/openapi-axios/commit/1c542421c5241eab373e9f61041cbbf818edac0f)) +## [0.6.11](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.10...v0.6.11) (2023-03-17) ### Bug Fixes -* 优化 actions 11 ([5c3578f](https://github.com/cloudcome/oas-gen-ts/commit/5c3578f51b441027e804463fcde6f2cfc44b1c9a)) -* 优化 actions 12 ([a684fae](https://github.com/cloudcome/oas-gen-ts/commit/a684faee7cdfdbfe4812bf2b0df7f6933a7231be)) -* 优化 actions 13 ([99ec84b](https://github.com/cloudcome/oas-gen-ts/commit/99ec84b4f29b01f8c49a271b660d6370d16ec236)) -* 优化 actions 14 ([793c5ef](https://github.com/cloudcome/oas-gen-ts/commit/793c5ef9a085607154a0b0c1d12aebc1203d6c7f)) -* 优化 actions 15 ([ddc496a](https://github.com/cloudcome/oas-gen-ts/commit/ddc496a93fa83040822c12e3bb8cd9a544c4ceec)) -* 优化 actions 16 ([b28bc1d](https://github.com/cloudcome/oas-gen-ts/commit/b28bc1d5c625bbe394c1c0f141700ed01a6c2627)) -* 优化 actions 17 ([99a2d7d](https://github.com/cloudcome/oas-gen-ts/commit/99a2d7dc8f5b67f2d8fbfb3433b40c6d05a28c26)) -* 优化 actions 18 ([2e2cc8d](https://github.com/cloudcome/oas-gen-ts/commit/2e2cc8df910ea94aec4379e162afc92dc65df5cd)) -* 优化 actions 19 ([c62b53b](https://github.com/cloudcome/oas-gen-ts/commit/c62b53b03d9eda210fa0e4dada90fb4a9942e9fb)) -* 优化 actions 20 ([ccd0358](https://github.com/cloudcome/oas-gen-ts/commit/ccd035894690b2dc2471fe02b7ccd4d2dfb45159)) - -## [0.6.10](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.9...v0.6.10) (2023-03-16) +- 优化 actions 11 ([5c3578f](https://github.com/FrontEndDev-org/openapi-axios/commit/5c3578f51b441027e804463fcde6f2cfc44b1c9a)) +- 优化 actions 12 ([a684fae](https://github.com/FrontEndDev-org/openapi-axios/commit/a684faee7cdfdbfe4812bf2b0df7f6933a7231be)) +- 优化 actions 13 ([99ec84b](https://github.com/FrontEndDev-org/openapi-axios/commit/99ec84b4f29b01f8c49a271b660d6370d16ec236)) +- 优化 actions 14 ([793c5ef](https://github.com/FrontEndDev-org/openapi-axios/commit/793c5ef9a085607154a0b0c1d12aebc1203d6c7f)) +- 优化 actions 15 ([ddc496a](https://github.com/FrontEndDev-org/openapi-axios/commit/ddc496a93fa83040822c12e3bb8cd9a544c4ceec)) +- 优化 actions 16 ([b28bc1d](https://github.com/FrontEndDev-org/openapi-axios/commit/b28bc1d5c625bbe394c1c0f141700ed01a6c2627)) +- 优化 actions 17 ([99a2d7d](https://github.com/FrontEndDev-org/openapi-axios/commit/99a2d7dc8f5b67f2d8fbfb3433b40c6d05a28c26)) +- 优化 actions 18 ([2e2cc8d](https://github.com/FrontEndDev-org/openapi-axios/commit/2e2cc8df910ea94aec4379e162afc92dc65df5cd)) +- 优化 actions 19 ([c62b53b](https://github.com/FrontEndDev-org/openapi-axios/commit/c62b53b03d9eda210fa0e4dada90fb4a9942e9fb)) +- 优化 actions 20 ([ccd0358](https://github.com/FrontEndDev-org/openapi-axios/commit/ccd035894690b2dc2471fe02b7ccd4d2dfb45159)) +## [0.6.10](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.9...v0.6.10) (2023-03-16) ### Bug Fixes -* 优化 actions 10 ([bef504d](https://github.com/cloudcome/oas-gen-ts/commit/bef504db38bc1103aa3a5973bc66ce001dca0da0)) - -## [0.6.9](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.8...v0.6.9) (2023-03-16) +- 优化 actions 10 ([bef504d](https://github.com/FrontEndDev-org/openapi-axios/commit/bef504db38bc1103aa3a5973bc66ce001dca0da0)) +## [0.6.9](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.8...v0.6.9) (2023-03-16) ### Bug Fixes -* 优化 actions 8 ([445bbfb](https://github.com/cloudcome/oas-gen-ts/commit/445bbfb756aaf5c6909c9e7c54ce83525e444986)) -* 优化 actions 9 ([e19df0e](https://github.com/cloudcome/oas-gen-ts/commit/e19df0e0c4e14b64e90a06061ab7d3293262d19f)) - -## [0.6.8](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.7...v0.6.8) (2023-03-16) +- 优化 actions 8 ([445bbfb](https://github.com/FrontEndDev-org/openapi-axios/commit/445bbfb756aaf5c6909c9e7c54ce83525e444986)) +- 优化 actions 9 ([e19df0e](https://github.com/FrontEndDev-org/openapi-axios/commit/e19df0e0c4e14b64e90a06061ab7d3293262d19f)) +## [0.6.8](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.7...v0.6.8) (2023-03-16) ### Bug Fixes -* 优化 actions 7 ([ceef4a3](https://github.com/cloudcome/oas-gen-ts/commit/ceef4a34409d3282584798cd7fbebfa0927dfb77)) - -## [0.6.7](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.6...v0.6.7) (2023-03-16) +- 优化 actions 7 ([ceef4a3](https://github.com/FrontEndDev-org/openapi-axios/commit/ceef4a34409d3282584798cd7fbebfa0927dfb77)) +## [0.6.7](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.6...v0.6.7) (2023-03-16) ### Bug Fixes -* 优化 actions 6 ([ba41765](https://github.com/cloudcome/oas-gen-ts/commit/ba4176578e04b8165b0cd8ffbd5b21d31bb8468b)) - -## [0.6.6](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.5...v0.6.6) (2023-03-16) +- 优化 actions 6 ([ba41765](https://github.com/FrontEndDev-org/openapi-axios/commit/ba4176578e04b8165b0cd8ffbd5b21d31bb8468b)) +## [0.6.6](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.5...v0.6.6) (2023-03-16) ### Bug Fixes -* 优化 actions 5 ([89f8dab](https://github.com/cloudcome/oas-gen-ts/commit/89f8dab3981101dc45f8fd412ef7094d6bb41e6e)) - -## [0.6.5](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.4...v0.6.5) (2023-03-16) +- 优化 actions 5 ([89f8dab](https://github.com/FrontEndDev-org/openapi-axios/commit/89f8dab3981101dc45f8fd412ef7094d6bb41e6e)) +## [0.6.5](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.4...v0.6.5) (2023-03-16) ### Bug Fixes -* 优化 actions 4 ([0243519](https://github.com/cloudcome/oas-gen-ts/commit/02435193e92ed67138ab55ea8e9da0b4f73ab04f)) - -## [0.6.4](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.3...v0.6.4) (2023-03-16) +- 优化 actions 4 ([0243519](https://github.com/FrontEndDev-org/openapi-axios/commit/02435193e92ed67138ab55ea8e9da0b4f73ab04f)) +## [0.6.4](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.3...v0.6.4) (2023-03-16) ### Bug Fixes -* 优化 actions 2 ([c24b6e5](https://github.com/cloudcome/oas-gen-ts/commit/c24b6e5801dd8bb3f7aeb2f3e214d145d91a1944)) -* 优化 actions 3 ([bd6de15](https://github.com/cloudcome/oas-gen-ts/commit/bd6de15d7dbbbcf411facb068d413330ac84f29b)) - -## [0.6.3](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.2...v0.6.3) (2023-03-16) +- 优化 actions 2 ([c24b6e5](https://github.com/FrontEndDev-org/openapi-axios/commit/c24b6e5801dd8bb3f7aeb2f3e214d145d91a1944)) +- 优化 actions 3 ([bd6de15](https://github.com/FrontEndDev-org/openapi-axios/commit/bd6de15d7dbbbcf411facb068d413330ac84f29b)) +## [0.6.3](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.2...v0.6.3) (2023-03-16) ### Bug Fixes -* 优化 actions ([a153ae7](https://github.com/cloudcome/oas-gen-ts/commit/a153ae7b96d2612d0d4ef44eb5e1df75bbff559b)) - -## [0.6.2](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.1...v0.6.2) (2023-03-16) +- 优化 actions ([a153ae7](https://github.com/FrontEndDev-org/openapi-axios/commit/a153ae7b96d2612d0d4ef44eb5e1df75bbff559b)) +## [0.6.2](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.1...v0.6.2) (2023-03-16) ### Bug Fixes -* 触发 release ([e92a1dc](https://github.com/cloudcome/oas-gen-ts/commit/e92a1dc2a6eaa4a8834bef21b5a85a151c6c8478)) - -## [0.6.1](https://github.com/cloudcome/oas-gen-ts/compare/v0.6.0...v0.6.1) (2023-03-16) +- 触发 release ([e92a1dc](https://github.com/FrontEndDev-org/openapi-axios/commit/e92a1dc2a6eaa4a8834bef21b5a85a151c6c8478)) +## [0.6.1](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.6.0...v0.6.1) (2023-03-16) ### Bug Fixes -* 优化 badge ([048c95f](https://github.com/cloudcome/oas-gen-ts/commit/048c95fdcac5e61c3ed79a379e7f27ab0c545060)) -* 文档优化,触发 release-please ([d80950b](https://github.com/cloudcome/oas-gen-ts/commit/d80950b00d47ada37765a9216933e80de4046a6e)) -* 添加注释,触发 release please ([67714f5](https://github.com/cloudcome/oas-gen-ts/commit/67714f5adbd534580302fa07180575787ad11823)) -* 类型优化 ([8ca712d](https://github.com/cloudcome/oas-gen-ts/commit/8ca712d65711689ee59293820a5d31fe3d07de8d)) - -## [0.6.0](https://github.com/cloudcome/oas-gen-ts/compare/v0.5.0...v0.6.0) (2023-03-16) +- 优化 badge ([048c95f](https://github.com/FrontEndDev-org/openapi-axios/commit/048c95fdcac5e61c3ed79a379e7f27ab0c545060)) +- 文档优化,触发 release-please ([d80950b](https://github.com/FrontEndDev-org/openapi-axios/commit/d80950b00d47ada37765a9216933e80de4046a6e)) +- 添加注释,触发 release please ([67714f5](https://github.com/FrontEndDev-org/openapi-axios/commit/67714f5adbd534580302fa07180575787ad11823)) +- 类型优化 ([8ca712d](https://github.com/FrontEndDev-org/openapi-axios/commit/8ca712d65711689ee59293820a5d31fe3d07de8d)) +## [0.6.0](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.5.0...v0.6.0) (2023-03-16) ### Features -* 增强 helpers 实现,增加其单元测试 ([f060a77](https://github.com/cloudcome/oas-gen-ts/commit/f060a7748bb2db620ca2b82f863a4e781f7a2326)) -* 增强 helpers 实现,增加其单元测试 ([7e410e1](https://github.com/cloudcome/oas-gen-ts/commit/7e410e1a55a9041c997eac09bd4494181ac38ff9)) -* 完善大部分源代码的单元测试 ([5dc6106](https://github.com/cloudcome/oas-gen-ts/commit/5dc61060f1cfb312ba526d349b24f930dd688414)) -* 支持 dist sourceMap ([110768d](https://github.com/cloudcome/oas-gen-ts/commit/110768d3e4917ae52eee1feaa8e0d0290405d116)) - +- 增强 helpers 实现,增加其单元测试 ([f060a77](https://github.com/FrontEndDev-org/openapi-axios/commit/f060a7748bb2db620ca2b82f863a4e781f7a2326)) +- 增强 helpers 实现,增加其单元测试 ([7e410e1](https://github.com/FrontEndDev-org/openapi-axios/commit/7e410e1a55a9041c997eac09bd4494181ac38ff9)) +- 完善大部分源代码的单元测试 ([5dc6106](https://github.com/FrontEndDev-org/openapi-axios/commit/5dc61060f1cfb312ba526d349b24f930dd688414)) +- 支持 dist sourceMap ([110768d](https://github.com/FrontEndDev-org/openapi-axios/commit/110768d3e4917ae52eee1feaa8e0d0290405d116)) ### Bug Fixes -* 修复 Oas 类型联合错误 ([7bac37c](https://github.com/cloudcome/oas-gen-ts/commit/7bac37ccde5901dcdbdb322d05d9628b363998bb)) -* 兼容 JSON 配置文件 ([1a380fa](https://github.com/cloudcome/oas-gen-ts/commit/1a380faebb5ee323cb0bd0b2db419a560a5a9b0a)), closes [#48](https://github.com/cloudcome/oas-gen-ts/issues/48) - -## [0.5.0](https://github.com/cloudcome/oas-gen-ts/compare/v0.4.0...v0.5.0) (2023-03-15) +- 修复 Oas 类型联合错误 ([7bac37c](https://github.com/FrontEndDev-org/openapi-axios/commit/7bac37ccde5901dcdbdb322d05d9628b363998bb)) +- 兼容 JSON 配置文件 ([1a380fa](https://github.com/FrontEndDev-org/openapi-axios/commit/1a380faebb5ee323cb0bd0b2db419a560a5a9b0a)), closes [#48](https://github.com/FrontEndDev-org/openapi-axios/issues/48) +## [0.5.0](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.4.0...v0.5.0) (2023-03-15) ### Features -* chalk 降级为 4,因为需要兼容 cjs/esm 两种格式 ([d19dc80](https://github.com/cloudcome/oas-gen-ts/commit/d19dc801bbc8744223e5dd740380d2f934caa462)) -* 增加生成步骤提示 ([b0aad3a](https://github.com/cloudcome/oas-gen-ts/commit/b0aad3ae202c125caacdb3629556fd8122e2c2e1)) - -## [0.4.0](https://github.com/cloudcome/oas-gen-ts/compare/v0.3.0...v0.4.0) (2023-03-15) +- chalk 降级为 4,因为需要兼容 cjs/esm 两种格式 ([d19dc80](https://github.com/FrontEndDev-org/openapi-axios/commit/d19dc801bbc8744223e5dd740380d2f934caa462)) +- 增加生成步骤提示 ([b0aad3a](https://github.com/FrontEndDev-org/openapi-axios/commit/b0aad3ae202c125caacdb3629556fd8122e2c2e1)) +## [0.4.0](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.3.0...v0.4.0) (2023-03-15) ### Features -* 优化构建命令 ([b4e3584](https://github.com/cloudcome/oas-gen-ts/commit/b4e358400e0b50fd4f97c9fcf021fbd0620ae002)) -* 新增配置项 unwrapResponseData ([c2441b3](https://github.com/cloudcome/oas-gen-ts/commit/c2441b3ba87c82fd82d006126cb4228e163b2acb)) - +- 优化构建命令 ([b4e3584](https://github.com/FrontEndDev-org/openapi-axios/commit/b4e358400e0b50fd4f97c9fcf021fbd0620ae002)) +- 新增配置项 unwrapResponseData ([c2441b3](https://github.com/FrontEndDev-org/openapi-axios/commit/c2441b3ba87c82fd82d006126cb4228e163b2acb)) ### Bug Fixes -* 生成文件目录可能为空的问题 ([ab33280](https://github.com/cloudcome/oas-gen-ts/commit/ab33280a800a9231e91cd8bd733b5b48e236f90f)) - -## [0.3.0](https://github.com/cloudcome/oas-gen-ts/compare/v0.2.0...v0.3.0) (2023-03-15) +- 生成文件目录可能为空的问题 ([ab33280](https://github.com/FrontEndDev-org/openapi-axios/commit/ab33280a800a9231e91cd8bd733b5b48e236f90f)) +## [0.3.0](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.2.0...v0.3.0) (2023-03-15) ### Features -* init project ([a5b8ed4](https://github.com/cloudcome/oas-gen-ts/commit/a5b8ed4db3fcad45b859364fe4aaf62a2b8cd768)) -* 增加编译命令 ([34c49a1](https://github.com/cloudcome/oas-gen-ts/commit/34c49a125c7f3d3d81150db03202ecf78ded256f)) -* 实现基本功能 ([6b932f8](https://github.com/cloudcome/oas-gen-ts/commit/6b932f89976625047e228558e05f2bb18d6e23ac)) - -## [0.2.0](https://github.com/cloudcome/oas-gen-ts/compare/v0.1.4...v0.2.0) (2023-03-15) +- init project ([a5b8ed4](https://github.com/FrontEndDev-org/openapi-axios/commit/a5b8ed4db3fcad45b859364fe4aaf62a2b8cd768)) +- 增加编译命令 ([34c49a1](https://github.com/FrontEndDev-org/openapi-axios/commit/34c49a125c7f3d3d81150db03202ecf78ded256f)) +- 实现基本功能 ([6b932f8](https://github.com/FrontEndDev-org/openapi-axios/commit/6b932f89976625047e228558e05f2bb18d6e23ac)) +## [0.2.0](https://github.com/FrontEndDev-org/openapi-axios/compare/v0.1.4...v0.2.0) (2023-03-15) ### Features -* rename oas_ts -> oas-gen-ts ([b00efb0](https://github.com/cloudcome/oas-gen-ts/commit/b00efb0277110da57dffa52c0960dad4d54f68c5)) +- rename oas_ts -> openapi-axios ([b00efb0](https://github.com/FrontEndDev-org/openapi-axios/commit/b00efb0277110da57dffa52c0960dad4d54f68c5)) ## [0.1.4](https://github.com/cloudcome/oas_ts/compare/v0.1.3...v0.1.4) (2023-03-15) - ### Bug Fixes -* publish 条件 6 ([6bbfffd](https://github.com/cloudcome/oas_ts/commit/6bbfffdc2d5387a186abb7a819908b31cb29a828)) +- publish 条件 6 ([6bbfffd](https://github.com/cloudcome/oas_ts/commit/6bbfffdc2d5387a186abb7a819908b31cb29a828)) ## [0.1.3](https://github.com/cloudcome/oas_ts/compare/v0.1.2...v0.1.3) (2023-03-15) - ### Bug Fixes -* publish 条件 5 ([61bc4ab](https://github.com/cloudcome/oas_ts/commit/61bc4abbc8bf25fcb9703ed37b19d88da933b2fb)) +- publish 条件 5 ([61bc4ab](https://github.com/cloudcome/oas_ts/commit/61bc4abbc8bf25fcb9703ed37b19d88da933b2fb)) ## [0.1.2](https://github.com/cloudcome/oas_ts/compare/v0.1.1...v0.1.2) (2023-03-15) - ### Bug Fixes -* publish 条件 4 ([7bf06f6](https://github.com/cloudcome/oas_ts/commit/7bf06f6ff93aadbad8816a0ad16f4ff2d9c814ce)) +- publish 条件 4 ([7bf06f6](https://github.com/cloudcome/oas_ts/commit/7bf06f6ff93aadbad8816a0ad16f4ff2d9c814ce)) ## [0.1.1](https://github.com/cloudcome/oas_ts/compare/v0.1.0...v0.1.1) (2023-03-15) - ### Bug Fixes -* npm publish 指定仓库 ([b438e99](https://github.com/cloudcome/oas_ts/commit/b438e994ed1c694def97209c4078c4021346b140)) -* publish 条件 ([51a0f08](https://github.com/cloudcome/oas_ts/commit/51a0f080b8d65c5470daab1b5035f52c28f59972)) -* publish 条件 ([c3f615a](https://github.com/cloudcome/oas_ts/commit/c3f615a79c9b4234f95b1c41a35ef459f3e5932f)) -* publish 条件 2 ([480611d](https://github.com/cloudcome/oas_ts/commit/480611d0fc38ad320578620f6d18491778524850)) -* publish 条件 3 ([5e1e75f](https://github.com/cloudcome/oas_ts/commit/5e1e75f75343799fc5a2273fa6ef60bba8ac7535)) -* update README.md ([d7f5856](https://github.com/cloudcome/oas_ts/commit/d7f5856d868001fe3f099b8ee0aa564a49ca2c70)) +- npm publish 指定仓库 ([b438e99](https://github.com/cloudcome/oas_ts/commit/b438e994ed1c694def97209c4078c4021346b140)) +- publish 条件 ([51a0f08](https://github.com/cloudcome/oas_ts/commit/51a0f080b8d65c5470daab1b5035f52c28f59972)) +- publish 条件 ([c3f615a](https://github.com/cloudcome/oas_ts/commit/c3f615a79c9b4234f95b1c41a35ef459f3e5932f)) +- publish 条件 2 ([480611d](https://github.com/cloudcome/oas_ts/commit/480611d0fc38ad320578620f6d18491778524850)) +- publish 条件 3 ([5e1e75f](https://github.com/cloudcome/oas_ts/commit/5e1e75f75343799fc5a2273fa6ef60bba8ac7535)) +- update README.md ([d7f5856](https://github.com/cloudcome/oas_ts/commit/d7f5856d868001fe3f099b8ee0aa564a49ca2c70)) ## [0.1.0](https://github.com/cloudcome/oas_ts/compare/v0.0.0...v0.1.0) (2023-03-15) - ### Features -* 排除指定版本 ([53bba08](https://github.com/cloudcome/oas_ts/commit/53bba08e52df8c056248569ec2bbc980f4751a49)) +- 排除指定版本 ([53bba08](https://github.com/cloudcome/oas_ts/commit/53bba08e52df8c056248569ec2bbc980f4751a49)) ## 0.0.0 (2023-03-15) - ### Features -* test github workflow ([51bb312](https://github.com/cloudcome/oas_ts/commit/51bb312415b5b4144b51a290169bf4fc5daee515)) -* 指定版本为 0.0.0 ([f330210](https://github.com/cloudcome/oas_ts/commit/f3302103f029c9be694717c5897c2944d994099c)) - +- test github workflow ([51bb312](https://github.com/cloudcome/oas_ts/commit/51bb312415b5b4144b51a290169bf4fc5daee515)) +- 指定版本为 0.0.0 ([f330210](https://github.com/cloudcome/oas_ts/commit/f3302103f029c9be694717c5897c2944d994099c)) ### Bug Fixes -* test GitHub workflow 15 ([801f519](https://github.com/cloudcome/oas_ts/commit/801f5190994a72525a78c246960e0d694602202a)) +- test GitHub workflow 15 ([801f519](https://github.com/cloudcome/oas_ts/commit/801f5190994a72525a78c246960e0d694602202a)) diff --git a/README.md b/README.md index c1c139a..95db63e 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,42 @@ -# oas-gen-ts +# openapi-axios -[![code-review](https://github.com/cloudcome/oas-gen-ts/actions/workflows/code-review.yml/badge.svg)](https://github.com/cloudcome/oas-gen-ts/actions/workflows/code-review.yml) -[![dependency-review](https://github.com/cloudcome/oas-gen-ts/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/cloudcome/oas-gen-ts/actions/workflows/dependency-review.yml) -[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/cloudcome/oas-gen-ts/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) -[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/cloudcome/oas-gen-ts/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) -![npm](https://img.shields.io/npm/v/oas-gen-ts) -![release](https://img.shields.io/github/v/release/cloudcome/oas-gen-ts) -![license](https://img.shields.io/github/license/cloudcome/oas-gen-ts) +[![code-review](https://github.com/FrontEndDev-org/openapi-axios/actions/workflows/code-review.yml/badge.svg)](https://github.com/FrontEndDev-org/openapi-axios/actions/workflows/code-review.yml) +[![dependency-review](https://github.com/FrontEndDev-org/openapi-axios/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/FrontEndDev-org/openapi-axios/actions/workflows/dependency-review.yml) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/FrontEndDev-org/openapi-axios/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e788387e5e27472ba3b5003bf19aeea7)](https://app.codacy.com/gh/FrontEndDev-org/openapi-axios/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) +![npm](https://img.shields.io/npm/v/openapi-axios) +![release](https://img.shields.io/github/v/release/FrontEndDev-org/openapi-axios) +![license](https://img.shields.io/github/license/FrontEndDev-org/openapi-axios) -OpenAPI Specification ➡️ TypeScript +OpenAPI ➡️ Axios -Convert OpenAPI Specification declaration files into type declarations and executable functions. Compared with other similar tools, it has the following characteristics +将 OpenAPI 规范声明文件转换为类型声明和可执行函数(基于 Axios)。与其他同类工具相比,具有以下特点 -- Each API is a function for easy tree shaking at build time -- Easily integrate with local request clients, such as Axios instances created in local projects -- Easy to use, easy to learn, type safe +- 每个 API 都是一个函数,用于在构建时轻松进行 tree shaking +- 轻松与本地请求客户端集成,例如在本地项目中创建的 Axios 实例 +- 易于使用,易于学习,类型安全 # Install ```shell -npm i -D oas-gen-ts +npm i -D openapi-axios ``` or ```shell -yarn add --dev oas-gen-ts +yarn add --dev openapi-axios ``` # Usage ## CLI -Create oas.config.js or oas.json in the root directory of the project. The search order for configuration files is `oas.config.cjs`, `oas.config.js`, `oas.json`. +在项目根目录下创建配置文件,配置文件的搜索顺序是 `openapi.config.cjs`、`openapi.config.js`、`openapi.json`。 ```js -// oas.config.cjs -const { defineConfig } = require('oas-gen-ts'); +// openapi.config.cjs +const { defineConfig } = require('openapi-axios'); module.exports = defineConfig({ list: [ @@ -49,13 +49,13 @@ module.exports = defineConfig({ ``` ```shell -# Generate typescript files based on configuration files -npx oas-gen-ts +# 根据配置文件生成typescript文件 +npx openapi-axios -# The `src/apis/swagger/pet.ts` file will be generated +# 将生成 `src/apis/swagger/pet.ts` 文件 ``` -The generated file will be exported as one function and one operation, like this: +生成的文件将导出为一个函数和一个操作,如下所示: ```ts // src/apis/swagger/pet.ts @@ -109,7 +109,7 @@ export async function findPetsByStatus( // ... ``` -Then you can directly import a function and use it. Calling an interface is as simple as calling a local function, is it similar to RPC (remote procedure call). +然后你可以直接导入一个函数并使用它。 调用接口就像调用本地函数一样简单,是不是类似于 RPC(remote procedure call)。 ```ts import { findPetsByStatus } from '@/apis/swagger/pet'; @@ -123,7 +123,7 @@ const pets = await findPetsByStatus({ ## API ```ts -import { generate } from 'oas-gen-ts'; +import { generate } from 'openapi-axios'; generate({ // ...config @@ -132,21 +132,22 @@ generate({ # Config -| Name | Type | Required | Description | Default | -| -------------------- | ----------- | -------- | ------------------------------------------ | ----------------------------------------------- | -| `cwd` | `string` | `false` | current working directory | `process.cwd()` | -| `dest` | `string` | `false` | Destination directory for generated files | `src/apis` | -| `axiosImport` | `string` | `false` | axios import string | Import from the official and create an instance | -| `unwrapResponseData` | `boolean` | `false` | unwrap the data item from the response | `false` | -| `list` | `OasItem[]` | `false` | List of OpenAPI Specification declarations | `[]` | - -`OasItem`: - -| Name | Type | Required | Description | Default | -| ------------- | -------- | -------- | ----------------------------------------------- | ----------------------------------------------- | -| `name` | `string` | `true` | filename, which can be a path | `process.cwd()` | -| `axiosImport` | `string` | `false` | axios import string, highest priority | Import from the official and create an instance | -| `url` | `string` | `false` | The remote address of the OpenAPI Specification | `undefined` | -| `spec` | `Spec` | `false` | The local Objects of the OpenAPI Specification | `undefined` | - -**At least one of `url` and `spec` exists** +| 参数名 | 类型 | 可选性 | 描述 | 默认值 | +| -------------------- | --------------- | ------- | --------------------------------------------------------------------------------- | ----------------------------------------------- | +| `cwd` | `string` | `false` | 当前工作路径 | `process.cwd()` | +| `dest` | `string` | `false` | 目标目录 | `src/apis` | +| `axiosImport` | `string` | `false` | axios 导入内容 | 默认从官方 Axios 导入,可以使用自己实现的客户端 | +| `unwrapResponseData` | `boolean` | `false` | 是否取消对 axios response 的包裹(即直接返回 ResponseData,而不是 AxiosResponse) | `false` | +| `list` | `OpenApiSpec[]` | `false` | OpenAPI 规范声明列表 | | +| `[]` | | | | | + +`OpenApiSpec` 签名: + +| 名称 | 类型 | 可选项 | 描述 | 默认值 | +| ------------- | -------- | ------- | -------------------------------------- | --------------- | +| `name` | `string` | `true` | 文件名,可以包含路径,相当于 dest 配置 | `process.cwd()` | +| `axiosImport` | `string` | `false` | axios 导入内容,优先级更高 | 无 | +| `url` | `string` | `false` | 远程 openApi 描述地址 | `undefined` | +| `spec` | `Spec` | `false` | 本地 OpenApi 描述文件 | `undefined` | + +备注:`url` 属性和 `spec` 属性,至少有一个必须。 diff --git a/package-lock.json b/package-lock.json index 025eb2e..23e86c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "oas-gen-ts", + "name": "openapi-axios", "version": "0.6.27", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "oas-gen-ts", + "name": "openapi-axios", "version": "0.6.27", "license": "MIT", "dependencies": { @@ -14,7 +14,7 @@ "swagger-typescript-api": "^12.0.3" }, "bin": { - "oas-gen-ts": "bin/index.cjs" + "openapi-axios": "bin/index.cjs" }, "devDependencies": { "@commitlint/cli": "^17.4.4", diff --git a/package.json b/package.json index f282599..d4bdd77 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "oas-gen-ts", + "name": "openapi-axios", "version": "0.6.27", - "description": "OpenAPI Specification ➡️ TypeScript", + "description": "OpenAPI ➡️ Axios", "scripts": { "prepare": "husky install", "lint": "eslint src/**/*.ts && tsc --project tsconfig.json --noEmit", @@ -33,7 +33,7 @@ "./package.json": "./package.json" }, "bin": { - "oas-gen-ts": "bin/index.cjs" + "openapi-axios": "bin/index.cjs" }, "files": [ "dist-cjs", @@ -44,14 +44,15 @@ "keywords": [ "cloudcome", "ydr.me", - "OpenAPI Specification", + "OpenAPI", + "swagger", "TypeScript", "OAS", "axios" ], "author": "publish-node-package-action", - "homepage": "https://github.com/cloudcome/oas-gen-ts", - "repository": "https://github.com/cloudcome/oas-gen-ts", + "homepage": "https://github.com/FrontEndDev-org/openapi-axios", + "repository": "https://github.com/FrontEndDev-org/openapi-axios", "license": "MIT", "dependencies": { "chalk": "^4.1.2", diff --git a/src/const.ts b/src/const.ts index 9e155a6..b01d9fc 100644 --- a/src/const.ts +++ b/src/const.ts @@ -5,4 +5,4 @@ const dirname = __dirname; export const templatesDir = path.join(dirname, '../templates'); export const axiosImportDefault = `import { Axios } from 'axios'; const axios = new Axios();`; -export const helpersImport = `import { formatHeaders, formatBody } from 'oas-gen-ts/helpers';`; +export const helpersImport = `import { formatHeaders, formatBody } from 'openapi-axios/helpers';`; diff --git a/src/generator.ts b/src/generator.ts index a0cad2d..253446a 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -2,16 +2,23 @@ import fs from 'fs/promises'; import path from 'path'; import { generateApi } from 'swagger-typescript-api'; import { axiosImportDefault, helpersImport, templatesDir } from './const'; -import { Generated, GeneratedCallback, OasItem, OasItemAsSpec, OasItemAsUrl, StrictConfig } from './types'; +import { + Generated, + GeneratedCallback, + OpenApiSpec, + OpenApiSpecAsLocal, + OpenApiSpecAsRemote, + StrictConfig, +} from './types'; -export async function generateItem(oasItem: OasItem, config: StrictConfig): Promise { +export async function generateItem(oasItem: OpenApiSpec, config: StrictConfig): Promise { const { name, axiosImport: axiosImportScope } = oasItem; const { cwd, dest, axiosImport: axiosImportGlobal, unwrapResponseData } = config; const axiosImport = axiosImportScope || axiosImportGlobal || axiosImportDefault; const { files } = await generateApi({ name, - url: (oasItem as OasItemAsUrl).url, - spec: (oasItem as OasItemAsSpec).spec, + url: (oasItem as OpenApiSpecAsRemote).url, + spec: (oasItem as OpenApiSpecAsLocal).spec, output: false, httpClientType: 'axios', templates: templatesDir, diff --git a/src/types.ts b/src/types.ts index 66c8b14..b3dbef4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -interface OasItemBase { +interface OpenApiSpecBase { name: string; /** @@ -10,17 +10,17 @@ interface OasItemBase { axiosImport?: string; } -export interface OasItemAsUrl extends OasItemBase { +export interface OpenApiSpecAsRemote extends OpenApiSpecBase { url: string; } export type Spec = import('swagger-schema-official').Spec; -export interface OasItemAsSpec extends OasItemBase { +export interface OpenApiSpecAsLocal extends OpenApiSpecBase { spec: Spec; } -export type OasItem = OasItemAsUrl | OasItemAsSpec; +export type OpenApiSpec = OpenApiSpecAsRemote | OpenApiSpecAsLocal; export interface UserConfig { /** @@ -56,9 +56,9 @@ export interface UserConfig { onGenerated?: (generated: Generated) => any; /** - * oas 列表 + * OpenApiSpec 列表 */ - list: OasItem[]; + list: OpenApiSpec[]; } export type StrictConfig = Required; @@ -73,7 +73,7 @@ export enum ContentKind { export interface Generated { files: string[]; - oasItem: OasItem; + oasItem: OpenApiSpec; config: StrictConfig; }