Skip to content

Commit 77f009a

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 77f009a

File tree

29 files changed

+1273
-2
lines changed

29 files changed

+1273
-2
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/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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.18.0-SNAPSHOT

0 commit comments

Comments
 (0)