swagger-typescript-api 13.2.7 → 13.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "13.2.7",
3
+ "version": "13.2.8",
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",
@@ -47,8 +47,8 @@
47
47
  "typedoc": "typedoc"
48
48
  },
49
49
  "dependencies": {
50
- "@biomejs/js-api": "1.0.0",
51
- "@biomejs/wasm-nodejs": "2.0.5",
50
+ "@biomejs/js-api": "2.0.3",
51
+ "@biomejs/wasm-nodejs": "2.1.4",
52
52
  "@types/swagger-schema-official": "^2.0.25",
53
53
  "c12": "^3.0.4",
54
54
  "citty": "^0.1.6",
@@ -59,22 +59,22 @@
59
59
  "nanoid": "^5.1.5",
60
60
  "swagger-schema-official": "2.0.0-bab6bed",
61
61
  "swagger2openapi": "^7.0.8",
62
- "typescript": "~5.8.3"
62
+ "typescript": "~5.9.2"
63
63
  },
64
64
  "devDependencies": {
65
- "@biomejs/biome": "2.0.5",
65
+ "@biomejs/biome": "2.1.4",
66
66
  "@changesets/changelog-github": "0.5.1",
67
67
  "@changesets/cli": "2.29.5",
68
68
  "@tsconfig/node18": "18.2.4",
69
69
  "@tsconfig/strictest": "2.0.5",
70
70
  "@types/js-yaml": "4.0.9",
71
- "@types/lodash": "4.17.18",
72
- "@types/node": "24.0.4",
71
+ "@types/lodash": "4.17.20",
72
+ "@types/node": "24.2.0",
73
73
  "@types/swagger2openapi": "7.0.4",
74
- "axios": "1.10.0",
74
+ "axios": "1.11.0",
75
75
  "openapi-types": "12.1.3",
76
- "tsdown": "0.12.9",
77
- "typedoc": "0.28.5",
76
+ "tsdown": "0.13.4",
77
+ "typedoc": "0.28.9",
78
78
  "vitest": "3.2.4"
79
79
  },
80
80
  "packageManager": "yarn@4.9.2",
@@ -106,8 +106,12 @@ export class HttpClient<SecurityDataType = unknown> {
106
106
  [ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
107
107
  [ContentType.JsonApi]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
108
108
  [ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
109
- [ContentType.FormData]: (input: any) =>
110
- Object.keys(input || {}).reduce((formData, key) => {
109
+ [ContentType.FormData]: (input: any) => {
110
+ if (input instanceof FormData) {
111
+ return input;
112
+ }
113
+
114
+ return Object.keys(input || {}).reduce((formData, key) => {
111
115
  const property = input[key];
112
116
  formData.append(
113
117
  key,
@@ -118,7 +122,8 @@ export class HttpClient<SecurityDataType = unknown> {
118
122
  `${property}`
119
123
  );
120
124
  return formData;
121
- }, new FormData()),
125
+ }, new FormData());
126
+ },
122
127
  [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
123
128
  }
124
129
 
@@ -4,6 +4,7 @@ const { _, pascalCase, require } = utils;
4
4
  const { query, payload, pathParams, headers } = route.request;
5
5
 
6
6
  const routeDocs = includeFile("@base/route-docs", { config, route, utils });
7
+ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
7
8
  const routeNamespace = pascalCase(route.routeName.usage);
8
9
 
9
10
  %>
@@ -14,7 +15,7 @@ const routeNamespace = pascalCase(route.routeName.usage);
14
15
  <%~ routeDocs.lines %>
15
16
 
16
17
  */
17
- export namespace <%~ routeNamespace %> {
18
+ export namespace <% if (isValidIdentifier(routeNamespace)) { %><%~ routeNamespace %><% } else { %>"<%~ routeNamespace %>"<% } %> {
18
19
  export type RequestParams = <%~ (pathParams && pathParams.type) || '{}' %>;
19
20
  export type RequestQuery = <%~ (query && query.type) || '{}' %>;
20
21
  export type RequestBody = <%~ (payload && payload.type) || 'never' %>;
@@ -79,6 +79,8 @@ const describeReturnType = () => {
79
79
  }
80
80
  }
81
81
 
82
+ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
83
+
82
84
  %>
83
85
  /**
84
86
  <%~ routeDocs.description %>
@@ -88,7 +90,7 @@ const describeReturnType = () => {
88
90
  <%~ routeDocs.lines %>
89
91
 
90
92
  */
91
- <%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
93
+ <% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ route.namespace ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
92
94
  <%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
93
95
  path: `<%~ path %>`,
94
96
  method: '<%~ _.upperCase(method) %>',
@@ -79,6 +79,8 @@ const describeReturnType = () => {
79
79
  }
80
80
  }
81
81
 
82
+ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
83
+
82
84
  %>
83
85
  /**
84
86
  <%~ routeDocs.description %>
@@ -88,7 +90,7 @@ const describeReturnType = () => {
88
90
  <%~ routeDocs.lines %>
89
91
 
90
92
  */
91
- <%~ route.routeName.usage %> = (<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
93
+ <% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ route.namespace ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
92
94
  <%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
93
95
  path: `<%~ path %>`,
94
96
  method: '<%~ _.upperCase(method) %>',
@@ -98,4 +100,4 @@ const describeReturnType = () => {
98
100
  <%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %>
99
101
  <%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %>
100
102
  ...<%~ _.get(requestConfigParam, "name") %>,
101
- })
103
+ })<%~ route.namespace ? ',' : '' %>