-2

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

Vít Kotačka
  • 1,472
  • 1
  • 15
  • 40

1 Answers1

0

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.

moondaisy
  • 4,303
  • 6
  • 41
  • 70