swagger-api / swagger-api/swagger-ui

Frontend validation error popup text is in a hard to read format

Open
#9,006 3 comments 0 reactions 0 assignees View on GitHub

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)
Describe the bug you're encountering

Swagger-ui's frontend validation for json values (e.g. for put or post) seems to render the parameter text in the error message popup in a hard to read format. Instead of using the parameter name e.g. photoUrls, it uses the following syntax: propKey+parameter+error. The html is rendered as

<div class="validation-errors errors-wrapper">Please correct the following validation errors and try again.
<ul>
<li>
::marker
"propKey"
"parameter" (+possibly more than one)
"error"
</li>
</ul>
</div>

which makes the content in the li tag look pretty unreadable in the error popup since each string is rendered without spaces in-between.
swaggerapierror

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://petstore.swagger.io/#/pet/addPet or https://editor.swagger.io/
  2. Click on PUT or POST /pet
  3. Edit a parameter like photoUrls which requires a string and instead enter a number
  4. Press execute
  5. See validation error popup with hard to read error message
Expected behavior

The strings inside of the li tag would be much easier to read if there were spaces in between the words 😄
It would also be beneficial to just see the name of the parameter without "propKey" or "error", possibly also with a seperator between the parameter and the error message (e.g. photoUrls: Value must be a string // or in this case photoUrls[0]: Value must be a string).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the validation popup using the Petstore demo: open PUT or POST /pet, enter a number for the photoUrls string parameter, and execute it. Inspect the frontend validation error rendering and make the list item readable, showing the parameter name and separating it from the error; done means the popup displays clear text instead of concatenated propKey, parameter, and error strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.