swagger-api / swagger-api/swagger-ui
SwaggerUI does not display array of 0 integer values example nor displays 0 when adding via "Add integer item"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Ubuntu 20.04 LTS
- Browser: Chrome
- Version: 102.0.5005.61 (Official Build) (64-bit)
- Method of installation: Unsure, part of Python/Django/DRF/drf-spectacular?
- Swagger-UI version: 4.12.0?
- Swagger/OpenAPI version: OpenAPI 3.0.3
Content & configuration
You can simply use Swagger Editor (https://editor.swagger.io/), use the following YAML, and look at the result for the example values.
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: Test API
version: 1.0.0
paths:
/test_endpoint/:
get:
parameters:
- in: query
name: int_array_parameter
schema:
type: array
items:
type: integer
examples:
ThreeZerosExample:
value:
- 0
- 0
- 0
responses:
'200':
description: Success response
Swagger-UI configuration options:
Not sure, but you can simply use https://editor.swagger.io/ to reproduce the error.
Describe the bug you're encountering
The three text fields show as empty rather than containing 0. A workaround is to provide the values as "0" rather than 0.
However, there is a related issue for which I don't see a good workaround: If you use the UI to add elements by clicking on "Add integer item", all new items appear as blank text fields, but in reality, the value 0 is used for them.
To reproduce...
Steps to reproduce the behavior:
- Enter the provided YAML into https://editor.swagger.io/
- Click on
/test_endpoint/to expand it - Notice that the three text fields are empty.
- You can go further and click on "Add integer item" and notice that the items appear as blank text fields. Click "Execute" to see what the blank field values are assumed to be (
0).
Expected behavior
- The three text fields should contain the value
0. A workaround is to use"0"in theyamlrather than0. Doing so ensures the text fields appear with the value0inside. - The items added via "Add integer item" should appear as
0just like they appear to be based on the executed query when you click "Execute".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Swagger Editor using the YAML provided, then trace the UI path that renders integer array parameter values and creates items from “Add integer item.” Done means existing zero values and newly added integer items visibly contain 0, while execution continues to send the expected values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100