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

feat: prettify json body automatically #1480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

banjo
Copy link
Contributor

@banjo banjo commented Jan 30, 2024

Description

Currently, the json body is by default in "string" mode, and you have to press the prettify button to fix it.

This update automatically prettifies the JSON on mount IF it is a valid JSON. This means that, for example, if you add a new curl import, it will default to a prettified view. And if it is not a valid JSON-format, it will do nothing.

Here is an example:

auto-format

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

@banjo banjo force-pushed the feature/auto-prettify branch from 6993ff5 to 6cbde0c Compare February 12, 2024 11:43
@banjo
Copy link
Contributor Author

banjo commented Feb 12, 2024

I'm not really sure why the tests here fail, anyone knows why?

The Publish test report step fails in the pipe.

Run dorny/test-reporter@v1
Action was triggered by pull_request: using SHA from head of source branch
Check runs will be created with SHA=6cbde0cd915fd7102077e34a806c7[14](https://github.com/usebruno/bruno/actions/runs/7871199178/job/21473980886?pr=1480#step:7:15)a1747f96a
Listing all files tracked by git
Found 646 files tracked by GitHub
Using test report parser 'java-junit'
Creating test report Test Report
  Processing test results for check run Test Report
  Creating check run Test Report
Error: HttpError: Resource not accessible by integration

@helloanoop
Copy link
Contributor

Thanks for taking time to work on this @banjo .

One issue I see with this approach is that - this essentially force prettifies the body every time the request body is opened, leaving no option for the user to format the body as per their needs.

This means that, for example, if you add a new curl import, it will default to a prettified view. And if it is not a valid JSON-format, it will do nothing.

I think trying to auto prettify the curl json body before creating a request still makes sense

@helloanoop helloanoop self-assigned this Aug 23, 2024
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.

2 participants