apidash icon indicating copy to clipboard operation
apidash copied to clipboard

Add validation for JSON request body

Open ashitaprasad opened this issue 10 months ago • 3 comments

Tell us about the task you want to perform and are unable to do so because the feature is not available

Currently, validation is missing for JSON request body.

What is JSON validation?

Image

From UX point of view,

  • a single line status card below the JSON Text field would be a good idea which will turn red if the JSON is invalid and user can tap/hover on the card to view more details of the error.
  • A more preferred approach is to notify user via the Status bar as mentioned in https://github.com/foss42/apidash/issues/587

Also, the check should be triggered keeping proper debounce time which allows users to finish typing a word or phrase without triggering unnecessary checks.

There is a JSON editor in the repo which has not yet been integrated for request body: https://github.com/foss42/apidash/blob/main/lib/widgets/editor_json.dart

ashitaprasad avatar Feb 19 '25 21:02 ashitaprasad

Hello @ashitaprasad , I will be working on this issue. I can see that it is related to 3 other issues #22 , #582 and #581, but as JSON validation is crucial for the request to succeed, I will start with this one. First I will check the available JSON editor, and then I will propose my solution or jump directly to the PR.

Ahmed-Aladdiin avatar Feb 20 '25 03:02 Ahmed-Aladdiin

FOSS Hack 2025 - Team Dart Knight

Proposal

User - Vishwa Karthik

P.S - Sometimes I'm thinking out loud while drafting this.

Features

  • Syntax Highlighting
  • JSON Validator
  • JSON Beautification
  • Object Indentation
  • Automatic Bracket Completer
  • Implement Line Number
  • Show Error Line
  • Allow comments? (should we include this?)

Edge Cases Considered

  • Extremely Large JSON Objects: To tackle entire process when large objectts is pasted into the editor.

  • Incorrectly Formatted JSON: Simple Error IconData over the line number to show where error could be? (like missing comma, trailing comma error)

  • Editing JSON with Comments: If supporting JSON5, do we need to allow comments, or skip them entirely.

  • Partial JSON Input: Gotta ensure the editor don't break when incomplete JSON is entered.

Recommendation

  • We can build custom JsonEditorView using "json_text_editor" package or can we reuse APIDASH's "json_explorer" package to reduce development time?

Questions for Maintainer

  • How do you want to prioritize this enhancement? Is this good to have feature?
  • If we support JSON, do we have any future plan to incorporate XML?

cc: @ashitaprasad

Vishwa-Karthik avatar Feb 20 '25 06:02 Vishwa-Karthik

@Vishwa-Karthik For the full list of features check out parent issue https://github.com/foss42/apidash/issues/22

Answering your query:

  • This is a good feature to have.
  • No, we currently do not have any plans to incorporate XML

ashitaprasad avatar Feb 21 '25 01:02 ashitaprasad