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

Feature/always indent json in queryresult #838

Merged

Conversation

Joschasa
Copy link
Contributor

Description

An unused condition was removed and the QueryPreview window should always indent the JSON payload.
Even for APIs with a Content-Type info of "application/html".

Before:
image
(Headers:)
image

After:
image

However the resulting JSON is not highlighted / foldable, as the CodeEditor still treats this as HTML.

We could leave this as is, so that one might recognize the API returns the wrong Content-Type.

Contribution Checklist:

André Glüpker added 2 commits October 31, 2023 11:55
The mode is returned by getCodeMirrorModeBasedOnContentType(),
which always prefixes the returned values with 'application/'.

However returning data on those application/html or application/text
break Bruno.
Some APIs return the wrong Content-Type 'application/html', but valid
JSON as payload. In this cases the data is still typeof object and a
indented JSON makes it easier to work with.

However JSON folding and highlighting will still be off in this case.
@Its-treason
Copy link
Member

Hey, @Joschasa, I think it would be better if we instead edit the getCodeMirrorModeBasedOnContentType function to return the correct mode instead of changing just the formatting. This way JSON will also be highlighted correctly.

I think you can just pass the body to getCodeMirrorModeBasedOnContentType and check if it's an object or something and then return the application/ld+json mode.

@Joschasa
Copy link
Contributor Author

Joschasa commented Nov 1, 2023

Hi @Its-treason, is this what you had in mind?

@Its-treason
Copy link
Member

Hi @Its-treason, is this what you had in mind?

Yes, and you should be able to revert the changes to the formatResponse function.

Looks good, nice work!

@Joschasa
Copy link
Contributor Author

Any update on this?

@helloanoop helloanoop merged commit 9f8dba0 into usebruno:main Dec 6, 2023
2 checks passed
@helloanoop
Copy link
Contributor

Merged. Thank you @Joschasa for getting this done!

Thank you for reviewing this @Its-treason !

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.

None yet

3 participants