From e7bf34d60d6cba93d10fafe4955b958beebfbcf9 Mon Sep 17 00:00:00 2001 From: Arne De Smedt Date: Fri, 24 Nov 2023 10:41:49 +0100 Subject: [PATCH] fix: no boolean types for exclusive minimum and exclusive maximum open api minimum and exclusiveMinimum are merged into one property. The same goes for maximum. See https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0 for more details. --- .../Restriction/PropertySchemaGreaterThanRestriction.php | 3 +-- .../Restriction/PropertySchemaLessThanRestriction.php | 3 +-- .../PropertySchemaGreaterThanRestrictionTest.php | 3 +-- .../Restriction/PropertySchemaLessThanRestrictionTest.php | 3 +-- .../Property/ValidatorPropertyMetadataFactoryTest.php | 8 ++++---- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php index 4fc357d390a..6482cbfda8a 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php @@ -31,8 +31,7 @@ final class PropertySchemaGreaterThanRestriction implements PropertySchemaRestri public function create(Constraint $constraint, ApiProperty $propertyMetadata): array { return [ - 'minimum' => $constraint->value, - 'exclusiveMinimum' => true, + 'exclusiveMinimum' => $constraint->value, ]; } diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php index c7354f9af80..0693aeee3f7 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php @@ -31,8 +31,7 @@ final class PropertySchemaLessThanRestriction implements PropertySchemaRestricti public function create(Constraint $constraint, ApiProperty $propertyMetadata): array { return [ - 'maximum' => $constraint->value, - 'exclusiveMaximum' => true, + 'exclusiveMaximum' => $constraint->value, ]; } diff --git a/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestrictionTest.php b/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestrictionTest.php index bbf45247146..73901abef57 100644 --- a/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestrictionTest.php +++ b/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestrictionTest.php @@ -58,8 +58,7 @@ public static function supportsProvider(): \Generator public function testCreate(): void { self::assertEquals([ - 'minimum' => 10, - 'exclusiveMinimum' => true, + 'exclusiveMinimum' => 10, ], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]))); } } diff --git a/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestrictionTest.php b/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestrictionTest.php index 84e2c1daa64..80409cd3a5f 100644 --- a/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestrictionTest.php +++ b/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestrictionTest.php @@ -58,8 +58,7 @@ public static function supportsProvider(): \Generator public function testCreate(): void { self::assertEquals([ - 'maximum' => 10, - 'exclusiveMaximum' => true, + 'exclusiveMaximum' => 10, ], $this->propertySchemaLessThanRestriction->create(new LessThan(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]))); } } diff --git a/tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php b/tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php index 1a343e47054..0e47960ce3f 100644 --- a/tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php +++ b/tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php @@ -675,7 +675,7 @@ public static function provideNumericConstraintCases(): \Generator yield [ 'propertyMetadata' => (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]), 'property' => 'greaterThanMe', - 'expectedSchema' => ['minimum' => 10, 'exclusiveMinimum' => true], + 'expectedSchema' => ['exclusiveMinimum' => 10], ]; yield [ @@ -687,7 +687,7 @@ public static function provideNumericConstraintCases(): \Generator yield [ 'propertyMetadata' => (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]), 'property' => 'lessThanMe', - 'expectedSchema' => ['maximum' => 99, 'exclusiveMaximum' => true], + 'expectedSchema' => ['exclusiveMaximum' => 99], ]; yield [ @@ -699,7 +699,7 @@ public static function provideNumericConstraintCases(): \Generator yield [ 'propertyMetadata' => (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]), 'property' => 'positive', - 'expectedSchema' => ['minimum' => 0, 'exclusiveMinimum' => true], + 'expectedSchema' => ['exclusiveMinimum' => 0], ]; yield [ @@ -711,7 +711,7 @@ public static function provideNumericConstraintCases(): \Generator yield [ 'propertyMetadata' => (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)]), 'property' => 'negative', - 'expectedSchema' => ['maximum' => 0, 'exclusiveMaximum' => true], + 'expectedSchema' => ['exclusiveMaximum' => 0], ]; yield [