We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given a DTO with an union typed array property:
class ExampleDTO { /** * @param (int|string)[] $exampleList */ public function __construct( private array $exampleList ) { } /** * @return (int|string)[] */ public function getExampleList(): array { return $this->exampleList; } }
Result in Nelmio generating the following OpenApi schema for the DTO:
"ExampleDTO": { "properties": { "exampleList": { "type": "array", "items": { "type": "integer" } } }, "type": "object" },
"ExampleDTO": { "properties": { "exampleList": { "type": "array", "items": { "anyOf": [ { "type": "integer" }, { "type": "string" } ] } } }, "type": "object" },
This can be fixed manually by describing the exampleList property like so:
exampleList
use OpenApi\Attributes as OA; class ExampleDTO { /** * @param (int|string)[] $exampleList */ public function __construct( #[OA\Property( type: 'array', items: new OA\Items( anyOf: [ new OA\Schema(type: 'integer'), new OA\Schema(type: 'string'), ]) )] private array $exampleList ) { } /** * @return (int|string)[] */ public function getExampleList(): array { return $this->exampleList; } }
Ideally NelmioApiDocBundle should generate a correct schema instead of having to manually define it.
The text was updated successfully, but these errors were encountered:
Sounds more like a feature request for the underlying swagger-php library.
There is a long outstanding issue to improve type handling that should cover this. zircote/swagger-php#1310
Sorry, something went wrong.
Ah thanks for answering.
No branches or pull requests
Example
Given a DTO with an union typed array property:
Result in Nelmio generating the following OpenApi schema for the DTO:
Expected result
This can be fixed manually by describing the
exampleList
property like so:Ideally NelmioApiDocBundle should generate a correct schema instead of having to manually define it.
The text was updated successfully, but these errors were encountered: