Closed rcoiffard closed 3 years ago
I could be wrong but maybe the solution is simple by adding this in \Elao\Enum\Bridge\ApiPlatform\Core\JsonSchema\Type\ElaoEnumType::getType
:
public function getType(Type $type, string $format = 'json', ?bool $readableLink = null, ?array $serializerContext = null, Schema $schema = null): array
{
...
$values = $enumClass::values();
//Nullable enum should expose null value
if ($type->isNullable()) {
$values[]=null;
}
...
}
Indeed, we should probably add null
here:
in case $type->isNullable()
returns true.
Up for a PR?
Yes, I will try.
Could you tell me how you run unit tests on the project?
Just run make test
(or vendor/bin/simple-phpunit
il you don't have make
on your machine)
I can't get them to work. It may be due to my environment (windows 10 - php 7.4)...
.\vendor\bin\simple-phpunit.bat
=> Exit code 255 without trace
Maybe your CI can run them for me?: https://github.com/Elao/PhpEnums/pull/139
We noticed that the ElaoEnumType-Factory does not pupose the
null
value for "nullable" fields in the json-schema documentation (swagger).The swagger specifications indicate that a nullable enumeration can be defined as follows: (https://swagger.io/docs/specification/data-models/enums/)
Currently, API Platform responds with this (which is a problem for some swagger validators):