Skip to content

Commit 5d12e71

Browse files
wing328Dirk Niemeier
andauthored
[typescript-rxjs] Feat: Add @deprecated JSDoc tag to API operations (#22419)
* feat(typescript-rxjs): Add @deprecated tag to generated API operations This commit introduces the JSDoc @deprecated tag to API operations in the typescript-rxjs generator when the operation is marked as deprecated in the OpenAPI specification. This ensures that IDEs (like VS Code or WebStorm) correctly flag the method as deprecated, providing better developer experience and warning consumers about upcoming removals or changes. * minor updates --------- Co-authored-by: Dirk Niemeier <[email protected]>
1 parent 5711f39 commit 5d12e71

File tree

10 files changed

+65
-25
lines changed

10 files changed

+65
-25
lines changed

modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export class {{classname}} extends BaseAPI {
3939
{{#summary}}
4040
* {{&summary}}
4141
{{/summary}}
42+
{{#isDeprecated}}
43+
* @deprecated
44+
{{/isDeprecated}}
4245
*/
4346
{{nickname}}({{#allParams.0}}{ {{#allParams}}{{paramName}}{{#vendorExtensions.x-param-name-alternative}}: {{vendorExtensions.x-param-name-alternative}}{{/vendorExtensions.x-param-name-alternative}}{{^-last}}, {{/-last}}{{/allParams}} }: {{operationIdCamelCase}}Request{{/allParams.0}}): Observable<{{{returnType}}}{{^returnType}}void{{/returnType}}>
4447
{{#withProgressSubscriber}}
@@ -244,4 +247,4 @@ export enum {{operationIdCamelCase}}{{enumName}} {
244247
{{/allParams}}
245248
{{/operation}}
246249
{{/operations}}
247-
{{/hasEnums}}
250+
{{/hasEnums}}

modules/openapi-generator/src/main/resources/typescript-rxjs/modelEnum.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* {{{description}}}
33
* @export
44
* @enum {string}
5+
{{#deprecated}}
6+
* @deprecated
7+
{{/deprecated}}
58
*/
69
export enum {{classname}} {
710
{{#allowableValues}}

modules/openapi-generator/src/main/resources/typescript-rxjs/modelGeneric.mustache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import type {
1010
* {{{.}}}{{/description}}
1111
* @export
1212
* @interface {{classname}}
13+
{{#deprecated}}
14+
* @deprecated
15+
{{/deprecated}}
1316
*/
1417
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
1518
{{#additionalPropertiesType}}
@@ -18,6 +21,9 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
1821
{{#vars}}
1922
/**{{#description}}
2023
* {{{.}}}{{/description}}
24+
{{#deprecated}}
25+
* @deprecated
26+
{{/deprecated}}
2127
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
2228
* @memberof {{classname}}
2329
*/
@@ -30,6 +36,9 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
3036
/**
3137
* @export
3238
* @enum {string}
39+
{{#deprecated}}
40+
* @deprecated
41+
{{/deprecated}}
3342
*/
3443
export enum {{classname}}{{enumName}} {
3544
{{#allowableValues}}

modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ public void allOfCompositionTest() {
564564
Assert.assertNotNull(superMan);
565565

566566
// to test all properties
567-
Assert.assertEquals(superMan.getVars().size(), 6);
568-
Assert.assertEquals(superMan.getAllVars().size(), 6);
567+
Assert.assertEquals(superMan.getVars().size(), 7);
568+
Assert.assertEquals(superMan.getAllVars().size(), 7);
569569
Assert.assertEquals(superMan.getMandatory().size(), 3);
570570
Assert.assertEquals(superMan.getAllMandatory().size(), 3);
571571

@@ -578,45 +578,55 @@ public void allOfCompositionTest() {
578578
Assert.assertFalse(cp1.required);
579579

580580
CodegenProperty cp2 = superMan.getVars().get(2);
581-
Assert.assertEquals(cp2.name, "reward");
581+
Assert.assertEquals(cp2.name, "nickname");
582582
Assert.assertFalse(cp2.required);
583+
Assert.assertTrue(cp2.deprecated);
583584

584585
CodegenProperty cp3 = superMan.getVars().get(3);
585-
Assert.assertEquals(cp3.name, "origin");
586-
Assert.assertTrue(cp3.required);
586+
Assert.assertEquals(cp3.name, "reward");
587+
Assert.assertFalse(cp3.required);
587588

588589
CodegenProperty cp4 = superMan.getVars().get(4);
589-
Assert.assertEquals(cp4.name, "category");
590-
Assert.assertFalse(cp4.required);
590+
Assert.assertEquals(cp4.name, "origin");
591+
Assert.assertTrue(cp4.required);
591592

592593
CodegenProperty cp5 = superMan.getVars().get(5);
593-
Assert.assertEquals(cp5.name, "level");
594-
Assert.assertTrue(cp5.required);
594+
Assert.assertEquals(cp5.name, "category");
595+
Assert.assertFalse(cp5.required);
595596

596-
CodegenProperty cp6 = superMan.getAllVars().get(0);
597-
Assert.assertEquals(cp6.name, "id");
597+
CodegenProperty cp6 = superMan.getVars().get(6);
598+
Assert.assertEquals(cp6.name, "level");
598599
Assert.assertTrue(cp6.required);
599600

600-
CodegenProperty cp7 = superMan.getAllVars().get(1);
601-
Assert.assertEquals(cp7.name, "name");
602-
Assert.assertFalse(cp7.required);
601+
CodegenProperty cp7 = superMan.getAllVars().get(0);
602+
Assert.assertEquals(cp7.name, "id");
603+
Assert.assertTrue(cp7.required);
603604

604-
CodegenProperty cp8 = superMan.getAllVars().get(2);
605-
Assert.assertEquals(cp8.name, "reward");
605+
CodegenProperty cp8 = superMan.getAllVars().get(1);
606+
Assert.assertEquals(cp8.name, "name");
606607
Assert.assertFalse(cp8.required);
607608

608-
CodegenProperty cp9 = superMan.getAllVars().get(3);
609-
Assert.assertEquals(cp9.name, "origin");
610-
Assert.assertTrue(cp9.required);
609+
CodegenProperty cp9 = superMan.getAllVars().get(2);
610+
Assert.assertEquals(cp9.name, "nickname");
611+
Assert.assertFalse(cp9.required);
612+
Assert.assertTrue(cp9.deprecated);
611613

612-
CodegenProperty cp10 = superMan.getAllVars().get(4);
613-
Assert.assertEquals(cp10.name, "category");
614+
CodegenProperty cp10 = superMan.getAllVars().get(3);
615+
Assert.assertEquals(cp10.name, "reward");
614616
Assert.assertFalse(cp10.required);
615617

616-
CodegenProperty cp11 = superMan.getAllVars().get(5);
617-
Assert.assertEquals(cp11.name, "level");
618+
CodegenProperty cp11 = superMan.getAllVars().get(4);
619+
Assert.assertEquals(cp11.name, "origin");
618620
Assert.assertTrue(cp11.required);
619621

622+
CodegenProperty cp12 = superMan.getAllVars().get(5);
623+
Assert.assertEquals(cp12.name, "category");
624+
Assert.assertFalse(cp12.required);
625+
626+
CodegenProperty cp13 = superMan.getAllVars().get(6);
627+
Assert.assertEquals(cp13.name, "level");
628+
Assert.assertTrue(cp13.required);
629+
620630
}
621631

622632

modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,8 @@ components:
8181
format: int64
8282
name:
8383
type: string
84-
example: Tom
84+
example: Tom
85+
nickname:
86+
type: string
87+
description: Previous short name for the human, replaced by `name`
88+
deprecated: true

samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,11 @@ export interface Human {
2727
* @memberof Human
2828
*/
2929
name?: string;
30+
/**
31+
* Previous short name for the human, replaced by `name`
32+
* @deprecated
33+
* @type {string}
34+
* @memberof Human
35+
*/
36+
nickname?: string;
3037
}

samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class PetApi extends BaseAPI {
149149
/**
150150
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
151151
* Finds Pets by tags
152+
* @deprecated
152153
*/
153154
findPetsByTags({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>>
154155
findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable<AjaxResponse<Array<Pet>>>

samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class PetApi extends BaseAPI {
149149
/**
150150
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
151151
* Finds Pets by tags
152+
* @deprecated
152153
*/
153154
findPetsByTags({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>>
154155
findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable<AjaxResponse<Array<Pet>>>

samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class PetApi extends BaseAPI {
149149
/**
150150
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
151151
* Finds Pets by tags
152+
* @deprecated
152153
*/
153154
findPetsByTags({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>>
154155
findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable<AjaxResponse<Array<Pet>>>

samples/client/petstore/typescript-rxjs/builds/with-progress-subscriber/apis/PetApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export class PetApi extends BaseAPI {
155155
/**
156156
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
157157
* Finds Pets by tags
158+
* @deprecated
158159
*/
159160
findPetsByTags({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>>
160161
findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: Pick<OperationOpts, 'progressSubscriber'>): Observable<Array<Pet>>

0 commit comments

Comments
 (0)