Skip to content

Commit ea5be4b

Browse files
committed
Merge 3.2
2 parents 8df681e + e35c021 commit ea5be4b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Bundle/Resources/config/json_schema.xml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<argument type="service" id="api_platform.json_schema.metadata.property.metadata_factory.schema.inner" />
3737
</service>
3838

39+
<service id="api_platform.json_schema.backward_compatible_schema_factory" decorates="api_platform.json_schema.schema_factory" decoration-priority="-2" class="ApiPlatform\JsonSchema\BackwardCompatibleSchemaFactory">
40+
<argument type="service" id="api_platform.json_schema.backward_compatible_schema_factory.inner" />
41+
</service>
42+
3943
</services>
4044

4145
</container>

Bundle/Test/ApiTestAssertionsTrait.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace ApiPlatform\Symfony\Bundle\Test;
1515

16+
use ApiPlatform\JsonSchema\BackwardCompatibleSchemaFactory;
1617
use ApiPlatform\JsonSchema\Schema;
1718
use ApiPlatform\JsonSchema\SchemaFactoryInterface;
1819
use ApiPlatform\Metadata\Get;
@@ -118,7 +119,7 @@ public static function assertMatchesResourceCollectionJsonSchema(string $resourc
118119
$operation = $operationName ? (new GetCollection())->withName($operationName) : new GetCollection();
119120
}
120121

121-
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, $serializationContext);
122+
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, ($serializationContext ?? []) + [BackwardCompatibleSchemaFactory::SCHEMA_DRAFT4_VERSION => true]);
122123

123124
static::assertMatchesJsonSchema($schema->getArrayCopy());
124125
}
@@ -133,7 +134,7 @@ public static function assertMatchesResourceItemJsonSchema(string $resourceClass
133134
$operation = $operationName ? (new Get())->withName($operationName) : new Get();
134135
}
135136

136-
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, $serializationContext);
137+
$schema = $schemaFactory->buildSchema($resourceClass, $format, Schema::TYPE_OUTPUT, $operation, null, ($serializationContext ?? []) + [BackwardCompatibleSchemaFactory::SCHEMA_DRAFT4_VERSION => true]);
137138

138139
static::assertMatchesJsonSchema($schema->getArrayCopy());
139140
}

0 commit comments

Comments
 (0)