Skip to content

Commit aea8113

Browse files
fix(json-schema): move member property out of HydraCollectionBaseSchema (#7456)
Co-authored-by: Vincent Langlet <VincentLanglet@users.noreply.github.com>
1 parent fa74ed7 commit aea8113

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/Hydra/JsonSchema/SchemaFactory.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,7 @@ public function buildSchema(string $className, string $format = 'jsonld', string
170170

171171
$definitions[self::COLLECTION_BASE_SCHEMA_NAME] = [
172172
'type' => 'object',
173-
'required' => [
174-
$hydraPrefix.'member',
175-
],
176173
'properties' => [
177-
$hydraPrefix.'member' => [
178-
'type' => 'array',
179-
'items' => ['type' => 'object'],
180-
],
181174
$hydraPrefix.'totalItems' => [
182175
'type' => 'integer',
183176
'minimum' => 0,
@@ -249,6 +242,9 @@ public function buildSchema(string $className, string $format = 'jsonld', string
249242
['$ref' => $prefix.self::COLLECTION_BASE_SCHEMA_NAME],
250243
[
251244
'type' => 'object',
245+
'required' => [
246+
$hydraPrefix.'member',
247+
],
252248
'properties' => [
253249
$hydraPrefix.'member' => [
254250
'type' => 'array',

src/Hydra/Tests/JsonSchema/SchemaFactoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public function testSchemaTypeBuildSchema(): void
132132
$this->assertNull($resultSchema->getRootDefinitionKey());
133133
$hydraCollectionSchema = $resultSchema['definitions']['HydraCollectionBaseSchema'];
134134
$properties = $hydraCollectionSchema['properties'];
135-
$this->assertTrue(isset($properties['hydra:member']));
136135
$this->assertArrayHasKey('hydra:totalItems', $properties);
137136
$this->assertArrayHasKey('hydra:view', $properties);
138137
$this->assertArrayHasKey('hydra:search', $properties);

tests/Fixtures/TestBundle/ApiResource/Issue7432/OriginalDataWithListeners.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public static function process($data, Operation $operation, array $uriVariables
3333
{
3434
\assert($data instanceof UserVerifyInput);
3535
\assert($context['previous_data'] instanceof self);
36+
\assert($context['read_data'] instanceof self);
37+
\assert($context['previous_data'] !== $context['read_data']);
3638
\assert($context['request']->attributes->get('data') instanceof UserVerifyInput);
39+
\assert($context['request']->attributes->get('read_data') instanceof self);
3740
\assert($context['request']->attributes->get('previous_data') instanceof self);
3841
\assert($context['data'] instanceof UserVerifyInput);
3942
$context['previous_data']->code = $data->code;

0 commit comments

Comments
 (0)