Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: validate json #577

Merged
merged 3 commits into from
Jun 8, 2020
Merged

Fix: validate json #577

merged 3 commits into from
Jun 8, 2020

Conversation

thewahome
Copy link
Collaborator

Overview

Checks if the sample body is valid before running it. Incase it is not, it provides an error "Malformed JSON body" so that someone can see that there is a syntax error that needs to be fixed

Fixes #557

Demo

image

Notes

The second part in the message that contains the actual syntax error is dynamically generated and thus it's localisation is not possible.

Testing Instructions

  • Log in so that you are able to send a post request
  • Add an extra comma anywhere in the sample body and take note of it
  • Hit enter / click run query
  • Notice that an error appears saying that you have a syntax error and shows you where to find it

Copy link
Contributor

@MIchaelMainer MIchaelMainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I see that Monaco has built in JSON validation as it has the red squiggle so they can find the error.

My only suggestion is to provide an action in the error message. Something like "Review the request body and fix any malformed JSON." I'd leave the parser related message, and append to the end of the message.

@MIchaelMainer
Copy link
Contributor

By the way, did you see this: https://github.com/Microsoft/monaco-json? It may provide additional value for this scenario.

@thewahome thewahome merged commit 26ddbb1 into dev Jun 8, 2020
@thewahome thewahome deleted the fix/validate-json branch June 25, 2020 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle non wellformed JSON for request bodies
3 participants