Skip to content

Commit ecd6016

Browse files
author
Dirk Niemeier
committed
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.
1 parent 2c7efda commit ecd6016

File tree

30 files changed

+1308
-27
lines changed

30 files changed

+1308
-27
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
generatorName: typescript-rxjs
2+
outputDir: samples/client/petstore/typescript-rxjs/builds/3.0
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript-rxjs

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: 35 additions & 25 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

@@ -577,46 +577,56 @@ public void allOfCompositionTest() {
577577
Assert.assertEquals(cp1.name, "name");
578578
Assert.assertFalse(cp1.required);
579579

580-
CodegenProperty cp2 = superMan.getVars().get(2);
581-
Assert.assertEquals(cp2.name, "reward");
582-
Assert.assertFalse(cp2.required);
580+
CodegenProperty cp2 = superMan.getVars().get(2);
581+
Assert.assertEquals(cp2.name, "nickname");
582+
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
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
wwwroot/*.js
2+
node_modules
3+
typings
4+
dist
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.gitignore
2+
.openapi-generator-ignore
3+
apis/PetApi.ts
4+
apis/StoreApi.ts
5+
apis/UserApi.ts
6+
apis/index.ts
7+
index.ts
8+
models/ApiResponse.ts
9+
models/Category.ts
10+
models/Order.ts
11+
models/Pet.ts
12+
models/Tag.ts
13+
models/User.ts
14+
models/index.ts
15+
runtime.ts
16+
servers.ts
17+
tsconfig.json

0 commit comments

Comments
 (0)