swagger-typescript-api 13.11.2 → 13.12.0
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/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-C0d8cMi-.mjs → src-DNm4rxFm.mjs} +4 -4
- package/dist/src-DNm4rxFm.mjs.map +1 -0
- package/dist/{src-B2ssuwoK.cjs → src-t0Ockaa6.cjs} +4 -4
- package/dist/src-t0Ockaa6.cjs.map +1 -0
- package/package.json +1 -1
- package/templates/base/data-contracts.ejs +3 -0
- package/templates/base/enum-data-contract.ejs +10 -0
- package/templates/base/http-clients/axios-http-client.ejs +8 -0
- package/templates/base/http-clients/fetch-http-client.ejs +8 -0
- package/dist/src-B2ssuwoK.cjs.map +0 -1
- package/dist/src-C0d8cMi-.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-typescript-api",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.12.0",
|
|
4
4
|
"description": "Generate the API client for Fetch or Axios from an OpenAPI Specification",
|
|
5
5
|
"homepage": "https://github.com/acacode/swagger-typescript-api",
|
|
6
6
|
"bugs": "https://github.com/acacode/swagger-typescript-api/issues",
|
|
@@ -19,6 +19,9 @@ const dataContractTemplates = {
|
|
|
19
19
|
enum: (contract) => {
|
|
20
20
|
return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
|
|
21
21
|
},
|
|
22
|
+
'const enum': (contract) => {
|
|
23
|
+
return `const enum ${contract.name} {\r\n${contract.content} \r\n }`;
|
|
24
|
+
},
|
|
22
25
|
interface: (contract) => {
|
|
23
26
|
return `interface ${contract.name}${buildGenerics(contract)} {\r\n${contract.content}}`;
|
|
24
27
|
},
|
|
@@ -8,6 +8,16 @@ const { name, $content } = contract;
|
|
|
8
8
|
<%~ _.map($content, ({ key, value }) => `${key}: ${value}`).join(",\n ") %>
|
|
9
9
|
} as const;
|
|
10
10
|
export type <%~ name %> = (typeof <%~ name %>)[keyof typeof <%~ name %>];
|
|
11
|
+
<% } else if (config.enumStyle === "const-enum") { %>
|
|
12
|
+
export const enum <%~ name %> {
|
|
13
|
+
<%~ _.map($content, ({ key, value, description }) => {
|
|
14
|
+
let formattedDescription = description && formatDescription(description, true);
|
|
15
|
+
return [
|
|
16
|
+
formattedDescription && `/** ${formattedDescription} */`,
|
|
17
|
+
`${key} = ${value}`
|
|
18
|
+
].filter(Boolean).join("\n");
|
|
19
|
+
}).join(",\n") %>
|
|
20
|
+
}
|
|
11
21
|
<% } else if (config.enumStyle === "union") { %>
|
|
12
22
|
export type <%~ name %> = <%~ _.map($content, ({ value }) => value).join(" | ") %>
|
|
13
23
|
<% } else { %>
|
|
@@ -42,6 +42,14 @@ export const ContentType = {
|
|
|
42
42
|
export type ContentType = (typeof ContentType)[keyof typeof ContentType];
|
|
43
43
|
<% } else if (config.enumStyle === "union") { %>
|
|
44
44
|
export type ContentType = "application/json" | "application/vnd.api+json" | "multipart/form-data" | "application/x-www-form-urlencoded" | "text/plain";
|
|
45
|
+
<% } else if (config.enumStyle === "const-enum") { %>
|
|
46
|
+
export const enum ContentType {
|
|
47
|
+
Json = "application/json",
|
|
48
|
+
JsonApi = "application/vnd.api+json",
|
|
49
|
+
FormData = "multipart/form-data",
|
|
50
|
+
UrlEncoded = "application/x-www-form-urlencoded",
|
|
51
|
+
Text = "text/plain",
|
|
52
|
+
}
|
|
45
53
|
<% } else { %>
|
|
46
54
|
export enum ContentType {
|
|
47
55
|
Json = "application/json",
|
|
@@ -53,6 +53,14 @@ export const ContentType = {
|
|
|
53
53
|
export type ContentType = (typeof ContentType)[keyof typeof ContentType];
|
|
54
54
|
<% } else if (config.enumStyle === "union") { %>
|
|
55
55
|
export type ContentType = "application/json" | "application/vnd.api+json" | "multipart/form-data" | "application/x-www-form-urlencoded" | "text/plain";
|
|
56
|
+
<% } else if (config.enumStyle === "const-enum") { %>
|
|
57
|
+
export const enum ContentType {
|
|
58
|
+
Json = "application/json",
|
|
59
|
+
JsonApi = "application/vnd.api+json",
|
|
60
|
+
FormData = "multipart/form-data",
|
|
61
|
+
UrlEncoded = "application/x-www-form-urlencoded",
|
|
62
|
+
Text = "text/plain",
|
|
63
|
+
}
|
|
56
64
|
<% } else { %>
|
|
57
65
|
export enum ContentType {
|
|
58
66
|
Json = "application/json",
|