jhthorsen / mojolicious-plugin-openapi

OpenAPI / Swagger plugin for Mojolicious
54 stars 44 forks source link

Use plugin only for rendering spec? #165

Closed christopherraa closed 4 years ago

christopherraa commented 4 years ago

This is perhaps quite the edge-case, but bear with me.

Say you have three APIs:

These APIs are meant only to be accessed by OpenAPI-clients, with appropriate security measures for that kind of use. They are not meant to be directly accessed by end users (ie: developers).

Having the option of using SpecRenderer to render a html-representation of the API documentation would enable users to expose documentation for multiple APIs through one application tailored for that kind of use. This application would ideally just slurp the yaml/json-specs available one the abovementioned urls and present something human readable. This means that base_url in the rendered documentation would have to point to the location from which the spec was pulled. It would also mean that one would not want the plugin to also register routes for the endpoints found in the api specification that is loaded. Perhaps having skip_route_registration => 1 as an option to the OpenAPI plugin could help with the latter, and preserve_base_url => 1 or something could address the former?

I guess this issue is more of a braindump and an invitation for further discussion. Thoughts?

jhthorsen commented 4 years ago

I didn't do it quite as you described, but pretty close. Check out the commit for details, but...

Hope this works for you!

jhthorsen commented 4 years ago

You might be interested in 9f845236048fd42017f099522362a0aa7a4db9ce as well, as it contains more templates that you can override to apply your own CSS/JavaScript.