Allow yaml to define enum with different name and value
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2021
09:03 AM
04-12-2021
09:03 AM
Allow yaml to define enum with different name and value
A common practice is to use enum to define coded persistence values such as:
Status:
type: string
enum:
- name: ABANDONED
value: A
- name: ISSUED
value: I
However this generates a JSON object as the value
ABANDONED_A("{name: ABANDONED, value: A}")
Is this not possible with OAS3?
Labels:
- Labels:
-
Swagger Codegen
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2021
09:41 AM
04-12-2021
09:41 AM
Is this not possible with OAS3?
OpenAPI 3.0 does not have a way to annotate individual enum values, but this is possible in OpenAPI 3.1 using oneOf + const (once tooling support is available):
Status:
oneOf:
- title: ABANDONED
const: A
- title: ISSUED
const: I
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2021
07:27 AM
08-04-2021
07:27 AM
I am trying to implement this as well in my open API specification, but IntelliJ is marking "const" as a prohibited property.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2021
06:01 PM
08-04-2021
06:01 PM
That could be intellij's limitation.
Regards,
Rao.
Regards,
Rao.
