@fxri/swagger2api 1.2.1 → 1.2.3
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.
- package/README.md +2 -2
- package/dist/templates/route-types.ejs +32 -32
- package/dist/templates/type-data-contract.ejs +15 -15
- package/package.json +70 -70
package/README.md
CHANGED
|
@@ -206,10 +206,10 @@ npx @fxri/swagger2api [--replace-tags,-rt <regexp> <substr>]
|
|
|
206
206
|
|
|
207
207
|
作者:唐启云 <tqy@fxri.net>
|
|
208
208
|
|
|
209
|
-
版权:Copyright © 2025 方弦研究所. All rights reserved.
|
|
209
|
+
版权:Copyright © 2025-2026 方弦研究所. All rights reserved.
|
|
210
210
|
|
|
211
211
|
网站:[方弦研究信息网](https://fxri.net:444/)
|
|
212
212
|
|
|
213
213
|
协议:[MIT License](./LICENSE)
|
|
214
214
|
|
|
215
|
-
商标:"
|
|
215
|
+
商标:"方弦®"为第42类注册商标(注册号89648411),本开源许可不授予商标使用权,详见 [TRADEMARK.md](./TRADEMARK.md)
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const { utils, config, routes, modelTypes } = it;
|
|
3
|
-
const { _, pascalCase } = utils;
|
|
4
|
-
const dataContracts = config.modular ? _.map(modelTypes, "name") : [];
|
|
5
|
-
%>
|
|
6
|
-
|
|
7
|
-
<% if (dataContracts.length) { %>
|
|
8
|
-
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
9
|
-
<% } %>
|
|
10
|
-
|
|
11
|
-
<%
|
|
12
|
-
/* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */
|
|
13
|
-
%>
|
|
14
|
-
|
|
15
|
-
<% if (routes.outOfModule) { %>
|
|
16
|
-
<% for (const { routes: outOfModuleRoutes = [] } of routes.outOfModule) { %>
|
|
17
|
-
<% for (const route of outOfModuleRoutes) { %>
|
|
18
|
-
<%~ includeFile('./route-type.ejs', { ...it, route }) %>
|
|
19
|
-
<% } %>
|
|
20
|
-
<% } %>
|
|
21
|
-
<% } %>
|
|
22
|
-
|
|
23
|
-
<% if (routes.combined) { %>
|
|
24
|
-
<% for (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %>
|
|
25
|
-
export namespace <%~ pascalCase(moduleName) %> {
|
|
26
|
-
<% for (const route of combinedRoutes) { %>
|
|
27
|
-
<%~ includeFile('./route-type.ejs', { ...it, route }) %>
|
|
28
|
-
<% } %>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
<% } %>
|
|
32
|
-
<% } %>
|
|
1
|
+
<%
|
|
2
|
+
const { utils, config, routes, modelTypes } = it;
|
|
3
|
+
const { _, pascalCase } = utils;
|
|
4
|
+
const dataContracts = config.modular ? _.map(modelTypes, "name") : [];
|
|
5
|
+
%>
|
|
6
|
+
|
|
7
|
+
<% if (dataContracts.length) { %>
|
|
8
|
+
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
9
|
+
<% } %>
|
|
10
|
+
|
|
11
|
+
<%
|
|
12
|
+
/* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */
|
|
13
|
+
%>
|
|
14
|
+
|
|
15
|
+
<% if (routes.outOfModule) { %>
|
|
16
|
+
<% for (const { routes: outOfModuleRoutes = [] } of routes.outOfModule) { %>
|
|
17
|
+
<% for (const route of outOfModuleRoutes) { %>
|
|
18
|
+
<%~ includeFile('./route-type.ejs', { ...it, route }) %>
|
|
19
|
+
<% } %>
|
|
20
|
+
<% } %>
|
|
21
|
+
<% } %>
|
|
22
|
+
|
|
23
|
+
<% if (routes.combined) { %>
|
|
24
|
+
<% for (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %>
|
|
25
|
+
export namespace <%~ pascalCase(moduleName) %> {
|
|
26
|
+
<% for (const route of combinedRoutes) { %>
|
|
27
|
+
<%~ includeFile('./route-type.ejs', { ...it, route }) %>
|
|
28
|
+
<% } %>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
<% } %>
|
|
32
|
+
<% } %>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const { contract, utils } = it;
|
|
3
|
-
const { formatDescription, require, _ } = utils;
|
|
4
|
-
|
|
5
|
-
%>
|
|
6
|
-
<% if (contract.$content.length) { %>
|
|
7
|
-
export type <%~ contract.name %> = {
|
|
8
|
-
<% for (const field of contract.$content) { %>
|
|
9
|
-
<%~ includeFile('./object-field-jsdoc.ejs', { ...it, field }) %>
|
|
10
|
-
<%~ field.field %>;
|
|
11
|
-
<% } %>
|
|
12
|
-
}<%~ utils.isNeedToAddNull(contract) ? ' | null' : ''%>
|
|
13
|
-
<% } else { %>
|
|
14
|
-
export type <%~ contract.name %> = Record<string, any>;
|
|
15
|
-
<% } %>
|
|
1
|
+
<%
|
|
2
|
+
const { contract, utils } = it;
|
|
3
|
+
const { formatDescription, require, _ } = utils;
|
|
4
|
+
|
|
5
|
+
%>
|
|
6
|
+
<% if (contract.$content.length) { %>
|
|
7
|
+
export type <%~ contract.name %> = {
|
|
8
|
+
<% for (const field of contract.$content) { %>
|
|
9
|
+
<%~ includeFile('./object-field-jsdoc.ejs', { ...it, field }) %>
|
|
10
|
+
<%~ field.field %>;
|
|
11
|
+
<% } %>
|
|
12
|
+
}<%~ utils.isNeedToAddNull(contract) ? ' | null' : ''%>
|
|
13
|
+
<% } else { %>
|
|
14
|
+
export type <%~ contract.name %> = Record<string, any>;
|
|
15
|
+
<% } %>
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fxri/swagger2api",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "基于 swagger-typescript-api,将 Swagger 文档自动转为 TypeScript 格式的 API 文件。",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "唐启云",
|
|
8
|
-
"email": "tqy@fxri.net",
|
|
9
|
-
"url": "https://fxri.net:444/"
|
|
10
|
-
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"main": "./dist/index.js",
|
|
13
|
-
"bin": "./dist/cli.js",
|
|
14
|
-
"files": [
|
|
15
|
-
"dist",
|
|
16
|
-
"README.md",
|
|
17
|
-
"package.json"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "pnpm build:debug && node ./dist/cli.js",
|
|
21
|
-
"build": "cross-env NODE_ENV=production tsup",
|
|
22
|
-
"build:debug": "cross-env NODE_ENV=development tsup --config tsup.dev.config.ts",
|
|
23
|
-
"release": "pnpm build && pnpm publish",
|
|
24
|
-
"api": "pnpm dev --axios --responses -q -rpi 0 -err",
|
|
25
|
-
"tasks": "toolkit tasks",
|
|
26
|
-
"tasks:archive": "toolkit tasks archive",
|
|
27
|
-
"changeset": "toolkit changelog",
|
|
28
|
-
"version": "toolkit changelog version"
|
|
29
|
-
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"swagger",
|
|
32
|
-
"typescript",
|
|
33
|
-
"api"
|
|
34
|
-
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"axios": "^1.20.0",
|
|
37
|
-
"glob": "^11.0.3",
|
|
38
|
-
"prompts": "^2.4.2",
|
|
39
|
-
"swagger-typescript-api": "^13.12.6"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@fxri/toolkit": "^1.
|
|
43
|
-
"@types/node": "^20.19.21",
|
|
44
|
-
"@types/prompts": "^2.4.9",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
46
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
47
|
-
"cross-env": "^10.1.0",
|
|
48
|
-
"esbuild-plugin-copy": "^2.1.1",
|
|
49
|
-
"eslint": "^8.57.1",
|
|
50
|
-
"eslint-config-prettier": "^9.1.2",
|
|
51
|
-
"eslint-plugin-vue": "^9.33.0",
|
|
52
|
-
"tsup": "^8.5.1",
|
|
53
|
-
"typescript": "^5.9.3"
|
|
54
|
-
},
|
|
55
|
-
"packageManager": "pnpm@10.34.4",
|
|
56
|
-
"engines": {
|
|
57
|
-
"node": ">=20"
|
|
58
|
-
},
|
|
59
|
-
"publishConfig": {
|
|
60
|
-
"registry": "https://registry.npmjs.org/"
|
|
61
|
-
},
|
|
62
|
-
"homepage": "https://github.com/fxri-net/swagger2api#readme",
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "git",
|
|
65
|
-
"url": "https://github.com/fxri-net/swagger2api.git"
|
|
66
|
-
},
|
|
67
|
-
"bugs": {
|
|
68
|
-
"url": "https://github.com/fxri-net/swagger2api/issues"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fxri/swagger2api",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "基于 swagger-typescript-api,将 Swagger 文档自动转为 TypeScript 格式的 API 文件。",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "唐启云",
|
|
8
|
+
"email": "tqy@fxri.net",
|
|
9
|
+
"url": "https://fxri.net:444/"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"bin": "./dist/cli.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"package.json"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "pnpm build:debug && node ./dist/cli.js",
|
|
21
|
+
"build": "cross-env NODE_ENV=production tsup",
|
|
22
|
+
"build:debug": "cross-env NODE_ENV=development tsup --config tsup.dev.config.ts",
|
|
23
|
+
"release": "pnpm build && pnpm publish",
|
|
24
|
+
"api": "pnpm dev --axios --responses -q -rpi 0 -err",
|
|
25
|
+
"tasks": "toolkit tasks",
|
|
26
|
+
"tasks:archive": "toolkit tasks archive",
|
|
27
|
+
"changeset": "toolkit changelog",
|
|
28
|
+
"version": "toolkit changelog version"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"swagger",
|
|
32
|
+
"typescript",
|
|
33
|
+
"api"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"axios": "^1.20.0",
|
|
37
|
+
"glob": "^11.0.3",
|
|
38
|
+
"prompts": "^2.4.2",
|
|
39
|
+
"swagger-typescript-api": "^13.12.6"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@fxri/toolkit": "^1.6.1",
|
|
43
|
+
"@types/node": "^20.19.21",
|
|
44
|
+
"@types/prompts": "^2.4.9",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
47
|
+
"cross-env": "^10.1.0",
|
|
48
|
+
"esbuild-plugin-copy": "^2.1.1",
|
|
49
|
+
"eslint": "^8.57.1",
|
|
50
|
+
"eslint-config-prettier": "^9.1.2",
|
|
51
|
+
"eslint-plugin-vue": "^9.33.0",
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"packageManager": "pnpm@10.34.4",
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=20"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"registry": "https://registry.npmjs.org/"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://github.com/fxri-net/swagger2api#readme",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/fxri-net/swagger2api.git"
|
|
66
|
+
},
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/fxri-net/swagger2api/issues"
|
|
69
|
+
}
|
|
70
|
+
}
|