swagger-api / swagger-api/swagger-ui
Changing Content Type Cause Errors in the Example
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Describe the bug you're encountering
When I switch the content type from application/x-www-form-urlencoded to application/json after i clicked Try it out the generated example contains errors.
To reproduce...
Steps to reproduce the behavior:
- Go to https://editor.swagger.io/
- Load the Example Petstore OpenAPI 3.1
- Click on the first Endpoint (updatePet) to expand it
- Set the content type to
application/x-www-form-urlencoded - Click
Try it out - Set the content type to
application/json - Now you can see the errors in the generated example
- When you click on Reset everything looks good again
Expected behavior
There should be no errors in the generated examples.
Screenshots
Additional context or thoughts
- The error occurs from version v5.29.0 onwards
- We were able to reproduce the error in Firefox, Edge, and Chrome
- The error is independent of the specific OpenAPI documentation. It appears to occur in the frontend.
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 https://editor.swagger.io/ using the Example Petstore OpenAPI 3.1, following the content-type switch after clicking Try it out. Start by tracing the frontend state handling for generated examples when changing from application/x-www-form-urlencoded to application/json. Done means switching content types produces no errors and Reset continues to restore the correct example.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100