Skip to content

Commit 88e0073

Browse files
committed
fix(validator): error xml format output
1 parent fa37c1e commit 88e0073

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/State/ApiResource/Error.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@
8484
'jsonapi' => ['application/vnd.api+json'],
8585
'jsonld' => ['application/ld+json'],
8686
'json' => ['application/problem+json', 'application/json'],
87+
'xml' => ['application/xml', 'text/xml'],
8788
],
8889
),
8990
],
90-
outputFormats: ['jsonapi' => ['application/vnd.api+json'], 'jsonld' => ['application/ld+json'], 'json' => ['application/problem+json', 'application/json']],
91+
outputFormats: [
92+
'jsonapi' => ['application/vnd.api+json'],
93+
'jsonld' => ['application/ld+json'],
94+
'json' => ['application/problem+json', 'application/json'],
95+
'xml' => ['application/xml', 'text/xml'],
96+
],
9197
provider: 'api_platform.state.error_provider',
9298
graphQlOperations: [],
9399
description: 'A representation of common errors.',

src/Validator/Exception/ValidationException.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,22 @@
3737
status: 422,
3838
uriVariables: ['id'],
3939
openapi: false,
40-
outputFormats: ['jsonapi' => ['application/vnd.api+json'], 'jsonld' => ['application/ld+json'], 'json' => ['application/problem+json', 'application/json']],
40+
outputFormats: [
41+
'jsonapi' => ['application/vnd.api+json'],
42+
'jsonld' => ['application/ld+json'],
43+
'json' => ['application/problem+json', 'application/json'],
44+
'xml' => ['application/xml', 'text/xml'],
45+
],
4146
provider: 'api_platform.validator.state.error_provider',
4247
shortName: 'ConstraintViolation',
4348
description: 'Unprocessable entity',
4449
operations: [
4550
new ErrorOperation(
4651
name: '_api_validation_errors_problem',
47-
outputFormats: ['json' => ['application/problem+json']],
52+
outputFormats: [
53+
'json' => ['application/problem+json'],
54+
'xml' => ['application/xml', 'text/xml'],
55+
],
4856
normalizationContext: [
4957
'groups' => ['json'],
5058
'ignored_attributes' => ['trace', 'file', 'line', 'code', 'message', 'traceAsString', 'previous'],

0 commit comments

Comments
 (0)