question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Execute button is not working with 'malformed' JSON body

See original GitHub issue

Q&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:

  1. Go to https://petstore.swagger.io/#/pet/addPet
  2. Open the ‘Add a new pet to the store’ (it should be opened by default using the link above)
  3. Click the Try it out button to activate the UI
  4. 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"
}
  1. 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:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:15

github_iconTop GitHub Comments

4reactions
vishmitcommented, Jul 6, 2022

Hello, do we an option to turn off this validation on client side?

2reactions
luizavladislavnacommented, Nov 16, 2021

We also spent time because of this bug. Would love to see an improvement in this.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found