|
37 | 37 | use Symfony\Component\Messenger\MessageBusInterface;
|
38 | 38 | use Symfony\Component\Serializer\Exception\ExceptionInterface as SerializerExceptionInterface;
|
39 | 39 | use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
|
| 40 | +use Symfony\Component\Yaml\Yaml; |
40 | 41 |
|
41 | 42 | /**
|
42 | 43 | * The configuration of the bundle.
|
@@ -169,12 +170,19 @@ public function getConfigTreeBuilder(): TreeBuilder
|
169 | 170 | $this->addFormatSection($rootNode, 'patch_formats', [
|
170 | 171 | 'json' => ['mime_types' => ['application/merge-patch+json']],
|
171 | 172 | ]);
|
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 = [ |
175 | 175 | 'jsonld' => ['mime_types' => ['application/ld+json']],
|
| 176 | + 'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']], |
176 | 177 | '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 | + |
178 | 186 | $this->addFormatSection($rootNode, 'error_formats', [
|
179 | 187 | 'jsonld' => ['mime_types' => ['application/ld+json']],
|
180 | 188 | 'jsonproblem' => ['mime_types' => ['application/problem+json']],
|
|
0 commit comments