Skip to content

Commit ba833d3

Browse files
authored
Document 'x-enum-descriptions' and 'x-enum-varnames' (OpenAPITools#2010)
1 parent 65d3371 commit ba833d3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/templating.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,41 @@ For example, suppose you use your specification document for code generation wit
615615
616616
The following are vendor extensions supported by OpenAPI Generator. The list may not be up-to-date, the best way is to look for "x-" in the built-in mustache templates.
617617
618+
### All generators (core)
619+
620+
#### Enum
621+
622+
`x-enum-varnames` can be used to have an other enum name for the corresponding value.
623+
This is used to define names of the enum items.
624+
625+
`x-enum-descriptions` can be used to provide an individual description for each value.
626+
This is used for comments in the code (like javadoc if the target language is java).
627+
628+
`x-enum-descriptions` and `x-enum-varnames` are each expected to be list of items containing the same number of items as `enum`.
629+
The order of the items in the list matters: their position is used to group them together.
630+
631+
Example:
632+
633+
```yaml
634+
WeatherType:
635+
type: integer
636+
format: int32
637+
enum:
638+
- 42
639+
- 18
640+
- 56
641+
x-enum-descriptions:
642+
- 'Blue sky'
643+
- 'Slightly overcast'
644+
- 'Take an umbrella with you'
645+
x-enum-varnames:
646+
- Sunny
647+
- Cloudy
648+
- Rainy
649+
```
650+
651+
In the example for the integer value `42`, the description will be `Blue sky` and the name of the enum item will be `Sunny` (some generators changes it to `SUNNY` to respect some coding convention).
652+
618653
### ObjC
619654
#### x-objc-operationId
620655

0 commit comments

Comments
 (0)