question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display enums in parameter info

See original GitHub issue
Q A
Bug or feature request? Feature request
Which Swagger/OpenAPI version? 2.0, 3.0
Which Swagger-UI version? 3.4.3
How did you install Swagger-UI? http://editor.swagger.io
Which browser & version? N/A
Which operating system? N/A

Demonstration API definition

2.0:

swagger: '2.0'
info:
  title: test
  version: 0.0.0
paths:
  /report:
    get:
      parameters:
        - in: query
          name: rel_date
          required: true
          type: string
          enum:
            - today
            - yesterday
            - lastweek
      responses:
        200:
          description: OK

3.0:

openapi: 3.0.0
info:
  title: test
  version: 0.0.0
paths:
  /report:
    get:
      parameters:
        - in: query
          name: rel_date
          required: true
          schema:
            type: string
            enum:
              - today
              - yesterday
              - lastweek
      responses:
        '200':
          description: OK

Expected Behavior

The parameter info in the UI displays the enum values.

Current Behavior

The enum values are only displayed when we do “try it out” and are not displayed normally.

Parameter enum values

Context

Related to #3518.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
hkosovacommented, Jan 11, 2018

@webron @shockey This was implemented in 3.9.0, right? (via PR https://github.com/swagger-api/swagger-ui/pull/3977)

🎉

1reaction
alebarcommented, Nov 19, 2017

I agree with @feenr that dropdown is bot the beat to display value.

@feenr, please consider two more things:

  • it is possibile to create parametr accepting an array od enums ( that’s the case of API that we have at work).
  • openapi spec allows to add description for each enum’s value. This should be shown as well…
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get enum values if enum class is parameter in method ...
To get the enum values from a Class object, you can use Class.getEnumConstants() . If you want access to the getSequence() function.
Read more >
Enums - Swagger
You can use the enum keyword to specify possible values of a request parameter or a model property. For example, the sort parameter...
Read more >
ParameterAttributes Enum (System.Reflection) - Microsoft Learn
Defines the attributes that can be associated with a parameter. These are defined in ... Specifies that the parameter has field marshaling information....
Read more >
Enum HOWTO — Python 3.11.1 documentation
Because Enums are used to represent constants we recommend using UPPER_CASE names for members, and will be using that style in our examples....
Read more >
How To Send Enum Parameters To Forms
A developer can set an enum type in the 'Enum Type Parameter' property. And then set the specific enum value in 'Enum Parameter'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found