Skip to content

Commit fcfdabc

Browse files
committed
add xml/yaml support for jsonstream option
1 parent 2eea393 commit fcfdabc

File tree

9 files changed

+28
-1
lines changed

9 files changed

+28
-1
lines changed

src/Metadata/Extractor/XmlResourceExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ private function buildBase(\SimpleXMLElement $resource): array
145145
'extraProperties' => $this->buildExtraProperties($resource, 'extraProperties'),
146146
'read' => $this->phpize($resource, 'read', 'bool'),
147147
'write' => $this->phpize($resource, 'write', 'bool'),
148+
'jsonStream' => $this->phpize($resource, 'jsonStream', 'bool'),
148149
];
149150
}
150151

src/Metadata/Extractor/YamlResourceExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ private function buildBase(array $resource): array
171171
'messenger' => $this->buildMessenger($resource),
172172
'read' => $this->phpize($resource, 'read', 'bool'),
173173
'write' => $this->phpize($resource, 'write', 'bool'),
174+
'jsonStream' => $this->phpize($resource, 'jsonStream', 'bool'),
174175
];
175176
}
176177

src/Metadata/Extractor/schema/resources.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@
523523
<xsd:attribute type="xsd:string" name="securityPostValidation"/>
524524
<xsd:attribute type="xsd:string" name="securityPostValidationMessage"/>
525525
<xsd:attribute type="xsd:boolean" name="collectDenormalizationErrors"/>
526+
<xsd:attribute type="xsd:boolean" name="jsonStream"/>
526527
</xsd:attributeGroup>
527528

528529
<xsd:attributeGroup name="extendedBase">

src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ final class XmlResourceAdapter implements ResourceAdapterInterface
6565
'hideHydraOperation',
6666
'stateOptions',
6767
'collectDenormalizationErrors',
68+
'jsonStream',
6869
'links',
6970
'parameters',
7071
];
@@ -544,6 +545,11 @@ private function buildParameters(\SimpleXMLElement $resource, ?array $values = n
544545
}
545546
}
546547

548+
private function buildJsonStream(\SimpleXMLElement $resource, bool $value): void
549+
{
550+
$resource->addAttribute('jsonStream', $this->parse($value));
551+
}
552+
547553
private function parse($value): ?string
548554
{
549555
if (null === $value) {

src/Metadata/Tests/Extractor/Adapter/resources.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/Metadata/Tests/Extractor/Adapter/resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ resources:
338338
parameters: null
339339
strictQueryParameterValidation: false
340340
hideHydraOperation: false
341+
jsonStream: true
341342
extraProperties:
342343
custom_property: 'Lorem ipsum dolor sit amet'
343344
another_custom_property:

src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ final class ResourceMetadataCompatibilityTest extends TestCase
163163
'Lorem ipsum' => 'Dolor sit amet',
164164
],
165165
],
166+
'jsonStream' => true,
166167
'mercure' => true,
167168
'stateOptions' => [
168169
'elasticsearchOptions' => [
@@ -472,6 +473,7 @@ final class ResourceMetadataCompatibilityTest extends TestCase
472473
'filters',
473474
'order',
474475
'extraProperties',
476+
'jsonStream',
475477
];
476478
private const EXTENDED_BASE = [
477479
'uriTemplate',
@@ -754,4 +756,9 @@ private function withParameters(array $values): ?array
754756

755757
return $parameters;
756758
}
759+
760+
private function withJsonStream(bool $value): bool
761+
{
762+
return $value;
763+
}
757764
}

src/Metadata/Tests/Extractor/XmlExtractorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function testValidXML(): void
103103
'links' => null,
104104
'headers' => null,
105105
'parameters' => null,
106+
'jsonStream' => null,
106107
],
107108
[
108109
'uriTemplate' => '/users/{author}/comments{._format}',
@@ -278,6 +279,7 @@ public function testValidXML(): void
278279
'headers' => ['hello' => 'world'],
279280
'parameters' => null,
280281
'routeName' => 'custom_route_name',
282+
'jsonStream' => null,
281283
],
282284
[
283285
'name' => null,
@@ -390,6 +392,7 @@ public function testValidXML(): void
390392
),
391393
],
392394
'routeName' => null,
395+
'jsonStream' => null,
393396
],
394397
],
395398
'graphQlOperations' => null,
@@ -401,6 +404,7 @@ public function testValidXML(): void
401404
'links' => null,
402405
'headers' => ['hello' => 'world'],
403406
'parameters' => null,
407+
'jsonStream' => null,
404408
],
405409
],
406410
], $extractor->getResources());

src/Metadata/Tests/Extractor/YamlExtractorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function testValidYaml(): void
102102
'links' => null,
103103
'headers' => null,
104104
'parameters' => null,
105+
'jsonStream' => null,
105106
],
106107
],
107108
Program::class => [
@@ -173,6 +174,7 @@ public function testValidYaml(): void
173174
'links' => null,
174175
'headers' => null,
175176
'parameters' => null,
177+
'jsonStream' => null,
176178
],
177179
[
178180
'uriTemplate' => '/users/{author}/programs{._format}',
@@ -315,6 +317,7 @@ public function testValidYaml(): void
315317
'links' => null,
316318
'headers' => ['hello' => 'world'],
317319
'parameters' => null,
320+
'jsonStream' => null,
318321
],
319322
[
320323
'name' => null,
@@ -400,6 +403,7 @@ public function testValidYaml(): void
400403
'links' => null,
401404
'headers' => ['hello' => 'world'],
402405
'parameters' => ['author' => new QueryParameter(schema: ['type' => 'string'], required: true, key: 'author', description: 'hello')],
406+
'jsonStream' => null,
403407
],
404408
],
405409
'graphQlOperations' => null,
@@ -411,6 +415,7 @@ public function testValidYaml(): void
411415
'links' => null,
412416
'headers' => ['hello' => 'world'],
413417
'parameters' => null,
418+
'jsonStream' => null,
414419
],
415420
],
416421
SingleFileConfigDummy::class => [
@@ -482,6 +487,7 @@ public function testValidYaml(): void
482487
'links' => null,
483488
'headers' => null,
484489
'parameters' => null,
490+
'jsonStream' => null,
485491
],
486492
],
487493
], $extractor->getResources());

0 commit comments

Comments
 (0)