Skip to content

Commit 73079c2

Browse files
authored
Fix #20692 [typescript-angular] Support enumDescription / x-enum-descriptions (#20693)
* #20692 [typescript-angular] Added x-enum-descriptions to "composed-schemas" example. * #20692 [typescript-angular] Respect x-enum-descriptions / enumDescription in modelEnum mustache template. * #20692 [typescript-angular] Regenerated samples.
1 parent 9374dbd commit 73079c2

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
export enum {{classname}} {
33
{{#allowableValues}}
44
{{#enumVars}}
5+
{{#enumDescription}}
6+
7+
/**
8+
* {{.}}
9+
*/{{/enumDescription}}
510
{{name}} = {{{value}}}{{^-last}},{{/-last}}
611
{{/enumVars}}
712
{{/allowableValues}}
@@ -13,6 +18,11 @@ export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last
1318
export const {{classname}} = {
1419
{{#allowableValues}}
1520
{{#enumVars}}
21+
{{#enumDescription}}
22+
23+
/**
24+
* {{.}}
25+
*/{{/enumDescription}}
1626
{{name}}: {{{value}}} as {{classname}}{{^-last}},{{/-last}}
1727
{{/enumVars}}
1828
{{/allowableValues}}

modules/openapi-generator/src/test/resources/3_0/typescript-angular/composed-schemas.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ components:
3434
DogBreed:
3535
type: string
3636
enum: [Dingo, Husky]
37+
x-enum-descriptions:
38+
- Canis lupus dingo
39+
- Siberian Husky
3740

3841
PetWithSimpleDiscriminator:
3942
type: object
@@ -104,6 +107,9 @@ components:
104107
inlineBreed:
105108
type: string
106109
enum: [ Dingo, Husky ]
110+
x-enum-descriptions:
111+
- Canis lupus dingo
112+
- Siberian Husky
107113
CatComposed:
108114
allOf:
109115
- $ref: '#/components/schemas/PetWithoutDiscriminator'

samples/client/others/typescript-angular/builds/composed-schemas-tagged-unions/model/dogBreed.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010

1111

1212
export enum DogBreedModel {
13+
14+
/**
15+
* Canis lupus dingo
16+
*/
1317
Dingo = 'Dingo',
18+
19+
/**
20+
* Siberian Husky
21+
*/
1422
Husky = 'Husky'
1523
}
1624

samples/client/others/typescript-angular/builds/composed-schemas/model/dogBreed.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010

1111

1212
export enum DogBreedModel {
13+
14+
/**
15+
* Canis lupus dingo
16+
*/
1317
Dingo = 'Dingo',
18+
19+
/**
20+
* Siberian Husky
21+
*/
1422
Husky = 'Husky'
1523
}
1624

0 commit comments

Comments
 (0)