Skip to content

Commit f9ab68d

Browse files
Copilotsmorimoto
andcommitted
Fix TypeScript syntax issue for operationIds starting with numbers
Co-authored-by: smorimoto <[email protected]>
1 parent b5055e9 commit f9ab68d

File tree

7 files changed

+193
-205
lines changed

7 files changed

+193
-205
lines changed

templates/default/api.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class <%~ config.apiClassName %><SecurityDataType extends unknown><% if (
5050
<% if (routes.outOfModule) { %>
5151
<% for (const route of routes.outOfModule) { %>
5252
53-
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
53+
<%~ includeFile('./procedure-call.ejs', { ...it, route, isObjectProperty: false }) %>
5454
5555
<% } %>
5656
<% } %>
@@ -60,7 +60,7 @@ export class <%~ config.apiClassName %><SecurityDataType extends unknown><% if (
6060
<%~ moduleName %> = {
6161
<% for (const route of combinedRoutes) { %>
6262
63-
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
63+
<%~ includeFile('./procedure-call.ejs', { ...it, route, isObjectProperty: true }) %>
6464
6565
<% } %>
6666
}

templates/default/procedure-call.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%
2-
const { utils, route, config } = it;
2+
const { utils, route, config, isObjectProperty = route.namespace } = it;
33
const { requestBodyInfo, responseBodyInfo, specificArgNameResolver } = route;
44
const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRef, require } = utils;
55
const { parameters, path, method, payload, query, formData, security, requestParams } = route.request;
@@ -90,7 +90,7 @@ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
9090
<%~ routeDocs.lines %>
9191

9292
*/
93-
<% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ route.namespace ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
93+
<% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ isObjectProperty ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ isObjectProperty ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
9494
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
9595
path: `<%~ path %>`,
9696
method: '<%~ _.upperCase(method) %>',

templates/modular/api.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ export class <%= apiClassName %><SecurityDataType = unknown><% if (!config.singl
2323
<% } %>
2424

2525
<% for (const route of routes) { %>
26-
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
26+
<%~ includeFile('./procedure-call.ejs', { ...it, route, isObjectProperty: false }) %>
2727
<% } %>
2828
}

templates/modular/procedure-call.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%
2-
const { utils, route, config } = it;
2+
const { utils, route, config, isObjectProperty = route.namespace } = it;
33
const { requestBodyInfo, responseBodyInfo, specificArgNameResolver } = route;
44
const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRef, require } = utils;
55
const { parameters, path, method, payload, query, formData, security, requestParams } = route.request;
@@ -90,7 +90,7 @@ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
9090
<%~ routeDocs.lines %>
9191

9292
*/
93-
<% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ route.namespace ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
93+
<% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ isObjectProperty ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ isObjectProperty ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
9494
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
9595
path: `<%~ path %>`,
9696
method: '<%~ _.upperCase(method) %>',

test-reproduction-issue.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

test-reproduction.js

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)