Skip to content

Commit

Permalink
value of const keyword should be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaguerre committed Mar 2, 2022
1 parent 8b2bf92 commit 874616f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function build(\Reflector $reflector, Context $context): array
}
if (Generator::isDefault($instance->type)) {
$instance->type = 'const';
$instance->const = [$rc->getValue()];
$instance->const = $rc->getValue();
}
$annotations[] = $instance;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Annotations/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ class Schema extends AbstractAnnotation

/**
* https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.24.
*
* @var string
*/
public $const = Generator::UNDEFINED;

Expand All @@ -362,6 +364,7 @@ class Schema extends AbstractAnnotation
'allOf' => '[' . Schema::class . ']',
'oneOf' => '[' . Schema::class . ']',
'anyOf' => '[' . Schema::class . ']',
'const' => 'string',
];

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Attributes/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct(
?int $minItems = null,
?bool $uniqueItems = null,
?string $pattern = null,
?string $const = null,
?array $enum = null,
?Discriminator $discriminator = null,
?bool $readOnly = null,
Expand Down Expand Up @@ -78,6 +79,7 @@ public function __construct(
'minItems' => $minItems ?? Generator::UNDEFINED,
'uniqueItems' => $uniqueItems ?? Generator::UNDEFINED,
'pattern' => $pattern ?? Generator::UNDEFINED,
'const' => $const ?? Generator::UNDEFINED,
'enum' => $enum ?? Generator::UNDEFINED,
'readOnly' => $readOnly ?? Generator::UNDEFINED,
'writeOnly' => $writeOnly ?? Generator::UNDEFINED,
Expand Down

0 comments on commit 874616f

Please sign in to comment.