Skip to content

Commit

Permalink
fix(jsonschema): reDoc json sample values (#5638)
Browse files Browse the repository at this point in the history
* fix(jsonschema): fix reDoc json sample values

* fix(JsonSchema): reDoc json sample values

* fix-redoc-json-example-values

- fix(JsonSchema): reDoc json sample values

* fix-redoc-json-example-values

- fix(JsonSchema): reDoc json sample values
  • Loading branch information
ERuban authored Oct 17, 2023
1 parent 5bc4442 commit 7afdabb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion features/openapi/docs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Feature: Documentation support
"""
{
"type": "string",
"format": "iri-reference"
"format": "iri-template"
}
"""
# Enable these tests when SF 4.4 / PHP 7.1 support is dropped
Expand Down
24 changes: 12 additions & 12 deletions src/JsonSchema/Tests/TypeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public static function typeProvider(): iterable
yield [['nullable' => true, 'type' => 'string', 'format' => 'date-time'], new Type(Type::BUILTIN_TYPE_OBJECT, true, \DateTimeImmutable::class)];
yield [['type' => 'string', 'format' => 'duration'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \DateInterval::class)];
yield [['type' => 'string', 'format' => 'binary'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \SplFileInfo::class)];
yield [['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['nullable' => true, 'type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield [['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['nullable' => true, 'type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield ['enum' => ['type' => 'string', 'enum' => ['male', 'female']], new Type(Type::BUILTIN_TYPE_OBJECT, false, GenderTypeEnum::class)];
yield ['nullable enum' => ['type' => 'string', 'enum' => ['male', 'female', null], 'nullable' => true], new Type(Type::BUILTIN_TYPE_OBJECT, true, GenderTypeEnum::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => 'string', 'format' => 'iri-reference', 'nullable' => true], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => 'string', 'format' => 'iri-template', 'nullable' => true], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield [['type' => 'array', 'items' => ['type' => 'string']], new Type(Type::BUILTIN_TYPE_STRING, false, null, true)];
yield 'array can be itself nullable' => [
['nullable' => true, 'type' => 'array', 'items' => ['type' => 'string']],
Expand Down Expand Up @@ -185,12 +185,12 @@ public static function jsonSchemaTypeProvider(): iterable
yield [['type' => ['string', 'null'], 'format' => 'date-time'], new Type(Type::BUILTIN_TYPE_OBJECT, true, \DateTimeImmutable::class)];
yield [['type' => 'string', 'format' => 'duration'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \DateInterval::class)];
yield [['type' => 'string', 'format' => 'binary'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \SplFileInfo::class)];
yield [['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['type' => ['string', 'null'], 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield [['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['type' => ['string', 'null'], 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield ['enum' => ['type' => 'string', 'enum' => ['male', 'female']], new Type(Type::BUILTIN_TYPE_OBJECT, false, GenderTypeEnum::class)];
yield ['nullable enum' => ['type' => ['string', 'null'], 'enum' => ['male', 'female', null]], new Type(Type::BUILTIN_TYPE_OBJECT, true, GenderTypeEnum::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => ['string', 'null'], 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => ['string', 'null'], 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield [['type' => 'array', 'items' => ['type' => 'string']], new Type(Type::BUILTIN_TYPE_STRING, false, null, true)];
yield 'array can be itself nullable' => [
['type' => ['array', 'null'], 'items' => ['type' => 'string']],
Expand Down Expand Up @@ -306,12 +306,12 @@ public static function openAPIV2TypeProvider(): iterable
yield [['type' => 'string', 'format' => 'date-time'], new Type(Type::BUILTIN_TYPE_OBJECT, true, \DateTimeImmutable::class)];
yield [['type' => 'string', 'format' => 'duration'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \DateInterval::class)];
yield [['type' => 'string', 'format' => 'binary'], new Type(Type::BUILTIN_TYPE_OBJECT, false, \SplFileInfo::class)];
yield [['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield [['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)];
yield [['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class)];
yield ['enum' => ['type' => 'string', 'enum' => ['male', 'female']], new Type(Type::BUILTIN_TYPE_OBJECT, false, GenderTypeEnum::class)];
yield ['nullable enum' => ['type' => 'string', 'enum' => ['male', 'female', null]], new Type(Type::BUILTIN_TYPE_OBJECT, true, GenderTypeEnum::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => 'string', 'format' => 'iri-reference'], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield ['enum resource' => ['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, false, GamePlayMode::class)];
yield ['nullable enum resource' => ['type' => 'string', 'format' => 'iri-template'], new Type(Type::BUILTIN_TYPE_OBJECT, true, GamePlayMode::class)];
yield [['type' => 'array', 'items' => ['type' => 'string']], new Type(Type::BUILTIN_TYPE_STRING, false, null, true)];
yield 'array can be itself nullable, but ignored in OpenAPI V2' => [
['type' => 'array', 'items' => ['type' => 'string']],
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/TypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function getClassType(?string $className, bool $nullable, string $format
if (true !== $readableLink && $this->isResourceClass($className)) {
return [
'type' => 'string',
'format' => 'iri-reference',
'format' => 'iri-template',
];
}

Expand Down

0 comments on commit 7afdabb

Please sign in to comment.