Skip to content

Commit 51fe6a6

Browse files
committed
fix(symfony): default formats
1 parent 25aaa3f commit 51fe6a6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,19 @@ public function getConfigTreeBuilder(): TreeBuilder
169169
$this->addFormatSection($rootNode, 'patch_formats', [
170170
'json' => ['mime_types' => ['application/merge-patch+json']],
171171
]);
172-
$this->addFormatSection($rootNode, 'docs_formats', [
173-
'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']],
174-
'yamlopenapi' => ['mime_types' => ['application/vnd.openapi+yaml']],
172+
173+
$defaultDocFormats = [
175174
'jsonld' => ['mime_types' => ['application/ld+json']],
175+
'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']],
176176
'html' => ['mime_types' => ['text/html']],
177-
]);
177+
];
178+
179+
if (class_exists(Yaml::class)) {
180+
$defaultDocFormats['yamlopenapi'] = ['mime_types' => ['application/vnd.openapi+yaml']];
181+
}
182+
183+
$this->addFormatSection($rootNode, 'docs_formats', $defaultDocFormats);
184+
178185
$this->addFormatSection($rootNode, 'error_formats', [
179186
'jsonld' => ['mime_types' => ['application/ld+json']],
180187
'jsonproblem' => ['mime_types' => ['application/problem+json']],

0 commit comments

Comments
 (0)