Skip to content

Commit dddb970

Browse files
authoredNov 6, 2024··
fix(symfony): default formats order (#6780)
1 parent 25aaa3f commit dddb970

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
 

Diff for: ‎src/Symfony/Bundle/DependencyInjection/Configuration.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\Messenger\MessageBusInterface;
3838
use Symfony\Component\Serializer\Exception\ExceptionInterface as SerializerExceptionInterface;
3939
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
40+
use Symfony\Component\Yaml\Yaml;
4041

4142
/**
4243
* The configuration of the bundle.
@@ -169,12 +170,19 @@ public function getConfigTreeBuilder(): TreeBuilder
169170
$this->addFormatSection($rootNode, 'patch_formats', [
170171
'json' => ['mime_types' => ['application/merge-patch+json']],
171172
]);
172-
$this->addFormatSection($rootNode, 'docs_formats', [
173-
'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']],
174-
'yamlopenapi' => ['mime_types' => ['application/vnd.openapi+yaml']],
173+
174+
$defaultDocFormats = [
175175
'jsonld' => ['mime_types' => ['application/ld+json']],
176+
'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']],
176177
'html' => ['mime_types' => ['text/html']],
177-
]);
178+
];
179+
180+
if (class_exists(Yaml::class)) {
181+
$defaultDocFormats['yamlopenapi'] = ['mime_types' => ['application/vnd.openapi+yaml']];
182+
}
183+
184+
$this->addFormatSection($rootNode, 'docs_formats', $defaultDocFormats);
185+
178186
$this->addFormatSection($rootNode, 'error_formats', [
179187
'jsonld' => ['mime_types' => ['application/ld+json']],
180188
'jsonproblem' => ['mime_types' => ['application/problem+json']],

0 commit comments

Comments
 (0)
Please sign in to comment.