Closed nathanaelhoun closed 3 months ago
I'm not in favour of this (I think JSON is a terrible format for this), but I'll accept this. However, you need to add it to the config reference and remove it from the default config file (there are too many options; only the most common and important stuff should be there).
Thanks for your understanding. I agree that Yaml format is more readable, but allowing to publish as JSON would be a great enhancement for our deploiement setup.
I replaced the configuration for a more simple toggle scribe.openapi.json
(as it can only be JSON or Yaml according to the OpenAPI spec), and removed it from the default config.
Having put more thought to it, I wonder if it wouldn't be simpler for both of us to add a composer script to my side to convert the yaml to json after building. This would avoid merging this new "niche" feature into Scribe. What do you think?
"scripts": {
"build-docs": [
"@php artisan scribe:generate",
"@php -r \"require 'vendor/autoload.php'; $spec = Symfony\\Component\\Yaml\\Yaml::parseFile('resources/swagger/openapi.yaml'); $json = json_encode($spec, JSON_PRETTY_PRINT); file_put_contents('resources/swagger/openapi.json', $json);\""
]
},
After some time and some thoughts about our usage of Scribe, we have decided to go with the composer script solution. Less software can be better software.
I'll let someone else re-submit this code if they are still interested in it.
Thanks again for making Scribe, it's a real gamechanger.
Alright then! I'm still fine with adding it if it's hidden away.👍
From https://swagger.io/specification/,
This PR adds a configuration toggle to output the OpenAPI document in the JSON format, which is useful to use it with the package nextapps-be/laravel-swagger-ui without the
yaml
PECL extension.