You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
OpenAPI 3.1 is now fully compatible with JSON Schema 2020-12. In contrast to 3.0, the type keyword now allows for multiple types defined as an array. This commonly applies to nullable properties, but in general it could apply to any element where multiple types are allowed.
Attempting to generate client code containing a definition like this results in the following exception:
TypeError: Jane\Component\OpenApi3\JsonSchema\Model\Schema::setType(): Argument #1 ($type) must be of type ?string, array given, called in C:\example\vendor\jane-php\open-api-3\JsonSchema\Norma
lizer\SchemaNormalizer.php on line 174 in C:\example\vendor\jane-php\open-api-3\JsonSchema\Model\Schema.php on line 569
How to reproduce
Use any OAS 3.1 schema and create a property like this:
example_property:
type:
- string
- 'null'
Attempt to generate client code.
Possible Solution
Jane-PHP should be able to deal with the official specification and allow arrays.
A workaround is to manually modify the schema and apply oneOf instead:
Jane version(s) affected: 7
Description
OpenAPI 3.1 is now fully compatible with JSON Schema 2020-12. In contrast to 3.0, the
type
keyword now allows for multiple types defined as an array. This commonly applies to nullable properties, but in general it could apply to any element where multiple types are allowed.Attempting to generate client code containing a definition like this results in the following exception:
How to reproduce
Possible Solution
Jane-PHP should be able to deal with the official specification and allow arrays.
A workaround is to manually modify the schema and apply
oneOf
instead:Additional context
The text was updated successfully, but these errors were encountered: