@fxri/swagger2api 1.1.13 → 1.2.1
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 +3 -1
- package/dist/cli.js +0 -0
- package/dist/templates/route-types.ejs +32 -32
- package/dist/templates/type-data-contract.ejs +15 -15
- package/package.json +18 -12
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fxri/swagger2api",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "基于 swagger-typescript-api,将 Swagger 文档自动转为 TypeScript 格式的 API 文件。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -16,18 +16,30 @@
|
|
|
16
16
|
"README.md",
|
|
17
17
|
"package.json"
|
|
18
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
|
+
},
|
|
19
30
|
"keywords": [
|
|
20
31
|
"swagger",
|
|
21
32
|
"typescript",
|
|
22
33
|
"api"
|
|
23
34
|
],
|
|
24
35
|
"dependencies": {
|
|
25
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.20.0",
|
|
26
37
|
"glob": "^11.0.3",
|
|
27
38
|
"prompts": "^2.4.2",
|
|
28
|
-
"swagger-typescript-api": "^13.
|
|
39
|
+
"swagger-typescript-api": "^13.12.6"
|
|
29
40
|
},
|
|
30
41
|
"devDependencies": {
|
|
42
|
+
"@fxri/toolkit": "^1.3.0",
|
|
31
43
|
"@types/node": "^20.19.21",
|
|
32
44
|
"@types/prompts": "^2.4.9",
|
|
33
45
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
@@ -37,9 +49,10 @@
|
|
|
37
49
|
"eslint": "^8.57.1",
|
|
38
50
|
"eslint-config-prettier": "^9.1.2",
|
|
39
51
|
"eslint-plugin-vue": "^9.33.0",
|
|
40
|
-
"tsup": "^8.5.
|
|
52
|
+
"tsup": "^8.5.1",
|
|
41
53
|
"typescript": "^5.9.3"
|
|
42
54
|
},
|
|
55
|
+
"packageManager": "pnpm@10.34.4",
|
|
43
56
|
"engines": {
|
|
44
57
|
"node": ">=20"
|
|
45
58
|
},
|
|
@@ -53,12 +66,5 @@
|
|
|
53
66
|
},
|
|
54
67
|
"bugs": {
|
|
55
68
|
"url": "https://github.com/fxri-net/swagger2api/issues"
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"dev": "pnpm build:debug && node ./dist/cli.js",
|
|
59
|
-
"build": "cross-env NODE_ENV=production tsup",
|
|
60
|
-
"build:debug": "cross-env NODE_ENV=development tsup --config tsup.dev.config.ts",
|
|
61
|
-
"release": "pnpm build && pnpm publish",
|
|
62
|
-
"api": "pnpm dev --axios --responses -q -rpi 0 -err"
|
|
63
69
|
}
|
|
64
|
-
}
|
|
70
|
+
}
|