api-platform / api-platform/api-doc-parser
Every property marked as optional + 'any' types
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
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 as `string` in Swagger, but appears as `any` in TypeScript. I also noticed dates being `any` – 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:
```json
{
"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:
```typescript
export interface ContactPerson {
"@id"?: string;
name?: string;
phoneNumber?: string;
email?: string;
jobAdvertisements?: string[];
image?: any;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.