nextapps-be / laravel-swagger-ui

Add Swagger UI to a Laravel application.
MIT License
160 stars 20 forks source link

Support custom openapi url #9

Closed dommer1 closed 2 years ago

gdebrauwer commented 2 years ago

I think it might be better if we just changed the setup of the SwaggerUIBundle to support external openapi files:

<script>
  window.ui = SwaggerUIBundle({
     url: '{{ filter_var(config('swagger-ui.file'), FILTER_VALIDATE_URL) ? config('swagger-ui.file') : route('swagger-openapi-json', [], false) }}',
     dom_id: '#swagger-ui',
     deepLinking: true,
     presets: [
         SwaggerUIBundle.presets.apis,
     ],
     layout: 'BaseLayout',
  });
</script>

If the swagger-ui.file config value is an url, then that config value will be directly provided as url to swagger-ui, instead of this package's route.

What do you think?

gdebrauwer commented 2 years ago

Or maybe, if the file is located somewhere else, then it still needs to go through the swagger-openapi-json route of the package, so it can update the server url and the oauth urls in the file before the openapi file is shown in swagger-ui 🤔