Skip to content

Add helper to render to static HTML #4232

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

Open
aeneasr opened this issue Feb 18, 2018 · 5 comments
Open

Add helper to render to static HTML #4232

aeneasr opened this issue Feb 18, 2018 · 5 comments

Comments

@aeneasr
Copy link

aeneasr commented Feb 18, 2018

I would like to render the swagger UI to static HTML for SEO reasons. With react, this is typically done using the ReactDOMServer and should (in theory) be not too hard to add.

Is this maybe implemented already?

@shockey
Copy link
Contributor

shockey commented Mar 1, 2018

Hi @arekkas!

Server-side rendering is out of Swagger-UI's scope. If you need it, the best approach would be to create a SSR-capable React application that consumes Swagger-UI.

@aeneasr
Copy link
Author

aeneasr commented Mar 1, 2018

That's what I thought as well, but I was unable to find a way to consume the swagger-ui react component itself. All I found was the option to instantiate the swagger-ui with some ID, which (presumably) mounts the swagger-ui internal react component there.

It would be really cool if you could point me to some resource that shows how I can consume the react component itself directly! Then I can easily implement SSR myself :)

@aeneasr
Copy link
Author

aeneasr commented Mar 5, 2018

I know you're ( @shockey ) probably incredibly busy and I appreciate the time taken for answering my initial question - I'd really like to get the SSR done and would be very happy to learn how to achieve that, based on my last question :)

@shockey
Copy link
Contributor

shockey commented Mar 27, 2018

Hey again @arekkas - I don't think that it's possible to graft Swagger-UI's component tree into your application's own at the moment, because we assume that we're managing our own:

https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/view/root-injects.js#L69

I'm marking this as an enhancement: I think we could rewire Swagger-UI to provide a "child mode" as opposed to vanilla mounting into a DOM node.

This may also be solved as part of a larger flavor of the project that better supports React users (see #3158, #3934, #3955).

@aeneasr
Copy link
Author

aeneasr commented Mar 30, 2018

Thank you for your reply! That's what I thought. It would be of course very nice to have support to call Swagger-UI directly and thus potentially enable SSR which could help with indexing (e.g. via search engines, SEO) and things like faster page loads.

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

No branches or pull requests

2 participants