Issue with route change in version 8.6
After updating composer we noticed that Swagger UI is no longer loads JSON annotations. the version that worked fine was 8.6.3 after the update it is now 8.6.5.
You have removed this segment {jsonFile?} from this route $router->get($config['routes']['docs'].'/{jsonFile?}', []) and now it can't load the json file and shows 500 error.
Yes this was removed due to path traversal vulnerability. More details here: https://github.com/DarkaOnLine/L5-Swagger/pull/630
ok, and what is the new way of the handling?
ok, and what is the new way of the handling?
Register path to your json in config $config['paths']['docs_json'] - https://github.com/DarkaOnLine/L5-Swagger/blob/master/src/Http/Controllers/SwaggerController.php#L46
I think it was already defined there, what we are missing?
return [
'default' => 'default',
'documentations' => [
'app' => [
'api' => [
'title' => 'Snapfix Api Specs for web app',
],
'routes' => [
/*
* Route for accessing api documentation interface
*/
'api' => 'api/documentation',
],
'paths' => [
/*
* Edit to include full URL in ui for assetreg
*/
'use_absolute_path' => env('L5_SWAGGER_USE_ABSOLUTE_PATH', true),
/*
* File name of the generated json documentation file
*/
'docs_json' => 'app.json',
/*
* File name of the generated YAML documentation file
*/
'docs_yaml' => 'app.yaml',
/*
* Set this to `json` or `yaml` to determine which documentation file to use in UI
*/
'format_to_use_for_docs' => env('L5_FORMAT_TO_USE_FOR_DOCS', 'json'),
/*
* Absolute paths to directory containing the swagger annotations are stored.
*/
'annotations' => [
base_path('app/Http/Controllers/v1/Openapi/App'),
],
],
],
'admin' => [
'api' => [
'title' => 'Snapfix Api Specs for web admin',
],
'routes' => [
/*
* Route for accessing api documentation interface
*/
'api' => 'api/documentation',
],
'paths' => [
/*
* Edit to include full URL in ui for assetreg
*/
'use_absolute_path' => env('L5_SWAGGER_USE_ABSOLUTE_PATH', true),
/*
* File name of the generated json documentation file
*/
'docs_json' => 'admin.json',
/*
* File name of the generated YAML documentation file
*/
'docs_yaml' => 'admin.yaml',
/*
* Set this to `json` or `yaml` to determine which documentation file to use in UI
*/
'format_to_use_for_docs' => env('L5_FORMAT_TO_USE_FOR_DOCS', 'json'),
/*
* Absolute paths to directory containing the swagger annotations are stored.
*/
'annotations' => [
base_path('app/Http/Controllers/v1/Openapi/Admin'),
],
],
],
],
This broke for me too, I was using multiple config files:
My config:
const ui = SwaggerUIBundle({
dom_id: '#swagger-ui',
urls:[
{ url: "/docs/api-docs.json", name: "API" },
{ url: "/docs/files-docs.json", name: "Arquivos" }
],
[... more code]
And now how to use my multiple files on the same screen?
Could this also have broken ability to generate yaml? Cause I can't make it work.