Skip to content

Commit 10c935e

Browse files
committed
Merge branch '2.3'
2 parents 474d70f + 19800ac commit 10c935e

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

features/hydra/docs.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Feature: Documentation support
3232
# Root properties
3333
And the JSON node "@id" should be equal to "/docs.jsonld"
3434
And the JSON node "hydra:title" should be equal to "My Dummy API"
35-
And the JSON node "hydra:description" should be equal to "This is a test API."
35+
And the JSON node "hydra:description" should contain "This is a test API."
36+
And the JSON node "hydra:description" should contain "Made with love"
3637
And the JSON node "hydra:entrypoint" should be equal to "/"
3738
# Supported classes
3839
And the Hydra class "The API entrypoint" exists

features/swagger/docs.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Feature: Documentation support
1313
And the JSON node "swagger" should be equal to "2.0"
1414
# Root properties
1515
And the JSON node "info.title" should be equal to "My Dummy API"
16-
And the JSON node "info.description" should be equal to "This is a test API."
16+
And the JSON node "info.description" should contain "This is a test API."
17+
And the JSON node "info.description" should contain "Made with love"
1718
# Supported classes
1819
And the Swagger class "AbstractDummy" exists
1920
And the Swagger class "CircularReference" exists

src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080

8181
$documentation = new Documentation($this->resourceNameCollectionFactory->create(), $this->apiTitle, $this->apiDescription, $this->apiVersion, $this->apiFormats);
8282
$data = $this->normalizer->normalize($documentation, DocumentationNormalizer::FORMAT, ['spec_version' => (int) $version]);
83-
$content = $input->getOption('yaml') ? Yaml::dump($data, 10, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE) : (json_encode($data, JSON_PRETTY_PRINT) ?: '');
83+
$content = $input->getOption('yaml') ? Yaml::dump($data, 10, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK) : (json_encode($data, JSON_PRETTY_PRINT) ?: '');
8484

8585
if (!empty($filename = $input->getOption('output')) && \is_string($filename)) {
8686
file_put_contents($filename, $content);

tests/Bridge/Symfony/Bundle/Command/SwaggerCommandTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ public function testExecuteWithYamlVersion3()
8181

8282
$this->assertContains($expected, $result, 'arrays should be correctly formatted.');
8383
$this->assertContains('openapi: 3.0.2', $result);
84+
85+
$expected = <<<YAML
86+
info:
87+
title: 'My Dummy API'
88+
version: 0.0.0
89+
description: |
90+
This is a test API.
91+
Made with love
92+
YAML;
93+
$this->assertContains($expected, $result, 'multiline formatting must be preserved (using literal style).');
8494
}
8595

8696
public function testExecuteOpenApiVersion2WithYaml()

tests/Fixtures/app/config/config_common.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ mercure:
4141

4242
api_platform:
4343
title: 'My Dummy API'
44-
description: 'This is a test API.'
44+
description: |
45+
This is a test API.
46+
Made with love
4547
allow_plain_identifiers: true
4648
formats:
4749
jsonld: ['application/ld+json']

0 commit comments

Comments
 (0)