diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
index f465798713a..71b2c16122b 100644
--- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
+++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
@@ -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');
}
diff --git a/src/Symfony/Bundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DependencyInjection/Configuration.php
index 2e1b5734283..8a5ed8f670f 100644
--- a/src/Symfony/Bundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/DependencyInjection/Configuration.php
@@ -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()
+ ->scalarNode('validation_error_resource_class')->defaultNull()->info('The class used to represent validation errors in the OpenAPI documentation.')->end()
->end()
->end()
->end();
diff --git a/src/Symfony/Bundle/Resources/config/openapi.xml b/src/Symfony/Bundle/Resources/config/openapi.xml
index 9245f89e86f..4e738bb4275 100644
--- a/src/Symfony/Bundle/Resources/config/openapi.xml
+++ b/src/Symfony/Bundle/Resources/config/openapi.xml
@@ -62,6 +62,8 @@
%api_platform.swagger.persist_authorization%
%api_platform.swagger.http_auth%
%api_platform.openapi.tags%
+ %api_platform.openapi.errorResourceClass%
+ %api_platform.openapi.validationErrorResourceClass%
%api_platform.openapi.license.identifier%
diff --git a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php
index b597141efa4..bbb1dc8e659 100644
--- a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php
+++ b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php
@@ -221,6 +221,8 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
'swagger_ui_extra_configuration' => [],
'overrideResponses' => true,
'tags' => [],
+ 'error_resource_class' => null,
+ 'validation_error_resource_class' => null,
],
'maker' => [
'enabled' => true,