Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,9 @@ private function registerOpenApiConfiguration(ContainerBuilder $container, array

$container->setParameter('api_platform.openapi.tags', $tags);

$container->setParameter('api_platform.openapi.errorResourceClass', $config['openapi']['error_resource_class'] ?? null);
$container->setParameter('api_platform.openapi.validationErrorResourceClass', $config['openapi']['validation_error_resource_class'] ?? null);

$loader->load('json_schema.xml');
}

Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ private function addOpenApiSection(ArrayNodeDefinition $rootNode): void
->end()
->info('To pass extra configuration to Swagger UI, like docExpansion or filter.')
->end()
->booleanNode('overrideResponses')->defaultTrue()->info('Whether API Platform adds automatic responses to the OpenAPI documentation.')
->booleanNode('overrideResponses')->defaultTrue()->info('Whether API Platform adds automatic responses to the OpenAPI documentation.')->end()
->scalarNode('error_resource_class')->defaultNull()->info('The class used to represent errors in the OpenAPI documentation.')->end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be camel cased to match other configuration names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony use snake case for configs. In the current section, we have both swagger_ui_extra_configuration and overrideResponses.

It will be nice to use snake case for new options and rename options with camel case in 5.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually its overrideResponses that's wrong :D

->scalarNode('validation_error_resource_class')->defaultNull()->info('The class used to represent validation errors in the OpenAPI documentation.')->end()
->end()
->end()
->end();
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/Resources/config/openapi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<argument>%api_platform.swagger.persist_authorization%</argument>
<argument>%api_platform.swagger.http_auth%</argument>
<argument>%api_platform.openapi.tags%</argument>
<argument>%api_platform.openapi.errorResourceClass%</argument>
<argument>%api_platform.openapi.validationErrorResourceClass%</argument>
<argument>%api_platform.openapi.license.identifier%</argument>
</service>
<service id="ApiPlatform\OpenApi\Options" alias="api_platform.openapi.options" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@
'swagger_ui_extra_configuration' => [],
'overrideResponses' => true,
'tags' => [],
'error_resource_class' => null,
'validation_error_resource_class' => null,

Check warning on line 225 in tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

View check run for this annotation

Codecov / codecov/patch

tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php#L224-L225

Added lines #L224 - L225 were not covered by tests
],
'maker' => [
'enabled' => true,
Expand Down
Loading