Skip to content

Commit 94e8997

Browse files
csutorasrRobin Csutoras
andauthored
[typescript-angular] Add includeEndpointUrl option to include endpoint URLs in generated service comments (#22152)
Adds a new boolean option 'includeEndpointUrl' that, when enabled, includes endpoint URL information as JSDoc comments in generated service methods and interfaces. This helps developers quickly identify the HTTP method and path for each API operation. Co-authored-by: Robin Csutoras <[email protected]>
1 parent 552ab4c commit 94e8997

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
8383
public static final String RXJS_VERSION = "rxjsVersion";
8484
public static final String NGPACKAGR_VERSION = "ngPackagrVersion";
8585
public static final String ZONEJS_VERSION = "zonejsVersion";
86+
public static final String INCLUDE_ENDPOINT_URL = "includeEndpointUrl";
8687

8788
protected String ngVersion = "20.0.0";
8889
@Getter @Setter
@@ -155,6 +156,7 @@ public TypeScriptAngularClientCodegen() {
155156
this.cliOptions.add(new CliOption(RXJS_VERSION, "The version of RxJS compatible with Angular (see ngVersion option)."));
156157
this.cliOptions.add(new CliOption(NGPACKAGR_VERSION, "The version of ng-packagr compatible with Angular (see ngVersion option)."));
157158
this.cliOptions.add(new CliOption(ZONEJS_VERSION, "The version of zone.js compatible with Angular (see ngVersion option)."));
159+
this.cliOptions.add(CliOption.newBoolean(INCLUDE_ENDPOINT_URL, "Include endpoint URL as comment in generated service methods.", false));
158160
}
159161

160162
@Override
@@ -309,6 +311,11 @@ public void processOpts() {
309311
additionalProperties.put("isQueryParamObjectFormatJson", getQueryParamObjectFormatJson());
310312
additionalProperties.put("isQueryParamObjectFormatKey", getQueryParamObjectFormatKey());
311313

314+
if (additionalProperties.containsKey(INCLUDE_ENDPOINT_URL)) {
315+
boolean includeEndpointUrl = Boolean.parseBoolean(additionalProperties.get(INCLUDE_ENDPOINT_URL).toString());
316+
additionalProperties.put(INCLUDE_ENDPOINT_URL, includeEndpointUrl);
317+
}
318+
312319
}
313320

314321
@Data

modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ export class {{classname}} extends BaseService {
7474
{{#notes}}
7575
* {{.}}
7676
{{/notes}}
77+
{{#includeEndpointUrl}}
78+
* @endpoint {{httpMethod}} {{{path}}}
79+
{{/includeEndpointUrl}}
7780
{{^useSingleRequestParameter}}
7881
{{#allParams}}
7982
* @param {{paramName}} {{description}}

modules/openapi-generator/src/main/resources/typescript-angular/apiInterface.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export interface {{classname}}Interface {
3838
/**
3939
* {{summary}}
4040
* {{notes}}
41+
{{#includeEndpointUrl}}
42+
* @endpoint {{httpMethod}} {{{path}}}
43+
{{/includeEndpointUrl}}
4144
{{^useSingleRequestParameter}}
4245
{{#allParams}}* @param {{paramName}} {{description}}
4346
{{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}* @param requestParameters

0 commit comments

Comments
 (0)