swagger-api / swagger-api/swagger-ui

Changing Content Type Cause Errors in the Example

Open
#10,738 2 comments 2 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

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:

  1. Go to https://editor.swagger.io/
  2. Load the Example Petstore OpenAPI 3.1
  3. Click on the first Endpoint (updatePet) to expand it
  4. Set the content type to application/x-www-form-urlencoded
  5. Click Try it out
  6. Set the content type to application/json
  7. Now you can see the errors in the generated example
  8. When you click on Reset everything looks good again
Expected behavior

There should be no errors in the generated examples.

Screenshots
Image
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.