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.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hkosovacommented, 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.

0reactions
shockeycommented, Jul 31, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

display Enum Values in UI with default value if not selected
1 Answer 1 · this does not take into account what the user already has selected. · the use of th:object with th:field...
Read more >
CA1008: Enums should have zero value (code analysis) - .NET
The default value of an uninitialized enumeration, just like other value types, is zero. A non-flags-attributed enumeration should define a ...
Read more >
How to show default value of enum type field on form
Hi can we show default value of enum field on form whoose who is not 0th element of enum. Also if user cchanges...
Read more >
Enumeration (or enum) in C - GeeksforGeeks
By default, the values // of the constants are as follows: // constant1 ... 1, 0, 0. 2. If we do not explicitly...
Read more >
MySQL 8.0 Reference Manual :: 11.3.5 The ENUM Type
An enumeration value can also be the empty string ( '' ) or NULL under certain circumstances: If you insert an invalid value...
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