Open etshy opened 1 year ago
I think using the anyOf
spec is incorrect here because you are using an union type here.
anyOf – validates the value against any (one or more) of the subschemas
oneOf
is the correct on here since this specifies that only one of the schemas is valid.
oneOf – validates the value against exactly one of the subschemas
Also note that null
is not a valid schema type.
Note that there is no null type; instead, the nullable attribute is used as a modifier of the base type.
https://swagger.io/docs/specification/data-models/data-types/
It is still weird that the generated string
typed schema is missing the nullable
property.
I would have assumed that it would end up like this when only the @var
annotation is present:
"Command": {
"properties": {
"property": {
"oneOf": [
{
"type": "integer",
"nullable": true
},
{
"type": "string",
"nullable": true
}
]
},
}
}
I'm not sure the error concerns this repo or
swagger-php
bu the error I got comes from nelmio file.I have a case with an old API where Properties can be
integer
,string
ornull
I tried making the followingBut the spec generation crash with the following error
I tried adding
@var
like thisIt works, but generate both
anyOf
andoneOf
and in the doc web page, it only show one type (the first one on the
@var
docblock)ps : I also tried using
oneOf
instead ofanyOf
, but spec generated looks like this