UI does not show the default value when one is assigned for an enum
See original GitHub issueThe 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:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I opened #3873 about rendering enums in parameter descriptions.
@DenisGorbachev, I believe this commit added the default value display: https://github.com/swagger-api/swagger-ui/commit/a47da98b54d122979bb8754e3050a4df0cc50d48