Skip to content

UI does not show the default value when one is assigned for an enum #3518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DavidBiesack opened this issue Aug 3, 2017 · 8 comments
Closed

Comments

@DavidBiesack
Copy link

The GET in the below OpenAPI yaml contains a parameter named imageSize, but the rendering of the query parameters does not disclose the default. Note that swagger-codegen (-l html) includes the default at the end of the description field

swagger: "2.0"
info:
  version: "1"
  title: Missing default for enum 
  description: Demonstrate Swagger UI bug not showing default for an enum
basePath: /enumDefault
schemes:
- "http"
paths:
  /example:
    get:
      summary: Get a diagram
      description: Get a diagram
      produces:
      - application/json
      parameters:
      - name: imageSize
        in: query
        type: string
        enum:
        - thumbnail
        - icon
        - scaled
        - fullsize
        required: false
        default: thumbnail
        description: The layout type. 
      responses:
        200:
          description: OK
          schema:
            $ref: "#/definitions/diagram"
          headers:
            Location:
              description: The URL of the diagram.
              type: string
              format: uri
definitions:
  diagram:
    title: Diagram
    description: The representation of a diagram.
    properties:
      id:
        type: string
        description: The unique identifier for the diagram.
      imageSize:
        type: string
        enum:
        - thumbnail
        - icon
        - scaled
        - fullsize
        default: thumbnail
        description: The layout type. 

current Swagger UI rendering:
missing-default-for-enum-parameter

@bthorstad
Copy link

In addition to not showing the default, the rendering does not enumerate the valid values; whereas swagger-codegen (-l html) does.

@DavidBiesack
Copy link
Author

However the Try it Out drop down does list the enumerated values and properly selects the default. but the doc should also show this w/o having to open the Try It Out. The default for an enum in the definitions/models is shown correctly.

@masterof0
Copy link

I am having a similar issue where the UI does not show enum options for parameters in the default view or the 'try it out' view. I only get a string input. In this particular example. I have defined values for category, but they do not show in the UI

enum

@shockey
Copy link
Contributor

shockey commented Oct 16, 2017

@masterof0, I think you're describing a related, but different issue. We'd appreciate it if you would open a new ticket for that!

Edit: To clarify, OP's issue is with a Swagger 2.0 definition, while your issue is unique to OpenAPI 3.0's rendering.

@hkosova
Copy link
Contributor

hkosova commented Nov 7, 2017

@masterof0 commented:

I am having a similar issue where the UI does not show enum options for parameters in the default view or the 'try it out' view.

@shockey commented:

I think you're describing a related, but different issue. We'd appreciate it if you would open a new ticket for that!

I opened #3873 about rendering enums in parameter descriptions.

@webron
Copy link
Contributor

webron commented Jul 5, 2018

Closing as resolved, thanks for reporting!

@webron webron closed this as completed Jul 5, 2018
@DenisGorbachev
Copy link

@webron could you please point to commit where the default values are displayed in Swagger UI for 2.0 version of specification? As far as I see in my Swagger UI, it's not resolved yet.

@shockey
Copy link
Contributor

shockey commented Jul 31, 2018

@DenisGorbachev, I believe this commit added the default value display: a47da98

@lock lock bot locked and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants