I have an Enum like below
enum:
- Male
- Female
but internally i want this as F
and M
? like if i print Male it should print M not male
I have an Enum like below
enum:
- Male
- Female
but internally i want this as F
and M
? like if i print Male it should print M not male
Since in your comments you speak about the frontend, I guess you mean that when you show this values you want to show "Female" and "Male", instead of F and M, that part goes beyond what swagger does.
What you need to put now is the values the API expects to receive which are, as you stated, M and F.
properties:
gender:
type: string
description: Gender of the person
enum:
- M
- F
Considering the data types listed in the spec your best choice seems to be string
.
How you show the data in the frontend is a completely different matter and you should implement something to display the enum values however you decide is best.
There are a couple of issues open in the swagger spec about enums that have a bit to do with what you want: here and here.