Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
* Set it to `null` to use your default disk.
*/
'filesystem_disk' => env('OPEN_API_SPEC_GENERATOR_FILESYSTEM_DISK', null),

/*
* Dump option for the yaml output file, see https://symfony.com/doc/current/components/yaml.html#expanded-and-inlined-arrays
* If you want the yaml output to be fully expanded, set inline to a high value like 1000
*/
'yaml' => [
'format' => [
'inline' => 2,
'indent' => 4
]
]
];
8 changes: 6 additions & 2 deletions src/OpenApiGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ public function generate(string $serverKey, string $format = 'yaml'): string

$storageDisk = Storage::disk(config('openapi.filesystem_disk'));

$fileName = $serverKey.'_openapi.'.$format;
$fileName = $serverKey . '_openapi.' . $format;

if ($format === 'yaml') {
$output = Yaml::dump($openapi->toArray());
$output = Yaml::dump(
$openapi->toArray(),
config('openapi.yaml.format.inline', 2),
config('openapi.yaml.format.indent', 4)
);
} elseif ($format === 'json') {
$output = json_encode($openapi->toArray(), JSON_PRETTY_PRINT);
}
Expand Down