From c99810f19cca6e70371e45ab2d20b542769a0a46 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 16 Feb 2026 16:23:50 +0100 Subject: [PATCH 1/8] Added const schema type to literals also when in union with other types --- src/Support/Generator/TypeTransformer.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Support/Generator/TypeTransformer.php b/src/Support/Generator/TypeTransformer.php index 53c7bd2b..992beb5c 100644 --- a/src/Support/Generator/TypeTransformer.php +++ b/src/Support/Generator/TypeTransformer.php @@ -204,15 +204,17 @@ public function transform(Type $type): OpenApiType $literalSchemas = []; if ($stringLiterals->count()) { - $items[] = $literalSchemas[] = (new StringType)->enum( - $stringLiterals->map->value->unique()->values()->toArray() // @phpstan-ignore property.notFound - ); + // @phpstan-ignore property.notFound + foreach ($stringLiterals->map->value->unique() as $stringLiteral) { + $items[] = $literalSchemas[] = (new StringType)->const($stringLiteral); + } } if ($integerLiterals->count()) { - $items[] = $literalSchemas[] = (new IntegerType)->enum( - $integerLiterals->map->value->unique()->values()->toArray() // @phpstan-ignore property.notFound - ); + // @phpstan-ignore property.notFound + foreach ($integerLiterals->map->value->unique() as $integerLiteral) { + $items[] = $literalSchemas[] = (new IntegerType)->const($integerLiteral); + } } // In case $otherTypes consist just of null and there is string or integer literals, make type nullable From facfd60ba4ae17eff578d20625674632c1e82733 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 16 Feb 2026 17:12:36 +0100 Subject: [PATCH 2/8] Fixed failing tests --- src/Support/Generator/TypeTransformer.php | 2 +- .../JsonResourceExtensionTest.php | 8 ++++---- tests/TypeToSchemaTransformerTest.php | 9 ++++++++- tests/ValidationRulesDocumentingTest.php | 18 ++++++++---------- ...json_resource_type_with_when_counted__1.yml | 2 +- ...json_resource_type_with_when_counted__2.yml | 2 +- ...s_with_data_set_(_var_foobarstring_)__1.yml | 3 ++- ...s_with_data_set_(_var_foobarstring_)__2.yml | 3 ++- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Support/Generator/TypeTransformer.php b/src/Support/Generator/TypeTransformer.php index 992beb5c..bb8c17d6 100644 --- a/src/Support/Generator/TypeTransformer.php +++ b/src/Support/Generator/TypeTransformer.php @@ -220,7 +220,7 @@ public function transform(Type $type): OpenApiType // In case $otherTypes consist just of null and there is string or integer literals, make type nullable $otherTypesIsNullable = count($otherTypes) === 1 && collect($otherTypes)->contains(fn ($t) => $t instanceof \Dedoc\Scramble\Support\Type\NullType); if ($otherTypesIsNullable && ($stringLiterals->count() || $integerLiterals->count())) { - $items = array_map(fn ($s) => $s->nullable(true), $literalSchemas); + // $items = array_map(fn ($s) => $s->nullable(true), $literalSchemas); } // Removing duplicated schemas before making a resulting AnyOf type. diff --git a/tests/InferExtensions/JsonResourceExtensionTest.php b/tests/InferExtensions/JsonResourceExtensionTest.php index fd5e9539..4bdd34e9 100644 --- a/tests/InferExtensions/JsonResourceExtensionTest.php +++ b/tests/InferExtensions/JsonResourceExtensionTest.php @@ -56,11 +56,11 @@ function JsonResourceExtensionTest_analyze(Infer $infer, OpenApiContext $context 'anyOf' => [ [ 'type' => 'string', - 'enum' => ['foo'], + 'const' => 'foo', ], [ 'type' => 'integer', - 'enum' => [42], + 'const' => 42, ], ], ], @@ -103,8 +103,8 @@ public function toArray(Request $request) 'properties' => [ 'property' => [ 'anyOf' => [ - ['type' => 'string', 'enum' => ['foo']], - ['type' => 'integer', 'enum' => [123]], + ['type' => 'string', 'const' => 'foo'], + ['type' => 'integer', 'const' => 123], ], ], ], diff --git a/tests/TypeToSchemaTransformerTest.php b/tests/TypeToSchemaTransformerTest.php index 31302013..88a210b9 100644 --- a/tests/TypeToSchemaTransformerTest.php +++ b/tests/TypeToSchemaTransformerTest.php @@ -83,7 +83,14 @@ new LiteralStringType('charging'), new LiteralStringType('discharging'), new NullType, - ]), ['type' => ['string', 'null'], 'enum' => ['idle', 'charging', 'discharging']]], + ]), [ + 'anyOf' => [ + [ 'type' => 'null' ], + [ 'type' => 'string', 'const' => 'idle' ], + [ 'type' => 'string', 'const' => 'charging' ], + [ 'type' => 'string', 'const' => 'discharging' ], + ] + ]], ]); it('gets json resource type', function () { diff --git a/tests/ValidationRulesDocumentingTest.php b/tests/ValidationRulesDocumentingTest.php index e91920d2..b1e9ae91 100644 --- a/tests/ValidationRulesDocumentingTest.php +++ b/tests/ValidationRulesDocumentingTest.php @@ -474,11 +474,10 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) $params = ($this->buildRulesToParameters)($rules)->handle(); expect($params[0]->toArray()['schema'])->toBe([ - 'type' => 'string', - 'enum' => [ - 'draft', - 'archived', - ], + 'anyOf' => [ + ['type' => 'string', 'const' => 'draft'], + ['type' => 'string', 'const' => 'archived'], + ] ]); }); @@ -490,11 +489,10 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) $params = ($this->buildRulesToParameters)($rules)->handle(); expect($params[0]->toArray()['schema'])->toBe([ - 'type' => 'string', - 'enum' => [ - 'published', - 'archived', - ], + 'anyOf' => [ + ['type' => 'string', 'const' => 'published'], + ['type' => 'string', 'const' => 'archived'], + ] ]); }); } diff --git a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml index fababc54..09deb05f 100644 --- a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml +++ b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml @@ -2,7 +2,7 @@ type: object properties: bar_single: { type: integer } bar_fake_count: { type: integer, const: 1 } - bar_different_literal_types: { type: integer, enum: [1, 5] } + bar_different_literal_types: { anyOf: [{ type: integer, const: 1 }, { type: integer, const: 5 }] } bar_identical_literal_types: { type: integer, const: 1 } bar_string: { type: string, const: '2' } bar_int: { type: integer, const: 1 } diff --git a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml index fababc54..09deb05f 100644 --- a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml +++ b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml @@ -2,7 +2,7 @@ type: object properties: bar_single: { type: integer } bar_fake_count: { type: integer, const: 1 } - bar_different_literal_types: { type: integer, enum: [1, 5] } + bar_different_literal_types: { anyOf: [{ type: integer, const: 1 }, { type: integer, const: 5 }] } bar_identical_literal_types: { type: integer, const: 1 } bar_string: { type: string, const: '2' } bar_int: { type: integer, const: 1 } diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml index 90c73310..9f710455 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml @@ -1,3 +1,4 @@ anyOf: - { type: string } - - { type: string, enum: [foo, bar] } + - { type: string, const: foo } + - { type: string, const: bar } diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml index 90c73310..9f710455 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml @@ -1,3 +1,4 @@ anyOf: - { type: string } - - { type: string, enum: [foo, bar] } + - { type: string, const: foo } + - { type: string, const: bar } From 1f54de02fbf6d7ad31fd2ca827161c486f9cc5d6 Mon Sep 17 00:00:00 2001 From: apasquini95 Date: Mon, 16 Feb 2026 16:13:15 +0000 Subject: [PATCH 3/8] Fix styling --- tests/TypeToSchemaTransformerTest.php | 10 +++++----- tests/ValidationRulesDocumentingTest.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/TypeToSchemaTransformerTest.php b/tests/TypeToSchemaTransformerTest.php index 88a210b9..b8f6dc5e 100644 --- a/tests/TypeToSchemaTransformerTest.php +++ b/tests/TypeToSchemaTransformerTest.php @@ -85,11 +85,11 @@ new NullType, ]), [ 'anyOf' => [ - [ 'type' => 'null' ], - [ 'type' => 'string', 'const' => 'idle' ], - [ 'type' => 'string', 'const' => 'charging' ], - [ 'type' => 'string', 'const' => 'discharging' ], - ] + ['type' => 'null'], + ['type' => 'string', 'const' => 'idle'], + ['type' => 'string', 'const' => 'charging'], + ['type' => 'string', 'const' => 'discharging'], + ], ]], ]); diff --git a/tests/ValidationRulesDocumentingTest.php b/tests/ValidationRulesDocumentingTest.php index b1e9ae91..2033d8d0 100644 --- a/tests/ValidationRulesDocumentingTest.php +++ b/tests/ValidationRulesDocumentingTest.php @@ -477,7 +477,7 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) 'anyOf' => [ ['type' => 'string', 'const' => 'draft'], ['type' => 'string', 'const' => 'archived'], - ] + ], ]); }); @@ -492,7 +492,7 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) 'anyOf' => [ ['type' => 'string', 'const' => 'published'], ['type' => 'string', 'const' => 'archived'], - ] + ], ]); }); } From 71272471916ff600501c805560a7e1230c1320f1 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 17 Feb 2026 13:42:33 +0100 Subject: [PATCH 4/8] Changed literals union type null handling --- src/Support/Generator/TypeTransformer.php | 30 +++++++++++-------- tests/TypeToSchemaTransformerTest.php | 9 +----- ...son_resource_type_with_when_counted__1.yml | 2 +- ...son_resource_type_with_when_counted__2.yml | 2 +- ..._with_data_set_(_var_foobarstring_)__1.yml | 3 +- ..._with_data_set_(_var_foobarstring_)__2.yml | 3 +- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/Support/Generator/TypeTransformer.php b/src/Support/Generator/TypeTransformer.php index bb8c17d6..2ce8cc2c 100644 --- a/src/Support/Generator/TypeTransformer.php +++ b/src/Support/Generator/TypeTransformer.php @@ -203,24 +203,30 @@ public function transform(Type $type): OpenApiType $items = array_map($this->transform(...), $otherTypes->values()->toArray()); // @phpstan-ignore argument.type $literalSchemas = []; - if ($stringLiterals->count()) { - // @phpstan-ignore property.notFound - foreach ($stringLiterals->map->value->unique() as $stringLiteral) { - $items[] = $literalSchemas[] = (new StringType)->const($stringLiteral); - } + if ($stringLiteralsCount = $stringLiterals->count()) { + if ($stringLiteralsCount > 1) { + $items[] = $literalSchemas[] = (new StringType)->enum( + $stringLiterals->map->value->unique()->values()->toArray() // @phpstan-ignore property.notFound + ); + } else { + $items[] = (new StringType)->const($stringLiterals->first()->value); + } } - if ($integerLiterals->count()) { - // @phpstan-ignore property.notFound - foreach ($integerLiterals->map->value->unique() as $integerLiteral) { - $items[] = $literalSchemas[] = (new IntegerType)->const($integerLiteral); - } + if ($integerLiteralsCount = $integerLiterals->count()) { + if ($integerLiteralsCount > 1) { + $items[] = $literalSchemas[] = (new IntegerType)->enum( + $integerLiterals->map->value->unique()->values()->toArray() // @phpstan-ignore property.notFound + ); + } else { + $items[] = (new IntegerType)->const($integerLiterals->first()->value); + } } // In case $otherTypes consist just of null and there is string or integer literals, make type nullable $otherTypesIsNullable = count($otherTypes) === 1 && collect($otherTypes)->contains(fn ($t) => $t instanceof \Dedoc\Scramble\Support\Type\NullType); - if ($otherTypesIsNullable && ($stringLiterals->count() || $integerLiterals->count())) { - // $items = array_map(fn ($s) => $s->nullable(true), $literalSchemas); + if ($otherTypesIsNullable && count($literalSchemas)) { + $items = array_map(fn ($s) => $s->nullable(true), $literalSchemas); } // Removing duplicated schemas before making a resulting AnyOf type. diff --git a/tests/TypeToSchemaTransformerTest.php b/tests/TypeToSchemaTransformerTest.php index b8f6dc5e..bec5cb1d 100644 --- a/tests/TypeToSchemaTransformerTest.php +++ b/tests/TypeToSchemaTransformerTest.php @@ -83,14 +83,7 @@ new LiteralStringType('charging'), new LiteralStringType('discharging'), new NullType, - ]), [ - 'anyOf' => [ - ['type' => 'null'], - ['type' => 'string', 'const' => 'idle'], - ['type' => 'string', 'const' => 'charging'], - ['type' => 'string', 'const' => 'discharging'], - ], - ]], + ]), [ 'type' => ['string', 'null'], 'enum' => ['idle', 'charging', 'discharging'] ]], ]); it('gets json resource type', function () { diff --git a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml index 09deb05f..fababc54 100644 --- a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml +++ b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__1.yml @@ -2,7 +2,7 @@ type: object properties: bar_single: { type: integer } bar_fake_count: { type: integer, const: 1 } - bar_different_literal_types: { anyOf: [{ type: integer, const: 1 }, { type: integer, const: 5 }] } + bar_different_literal_types: { type: integer, enum: [1, 5] } bar_identical_literal_types: { type: integer, const: 1 } bar_string: { type: string, const: '2' } bar_int: { type: integer, const: 1 } diff --git a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml index 09deb05f..fababc54 100644 --- a/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml +++ b/tests/__snapshots__/TypeToSchemaTransformerTest__it_gets_json_resource_type_with_when_counted__2.yml @@ -2,7 +2,7 @@ type: object properties: bar_single: { type: integer } bar_fake_count: { type: integer, const: 1 } - bar_different_literal_types: { anyOf: [{ type: integer, const: 1 }, { type: integer, const: 5 }] } + bar_different_literal_types: { type: integer, enum: [1, 5] } bar_identical_literal_types: { type: integer, const: 1 } bar_string: { type: string, const: '2' } bar_int: { type: integer, const: 1 } diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml index 9f710455..e077fdb6 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml @@ -1,4 +1,3 @@ anyOf: - { type: string } - - { type: string, const: foo } - - { type: string, const: bar } + - { type: string, enum: [foo, bar] } \ No newline at end of file diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml index 9f710455..e077fdb6 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml @@ -1,4 +1,3 @@ anyOf: - { type: string } - - { type: string, const: foo } - - { type: string, const: bar } + - { type: string, enum: [foo, bar] } \ No newline at end of file From de7a8d6038fbfa6e3876c1d259ec74066454066e Mon Sep 17 00:00:00 2001 From: apasquini95 Date: Tue, 17 Feb 2026 12:43:06 +0000 Subject: [PATCH 5/8] Fix styling --- src/Support/Generator/TypeTransformer.php | 4 ++-- tests/TypeToSchemaTransformerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Support/Generator/TypeTransformer.php b/src/Support/Generator/TypeTransformer.php index 2ce8cc2c..e3ea3df1 100644 --- a/src/Support/Generator/TypeTransformer.php +++ b/src/Support/Generator/TypeTransformer.php @@ -210,7 +210,7 @@ public function transform(Type $type): OpenApiType ); } else { $items[] = (new StringType)->const($stringLiterals->first()->value); - } + } } if ($integerLiteralsCount = $integerLiterals->count()) { @@ -220,7 +220,7 @@ public function transform(Type $type): OpenApiType ); } else { $items[] = (new IntegerType)->const($integerLiterals->first()->value); - } + } } // In case $otherTypes consist just of null and there is string or integer literals, make type nullable diff --git a/tests/TypeToSchemaTransformerTest.php b/tests/TypeToSchemaTransformerTest.php index bec5cb1d..31302013 100644 --- a/tests/TypeToSchemaTransformerTest.php +++ b/tests/TypeToSchemaTransformerTest.php @@ -83,7 +83,7 @@ new LiteralStringType('charging'), new LiteralStringType('discharging'), new NullType, - ]), [ 'type' => ['string', 'null'], 'enum' => ['idle', 'charging', 'discharging'] ]], + ]), ['type' => ['string', 'null'], 'enum' => ['idle', 'charging', 'discharging']]], ]); it('gets json resource type', function () { From 2d55bc13e23965b2601ca0e13f86471b39fb05e4 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 17 Feb 2026 14:12:00 +0100 Subject: [PATCH 6/8] Fixed failing tests --- tests/ValidationRulesDocumentingTest.php | 12 ++++-------- ...ring_literals_with_data_set_(_var_foobar_)__1.yml | 2 +- ...ring_literals_with_data_set_(_var_foobar_)__2.yml | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/ValidationRulesDocumentingTest.php b/tests/ValidationRulesDocumentingTest.php index 2033d8d0..da9d77e3 100644 --- a/tests/ValidationRulesDocumentingTest.php +++ b/tests/ValidationRulesDocumentingTest.php @@ -474,10 +474,8 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) $params = ($this->buildRulesToParameters)($rules)->handle(); expect($params[0]->toArray()['schema'])->toBe([ - 'anyOf' => [ - ['type' => 'string', 'const' => 'draft'], - ['type' => 'string', 'const' => 'archived'], - ], + 'type' => 'string', + 'enum' => [ 'draft', 'archived' ], ]); }); @@ -489,10 +487,8 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) $params = ($this->buildRulesToParameters)($rules)->handle(); expect($params[0]->toArray()['schema'])->toBe([ - 'anyOf' => [ - ['type' => 'string', 'const' => 'published'], - ['type' => 'string', 'const' => 'archived'], - ], + 'type' => 'string', + 'enum' => [ 'published', 'archived' ], ]); }); } diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml index 1942b935..827d93f5 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml @@ -1,4 +1,4 @@ type: string enum: - foo - - bar + - bar \ No newline at end of file diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml index 1942b935..827d93f5 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml @@ -1,4 +1,4 @@ type: string enum: - foo - - bar + - bar \ No newline at end of file From f97d04bbb3914563a47aeca9d8f9de0cb59111b5 Mon Sep 17 00:00:00 2001 From: apasquini95 Date: Tue, 17 Feb 2026 13:12:40 +0000 Subject: [PATCH 7/8] Fix styling --- tests/ValidationRulesDocumentingTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ValidationRulesDocumentingTest.php b/tests/ValidationRulesDocumentingTest.php index da9d77e3..5e5aa983 100644 --- a/tests/ValidationRulesDocumentingTest.php +++ b/tests/ValidationRulesDocumentingTest.php @@ -475,7 +475,7 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) expect($params[0]->toArray()['schema'])->toBe([ 'type' => 'string', - 'enum' => [ 'draft', 'archived' ], + 'enum' => ['draft', 'archived'], ]); }); @@ -487,8 +487,8 @@ function validationRulesToDocumentationWithDeep($rulesToParameters) $params = ($this->buildRulesToParameters)($rules)->handle(); expect($params[0]->toArray()['schema'])->toBe([ - 'type' => 'string', - 'enum' => [ 'published', 'archived' ], + 'type' => 'string', + 'enum' => ['published', 'archived'], ]); }); } From 75a1830230f55dd97e518e140363a6136caa7002 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 17 Feb 2026 14:21:33 +0100 Subject: [PATCH 8/8] Fixed failing tests --- ...nions_of_string_literals_with_data_set_(_var_foobar_)__1.yml | 2 +- ...nions_of_string_literals_with_data_set_(_var_foobar_)__2.yml | 2 +- ...of_string_literals_with_data_set_(_var_foobarstring_)__1.yml | 2 +- ...of_string_literals_with_data_set_(_var_foobarstring_)__2.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml index 827d93f5..1942b935 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__1.yml @@ -1,4 +1,4 @@ type: string enum: - foo - - bar \ No newline at end of file + - bar diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml index 827d93f5..1942b935 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobar_)__2.yml @@ -1,4 +1,4 @@ type: string enum: - foo - - bar \ No newline at end of file + - bar diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml index e077fdb6..90c73310 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__1.yml @@ -1,3 +1,3 @@ anyOf: - { type: string } - - { type: string, enum: [foo, bar] } \ No newline at end of file + - { type: string, enum: [foo, bar] } diff --git a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml index e077fdb6..90c73310 100644 --- a/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml +++ b/tests/__snapshots__/TypesRecognitionTest__it_handles_unions_of_string_literals_with_data_set_(_var_foobarstring_)__2.yml @@ -1,3 +1,3 @@ anyOf: - { type: string } - - { type: string, enum: [foo, bar] } \ No newline at end of file + - { type: string, enum: [foo, bar] }