@1szx1/vite-plugin-swagger2ts 1.0.17 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@ declare function LuchAdapter<T extends Record<string, any>>(httpInstance: Reques
15
15
  request: <U extends keyof T, M extends string & keyof T[U]>(url: U & string, method: M, param?: Get<T[U][M]["param" & keyof T[U][M]], M extends "get" ? "query" : "body"> | undefined, config?: (HttpRequestConfig<UniApp.RequestTask | UniApp.UploadTask | UniApp.DownloadTask> & {
16
16
  data?: Get<T[U][M]["param" & keyof T[U][M]], "body"> | undefined;
17
17
  params?: Get<T[U][M]["param" & keyof T[U][M]], "query"> | undefined;
18
+ path?: Get<T[U][M]["param" & keyof T[U][M]], "path"> | undefined;
18
19
  }) | undefined) => Promise<T[U][M]["response" & keyof T[U][M]]>;
19
20
  upload: <U_1 extends { [K in keyof T]: T[K] extends {
20
21
  post: any;
package/dist/adapters.js CHANGED
@@ -50,6 +50,8 @@ function axiosAdapter(httpInstance) {
50
50
  // src/adapters/luchRequest.ts
51
51
  function LuchAdapter(httpInstance) {
52
52
  async function request(url, method, param, config) {
53
+ if (config?.path)
54
+ url = mergeUrlParam(url, config.path);
53
55
  const response = await httpInstance.middleware({
54
56
  url,
55
57
  method: method.toUpperCase(),
package/dist/adapters.mjs CHANGED
@@ -23,6 +23,8 @@ function axiosAdapter(httpInstance) {
23
23
  // src/adapters/luchRequest.ts
24
24
  function LuchAdapter(httpInstance) {
25
25
  async function request(url, method, param, config) {
26
+ if (config?.path)
27
+ url = mergeUrlParam(url, config.path);
26
28
  const response = await httpInstance.middleware({
27
29
  url,
28
30
  method: method.toUpperCase(),
package/dist/index.js CHANGED
@@ -236,7 +236,12 @@ function convertObjPromise(docs) {
236
236
  function swagger2TsPlugin(userOptions) {
237
237
  const { swaggerUrl, output, formatDocs, formatSchema } = resolveOptions(userOptions);
238
238
  async function loadSwaggerSource() {
239
- const sources = await fetchUrl(`${swaggerUrl}/swagger-resources`);
239
+ let sources = [];
240
+ try {
241
+ sources = await fetchUrl(`${swaggerUrl}/swagger-resources`);
242
+ } catch (error) {
243
+ console.log("vite-plugin-swagger2ts doc error", error);
244
+ }
240
245
  let code = "";
241
246
  for (let i = 0; i < sources.length; i++) {
242
247
  const { url, name: docsName } = sources[i];
@@ -252,6 +257,7 @@ function swagger2TsPlugin(userOptions) {
252
257
  const apistrings = generateDocs(openapiDocs, { docsName, baseUrl: docs.basePath ?? "", formatSchema });
253
258
  code += apistrings;
254
259
  } catch (error) {
260
+ console.log("vite-plugin-swagger2ts convert error", error);
255
261
  }
256
262
  }
257
263
  const outputFile = (0, import_path2.resolve)(process.cwd(), output);
package/dist/index.mjs CHANGED
@@ -202,7 +202,12 @@ function convertObjPromise(docs) {
202
202
  function swagger2TsPlugin(userOptions) {
203
203
  const { swaggerUrl, output, formatDocs, formatSchema } = resolveOptions(userOptions);
204
204
  async function loadSwaggerSource() {
205
- const sources = await fetchUrl(`${swaggerUrl}/swagger-resources`);
205
+ let sources = [];
206
+ try {
207
+ sources = await fetchUrl(`${swaggerUrl}/swagger-resources`);
208
+ } catch (error) {
209
+ console.log("vite-plugin-swagger2ts doc error", error);
210
+ }
206
211
  let code = "";
207
212
  for (let i = 0; i < sources.length; i++) {
208
213
  const { url, name: docsName } = sources[i];
@@ -218,6 +223,7 @@ function swagger2TsPlugin(userOptions) {
218
223
  const apistrings = generateDocs(openapiDocs, { docsName, baseUrl: docs.basePath ?? "", formatSchema });
219
224
  code += apistrings;
220
225
  } catch (error) {
226
+ console.log("vite-plugin-swagger2ts convert error", error);
221
227
  }
222
228
  }
223
229
  const outputFile = resolve2(process.cwd(), output);
package/package.json CHANGED
@@ -1,103 +1,103 @@
1
- {
2
- "name": "@1szx1/vite-plugin-swagger2ts",
3
- "description": "fork for https://github.com/1SZX1/vite-plugin-swagger2ts",
4
- "version": "1.0.17",
5
- "license": "MIT",
6
- "author": "1SZX1 <2414126198@qq.com>",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/1SZX1/vite-plugin-swagger2ts"
10
- },
11
- "homepage": "https://github.com/1SZX1/vite-plugin-swagger2ts",
12
- "bugs": "https://github.com/1SZX1/vite-plugin-swagger2ts/issues",
13
- "files": [
14
- "dist"
15
- ],
16
- "exports": {
17
- ".": {
18
- "require": "./dist/index.js",
19
- "import": "./dist/index.mjs",
20
- "types": "./dist/index.d.ts"
21
- },
22
- "./adapters": {
23
- "require": "./dist/adapters.js",
24
- "import": "./dist/adapters.mjs",
25
- "types": "./dist/adapters.d.ts"
26
- }
27
- },
28
- "main": "dist/index.js",
29
- "module": "dist/index.mjs",
30
- "types": "index.d.ts",
31
- "typesVersions": {
32
- "*": {
33
- "*": [
34
- "./dist/*"
35
- ]
36
- }
37
- },
38
- "scripts": {
39
- "dev": "pnpm run build -- --watch --ignore-watch examples",
40
- "build": "tsup src/index.ts src/adapters.ts --dts --format cjs,esm",
41
- "prepublishOnly": "pnpm run build",
42
- "release": "pnpx git-ensure -a && pnpx bumpp --commit --tag --push",
43
- "demo:dev": "pnpm -C examples/demo run dev",
44
- "demo:build": "pnpm -C examples/demo run build",
45
- "demo:preview": "pnpm -C examples/demo run preview",
46
- "test": "jest",
47
- "lint": "eslint --fix --ext .ts ./",
48
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
49
- "preinstall": "npx only-allow pnpm"
50
- },
51
- "dependencies": {
52
- "cross-fetch": "^3.1.5",
53
- "openapi3-ts": "^2.0.2",
54
- "swagger2openapi": "^7.0.8"
55
- },
56
- "peerDependencies": {
57
- "vite": "^2.0.0"
58
- },
59
- "devDependencies": {
60
- "@antfu/eslint-config": "^0.6.6",
61
- "@commitlint/cli": "^12.1.4",
62
- "@commitlint/config-conventional": "^12.1.4",
63
- "@dcloudio/types": "^3.2.11",
64
- "@types/jest": "^26.0.24",
65
- "@types/node": "^14.18.12",
66
- "@typescript-eslint/eslint-plugin": "^4.33.0",
67
- "@typescript-eslint/parser": "^5.14.0",
68
- "axios": "^1.3.4",
69
- "conventional-changelog": "^3.1.25",
70
- "cz-conventional-changelog": "^3.3.0",
71
- "eslint": "^7.32.0",
72
- "husky": "^8.0.3",
73
- "jest": "^26.6.3",
74
- "jest-esbuild": "^0.1.6",
75
- "lint-staged": "^10.5.4",
76
- "luch-request": "^3.0.8",
77
- "rollup": "^2.70.0",
78
- "ts-node": "^9.1.1",
79
- "tsup": "^6.6.3",
80
- "typescript": "^4.6.2",
81
- "vite": "^2.8.6"
82
- },
83
- "lint-staged": {
84
- "*.{ts}": "eslint --fix --ext",
85
- "*.{ts,md}": "prettier --write"
86
- },
87
- "husky": {
88
- "hooks": {
89
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
90
- "pre-commit": "lint-staged"
91
- }
92
- },
93
- "commitlint": {
94
- "extends": [
95
- "@commitlint/config-conventional"
96
- ]
97
- },
98
- "config": {
99
- "commitizen": {
100
- "path": "./node_modules/cz-conventional-changelog"
101
- }
102
- }
1
+ {
2
+ "name": "@1szx1/vite-plugin-swagger2ts",
3
+ "description": "fork for https://github.com/1SZX1/vite-plugin-swagger2ts",
4
+ "version": "1.0.19",
5
+ "license": "MIT",
6
+ "author": "1SZX1 <2414126198@qq.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/1SZX1/vite-plugin-swagger2ts"
10
+ },
11
+ "homepage": "https://github.com/1SZX1/vite-plugin-swagger2ts",
12
+ "bugs": "https://github.com/1SZX1/vite-plugin-swagger2ts/issues",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "require": "./dist/index.js",
19
+ "import": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts"
21
+ },
22
+ "./adapters": {
23
+ "require": "./dist/adapters.js",
24
+ "import": "./dist/adapters.mjs",
25
+ "types": "./dist/adapters.d.ts"
26
+ }
27
+ },
28
+ "main": "dist/index.js",
29
+ "module": "dist/index.mjs",
30
+ "types": "index.d.ts",
31
+ "typesVersions": {
32
+ "*": {
33
+ "*": [
34
+ "./dist/*"
35
+ ]
36
+ }
37
+ },
38
+ "scripts": {
39
+ "dev": "pnpm run build -- --watch --ignore-watch examples",
40
+ "build": "tsup src/index.ts src/adapters.ts --dts --format cjs,esm",
41
+ "prepublishOnly": "pnpm run build",
42
+ "release": "pnpx git-ensure -a && pnpx bumpp --commit --tag --push",
43
+ "demo:dev": "pnpm -C examples/demo run dev",
44
+ "demo:build": "pnpm -C examples/demo run build",
45
+ "demo:preview": "pnpm -C examples/demo run preview",
46
+ "test": "jest",
47
+ "lint": "eslint --fix --ext .ts ./",
48
+ "version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
49
+ "preinstall": "npx only-allow pnpm"
50
+ },
51
+ "dependencies": {
52
+ "cross-fetch": "^3.1.5",
53
+ "openapi3-ts": "^2.0.2",
54
+ "swagger2openapi": "^7.0.8"
55
+ },
56
+ "peerDependencies": {
57
+ "vite": "^2.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "@antfu/eslint-config": "^0.6.6",
61
+ "@commitlint/cli": "^12.1.4",
62
+ "@commitlint/config-conventional": "^12.1.4",
63
+ "@dcloudio/types": "^3.2.11",
64
+ "@types/jest": "^26.0.24",
65
+ "@types/node": "^14.18.12",
66
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
67
+ "@typescript-eslint/parser": "^5.14.0",
68
+ "axios": "^1.3.4",
69
+ "conventional-changelog": "^3.1.25",
70
+ "cz-conventional-changelog": "^3.3.0",
71
+ "eslint": "^7.32.0",
72
+ "husky": "^8.0.3",
73
+ "jest": "^26.6.3",
74
+ "jest-esbuild": "^0.1.6",
75
+ "lint-staged": "^10.5.4",
76
+ "luch-request": "^3.0.8",
77
+ "rollup": "^2.70.0",
78
+ "ts-node": "^9.1.1",
79
+ "tsup": "^6.6.3",
80
+ "typescript": "^4.6.2",
81
+ "vite": "^2.8.6"
82
+ },
83
+ "lint-staged": {
84
+ "*.{ts}": "eslint --fix --ext",
85
+ "*.{ts,md}": "prettier --write"
86
+ },
87
+ "husky": {
88
+ "hooks": {
89
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
90
+ "pre-commit": "lint-staged"
91
+ }
92
+ },
93
+ "commitlint": {
94
+ "extends": [
95
+ "@commitlint/config-conventional"
96
+ ]
97
+ },
98
+ "config": {
99
+ "commitizen": {
100
+ "path": "./node_modules/cz-conventional-changelog"
101
+ }
102
+ }
103
103
  }