-
-
Notifications
You must be signed in to change notification settings - Fork 958
Closed
Description
API Platform version(s) affected: >= 3.2
Description
Since the 3.2 version, the openapi schema for nullable type is invalid for 3.x openapi schema.
How to reproduce
I use the Symfony api-platform version.
With the following ApiResource:
#[ApiResource()]
class MyApiRessource {
private ?int $nullableAttribute = null;
public function getNullableAttribute(): ?int
{
return $this->nullableAttribute;
}
public function setNullableAttribute(?int $nullableAttribute): MyApiRessource
{
$this->nullableAttribute = $nullableAttribute;
return $this;
}
}And I generated the openapi schema with php bin/console api:openapi:export --spec-version=3.0.0
I got the following schema for #/components/schemas/MyApiRessource with api-plaftorm 3.1.22:
"MyApiRessource": {
"type": "object",
"description": "",
"deprecated": false,
"properties": {
"nullableAttribute": {
"type": "integer",
"nullable": true
}
}
},
And for api-platform 3.2.0 (and upper):
"MyApiRessource": {
"type": "object",
"description": "",
"deprecated": false,
"properties": {
"nullableAttribute": {
"type": [
"integer",
"null"
]
}
}
},
It also concerns the application/ld+json, where hydra:mapping has a property that had this issue.
Possible Solution
According to the logs, it seems the bug has been introduce since https://github.com/api-platform/core/releases/tag/v3.2.0 and this specific pull request may introduce it #5489.
Metadata
Metadata
Assignees
Labels
No labels