-
-
Notifications
You must be signed in to change notification settings - Fork 921
Support YAML output from SwaggerCommand with --yaml #1695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test in the CI (like https://github.com/api-platform/core/blob/master/.travis.yml#L56) to check with the Swagger validator that the generated YAML file is valid?
@@ -63,7 +66,11 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
{ | |||
$documentation = new Documentation($this->resourceNameCollectionFactory->create(), $this->apiTitle, $this->apiDescription, $this->apiVersion, $this->apiFormats); | |||
$data = $this->documentationNormalizer->normalize($documentation); | |||
$content = json_encode($data, JSON_PRETTY_PRINT); | |||
if ($input->getOption('yaml')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$input->getOption('yaml') ? Yaml::dump($data) : json_encode($data, JSON_PRETTY_PRINT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you insist. 👍 I try to avoid those.
Sure. Edit: good call, it seems to be invalid. |
66cbedd
to
e249e86
Compare
It seems like this is the output: swagger: '2.0'
basePath: /
info:
title: 'My Dummy API'
version: 0.0.0
description: 'This is a test API.'
paths: null
definitions: null while this is supposed to be the output: swagger: '2.0'
basePath: /
info:
title: 'My Dummy API'
version: 0.0.0
description: 'This is a test API.'
paths: {}
definitions: {} I've added |
@dunglas Don't forget to merge this since you merged the docs describing it already. :) |
Thanks @dkarlovi |
Closes #1688.