I'm trying to create a controller to render a swagger documentation using the module swagger_ui_formatter that provide a formatter to the file field that render swagger files (yml, yaml, json) using javascript libraries to show the documentation like swagger website do. Then i copy my yml file in my module directory and in my controller i can load this file.
public function buildApiDocumentation() {
$file_system = \Drupal::service('file_system');
$searchFiles = '/^.*\.(yml)$/';
$directory = dirname(__DIR__,2).'/docs';
$file = $file_system->scanDirectory($directory, $searchFiles, ['recurse' => FALSE]);
}
But i don't know how can i render this file using the swagger formatter that the module provide, i can't use the traditional way to use this formatter, creating a content type with a file field and after that create a view and render it, because is a very manual process and i need to fix the api documentation file in a directory that only the dev team can update.