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 request: Syntax Highlighting #3189

Closed
Korri opened this issue Jun 6, 2017 · 5 comments
Closed

Feature request: Syntax Highlighting #3189

Korri opened this issue Jun 6, 2017 · 5 comments

Comments

@Korri
Copy link

Korri commented Jun 6, 2017

Swagger 2 had a nice syntax highlighting for json/xml samples.

I might be missing something, but I don't see it in the "Known Issues" section of the README.md, is this planned or is there a way to enable it on swagger-ui 3?

@webron
Copy link
Contributor

webron commented Jun 6, 2017

Thanks for bringing it up. As we're focused on OAS3 support, this will not be high on the priority list for now. That said, contributions are always welcome.

@shockey
Copy link
Contributor

shockey commented Jun 7, 2017

npm has some nice react components that handle syntax highlighting: https://www.npmjs.com/search?q=react+syntax+highlighting

a community PR that adds this functionality would be wonderful, and not difficult to implement!

@biggates
Copy link

swagger-ui currently uses microlight and has a component named HighlightCode . I tried to modify it with highlight.js and am going through several problems currently:

  • highlight.js requires type of language, which is not known yet in this component
  • some styles are marked important and have to be
  • need to find a way to "alter" component and styles as a plugin
  • and a method to avoid dangerouslySetInnerHTML (maybe in a react way using react-lowlight )

visual effect:

image

@hkosova
Copy link
Contributor

hkosova commented Jul 20, 2020

🎉 Implemented in Swagger UI 3.30.0 (PR #6236).

See also the relevant configuration parameters:
https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#user-content-syntaxhighlight

@hkosova hkosova closed this as completed Jul 20, 2020
@CodyReichert
Copy link

This works beautifully, thanks to everyone who worked on it. Responses are much more readable now.

Don't mean to be noisy, just wanted to leave some confirmation in the thread for other users searching around. I just upgraded swagger-ui-bundle.js/swagger-ui.css and voila:

image

The defaults look great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants