问题
Below is the generated YAML from python execution
requestBody:
content:
application/json:
schema:
properties:
element_ids:
items:
type: string
type: array
element_type:
items:
enum:
- NC
- CELL
type: string
type: array
expires_in:
format: int32
type: integer
group_id:
type: string
required:
- element_ids
- element_type
- expires_in
- group_id
I have provided my enum values in the form of list.
I see only NC in the swagger(3.0.0) shown below
回答1:
Your spec is correct. "Example Value" displays an example request based on the info you specified in the OpenAPI file. The full enum is listed on the Schema tab:
If you want to display "element_type": ["NC", "CELL"]
in the JSON example, add the corresponding example
to the element_type
property definition:
element_type:
items:
enum:
- NC
- CELL
type: string
type: array
example: [NC, CELL] # <----------
来源:https://stackoverflow.com/questions/54104552/only-first-element-of-enum-list-is-displayed-instead-of-entire-list-in-swagger