Execute button is not working with 'malformed' JSON body
See original GitHub issueQ&A (please complete the following information)
- OS: Windows 2019
- Browser: Chrome
- Version: 84.0.4147.125
- Method of installation: dist assets
- Swagger-UI version: 3.31.1
- Swagger/OpenAPI version: 2.0
Content & configuration
I’ll skip the content&configuration since the issue can be reproduced with the ‘pet store’ demo.
Describe the bug you’re encountering
I encountered a strange situation with Swagger-UI where the Execute
button stopped working without any apparent reason why (nothing in the console or network tab). After investigating I noticed that the issue was caused by a trailing comma in my JSON body.
To reproduce…
Steps to reproduce the behavior:
- Go to https://petstore.swagger.io/#/pet/addPet
- Open the ‘Add a new pet to the store’ (it should be opened by default using the link above)
- Click the
Try it out
button to activate the UI - Replace the body with this JSON (notice the
,
in the tags section)
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
,
}
],
"status": "available"
}
- Click the
Execute button
Expected behavior
I’m expecting the request to be sent to the server or some kind of message telling me why the execute didn’t work. It’s a bit strange to click on the Execute
button and having nothing happen.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:15
Top Results From Across the Web
Why do I get a malformed JSON in request body in this cURL ...
I found the answer in the blog post: "Expecting to find valid JSON in request body..." curl for Windows. For example, for Purge...
Read more >How to Fix the Invalid JSON Error in WordPress? - Rank Math
In this article, learn how to fix the invalid JSON error - 'Updating failed. The response is not a valid JSON response.' with...
Read more >I've received an "Invalid JSON string" error. What do I do?
An invalid JSON error can occur for many reasons. The most common issue is usually associated with a file upload attempt, and can...
Read more >Malformed JSON data, for some unicode characters - AskF5
Support Solution. There are applications that use unicode characters that are not mapped as allowed by the ASM JSON parser, hence the ASM ......
Read more >Got an error response malformed JSON Response. When ...
Hi, we have a pdf that when save button is click it will open new tab ... We will face the below error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, do we an option to turn off this validation on client side?
We also spent time because of this bug. Would love to see an improvement in this.