Skip to content

Commit cb5ede1

Browse files
authoredFeb 22, 2025··
feat: add checkMode parameter to control json schema validation (#6974)
1 parent 6c2e431 commit cb5ede1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function assertMatchesJsonSchema(object|array|string $jsonSchema,
113113
static::assertThat(self::getHttpResponse()->toArray(false), $constraint, $message);
114114
}
115115

116-
public static function assertMatchesResourceCollectionJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld', ?array $serializationContext = null): void
116+
public static function assertMatchesResourceCollectionJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld', ?array $serializationContext = null, ?int $checkMode = null): void
117117
{
118118
$schemaFactory = self::getSchemaFactory();
119119

@@ -127,10 +127,10 @@ public static function assertMatchesResourceCollectionJsonSchema(string $resourc
127127

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

130-
static::assertMatchesJsonSchema($schema->getArrayCopy());
130+
static::assertMatchesJsonSchema($schema->getArrayCopy(), $checkMode);
131131
}
132132

133-
public static function assertMatchesResourceItemJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld', ?array $serializationContext = null): void
133+
public static function assertMatchesResourceItemJsonSchema(string $resourceClass, ?string $operationName = null, string $format = 'jsonld', ?array $serializationContext = null, ?int $checkMode = null): void
134134
{
135135
$schemaFactory = self::getSchemaFactory();
136136

@@ -144,7 +144,7 @@ public static function assertMatchesResourceItemJsonSchema(string $resourceClass
144144

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

147-
static::assertMatchesJsonSchema($schema->getArrayCopy());
147+
static::assertMatchesJsonSchema($schema->getArrayCopy(), $checkMode);
148148
}
149149

150150
/**

0 commit comments

Comments
 (0)
Please sign in to comment.