Skip to content

Commit 0ae4db4

Browse files
committed
- Added better support for deprecated prop
1 parent 4428f85 commit 0ae4db4

16 files changed

+179
-15
lines changed

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const handlebarsPlugin = () => ({
2828
preventIndent: true,
2929
knownHelpersOnly: true,
3030
knownHelpers: {
31+
ifdef: true,
3132
equals: true,
3233
notEquals: true,
3334
containsSpaces: true,

src/client/interfaces/Model.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface Model extends Schema {
99
template: string | null;
1010
link: Model | null;
1111
description: string | null;
12+
deprecated?: boolean;
1213
default?: string;
1314
imports: string[];
1415
enum: Enum[];

src/openApi/v3/parser/getModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const getModel = (
2323
template: null,
2424
link: null,
2525
description: definition.description || null,
26+
deprecated: definition.deprecated === true,
2627
isDefinition,
2728
isReadOnly: definition.readOnly === true,
2829
isNullable: definition.nullable === true,

src/openApi/v3/parser/getModelProperties.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const getModelProperties = (
3737
> = {
3838
name: escapeName(propertyName),
3939
description: property.description || null,
40+
deprecated: property.deprecated === true,
4041
isDefinition: false,
4142
isReadOnly: property.readOnly === true,
4243
isRequired: propertyRequired,

src/openApi/v3/parser/getOperationParameter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const getOperationParameter = (openApi: OpenApi, parameter: OpenApiParame
2020
template: null,
2121
link: null,
2222
description: parameter.description || null,
23+
deprecated: parameter.deprecated === true,
2324
isDefinition: false,
2425
isReadOnly: false,
2526
isRequired: parameter.required === true,

src/templates/partials/exportComposition.hbs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
{{#if description}}
1+
{{#ifdef description deprecated}}
22
/**
3+
{{#if description}}
34
* {{{escapeComment description}}}
4-
*/
55
{{/if}}
6+
{{#if deprecated}}
7+
* @deprecated
8+
{{/if}}
9+
*/
10+
{{/ifdef}}
611
export type {{{name}}} = {{>type parent=name}};
712
{{#if enums}}
813
{{#unless @root.useUnionTypes}}
914

1015
export namespace {{{name}}} {
1116

1217
{{#each enums}}
13-
{{#if description}}
18+
{{#ifdef description deprecated}}
1419
/**
20+
{{#if description}}
1521
* {{{escapeComment description}}}
16-
*/
1722
{{/if}}
23+
{{#if deprecated}}
24+
* @deprecated
25+
{{/if}}
26+
*/
27+
{{/ifdef}}
1828
export enum {{{name}}} {
1929
{{#each enum}}
2030
{{{name}}} = {{{value}}},

src/templates/partials/exportEnum.hbs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
{{#if description}}
1+
{{#ifdef description deprecated}}
22
/**
3+
{{#if description}}
34
* {{{escapeComment description}}}
4-
*/
55
{{/if}}
6+
{{#if deprecated}}
7+
* @deprecated
8+
{{/if}}
9+
*/
10+
{{/ifdef}}
611
export enum {{{name}}} {
712
{{#each enum}}
813
{{#if description}}

src/templates/partials/exportInterface.hbs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
{{#if description}}
1+
{{#ifdef description deprecated}}
22
/**
3+
{{#if description}}
34
* {{{escapeComment description}}}
4-
*/
55
{{/if}}
6+
{{#if deprecated}}
7+
* @deprecated
8+
{{/if}}
9+
*/
10+
{{/ifdef}}
611
export type {{{name}}} = {
712
{{#each properties}}
8-
{{#if description}}
13+
{{#ifdef description deprecated}}
914
/**
15+
{{#if description}}
1016
* {{{escapeComment description}}}
11-
*/
1217
{{/if}}
18+
{{#if deprecated}}
19+
* @deprecated
20+
{{/if}}
21+
*/
22+
{{/ifdef}}
1323
{{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type parent=../name}};
1424
{{/each}}
1525
};

src/templates/partials/exportType.hbs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
{{#if description}}
1+
{{#ifdef description deprecated}}
22
/**
3+
{{#if description}}
34
* {{{escapeComment description}}}
4-
*/
55
{{/if}}
6+
{{#if deprecated}}
7+
* @deprecated
8+
{{/if}}
9+
*/
10+
{{/ifdef}}
611
export type {{{name}}} = {{>type}};

src/templates/partials/parameters.hbs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
{{/each}}
77
}: {
88
{{#each parameters}}
9+
{{#ifdef description deprecated}}
10+
/**
911
{{#if description}}
10-
/** {{{escapeComment description}}} **/
12+
* {{{escapeComment description}}}
1113
{{/if}}
14+
{{#if deprecated}}
15+
* @deprecated
16+
{{/if}}
17+
*/
18+
{{/ifdef}}
1219
{{{name}}}{{>isRequired}}: {{>type}},
1320
{{/each}}
1421
}

0 commit comments

Comments
 (0)