Open
Description
API Platform version(s) affected: 3.0
Description
I generated typescript interfaces from a API Platform with this package. This worked really well, but there are two issues that make the result pretty much unusable for me:
- Every property is marked as optional, even '@id'. Having to manual check for every property kinda defeats the purpose of having the interfaces in the first place.
- Some properties are marked as
any
, even though there is a proper type in the API docs. E.g.ContactPerson.image
is listed asstring
in Swagger, but appears asany
in TypeScript. I also noticed dates beingany
– but this was in a API Platform 2.6 project and might not be an issue in newer versions.
Here is an example taken out of my Swagger docs:
{
"hydra:member": [
{
"@context": "string",
"@id": "string",
"@type": "string",
"id": "string",
"name": "string",
"phoneNumber": "string",
"email": "string",
"jobAdvertisements": [
"string"
],
"image": "string"
}
],
"hydra:totalItems": 0,
"hydra:view": {
"@id": "string",
"type": "string",
"hydra:first": "string",
"hydra:last": "string",
"hydra:previous": "string",
"hydra:next": "string"
},
"hydra:search": {
"@type": "string",
"hydra:template": "string",
"hydra:variableRepresentation": "string",
"hydra:mapping": [
{
"@type": "string",
"variable": "string",
"property": "string",
"required": true
}
]
}
}
And this is the generated interface:
export interface ContactPerson {
"@id"?: string;
name?: string;
phoneNumber?: string;
email?: string;
jobAdvertisements?: string[];
image?: any;
}
Metadata
Metadata
Assignees
Labels
No labels