swagger-api / swagger-api/swagger-ui
Can't get parameter validation error list in `param-body`
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: macOS
- Browser: chrome
- Version: latest
- Method of installation: source code debug
- Swagger-UI version: latest
- Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0
Content & configuration
The code to get the validation error list in src/core/components/param-body.jsx
// line 110 - 111
let parameter = specSelectors ? specSelectors.parameterWithMetaByIdentity(pathMethod, param) : param
let errors = parameter.get("errors", List())
seems can't get the error list set in the [VALIDATE_PARAMS] reducer. While I changed it to
// line 111
let errors = param.get("errors", List())
to get the error list directly from the param variable, and it worked.
I think this may be a defect and don't know why this specSelectors.parameterWithMetaByIdentity(pathMethod, param) is necessary. Please take a look.
Example Swagger/OpenAPI definition:
# your YAML here
Swagger-UI configuration options:
SwaggerUI({
// your config options here
})
?yourQueryStringConfig
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior:
- Go to 'petstore'
- Scroll down to 'any api with additional body parameter'
- Change it's json body to any invalid format
- Click on
Execute
Expected behavior
There would be some feedback on the page
Screenshots
Additional context or thoughts
If the param-body gets the errors correctly, there would be a hint on the page indicating the param error for #6295.
And if the error messages can be displayed on the page, it would be even better.
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
Start in src/core/components/param-body.jsx around lines 110–111 and trace the parameter data through the [VALIDATE_PARAMS] reducer. Reproduce the issue with the Petstore example by submitting an invalid JSON body, then verify that parameter validation feedback appears on the page.
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
- Mostly clear
- Newbie friendliness
- 35/100