scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.42k stars 225 forks source link

return swaggerInit as part of generateHtml #265

Open MartinMuzatko opened 3 years ago

MartinMuzatko commented 3 years ago

Hello! The state scoped to the module makes it impossible to extract the swaggerInit value for other use when using swagger-ui-express as server-side renderer.

It would be great to get both values (maybe as object or array containing both) as a return value. In the needed places, you can take one or the other. Or if you don't see any alternative, store the return value of generateHtml into a module scoped variable.

Thanks!

scottie1984 commented 2 years ago

Hi, I think I get the principal of this - however not sure exactly how to take it forward without the use case.

Would an additional function that accepted the swaggerDoc & opts and returned the swaggerInit value solve this?

MartinMuzatko commented 2 years ago

Yes that would be great. thank you.

The use case for me was to render the entire file. Recently I switched to swagger react to render my definition.