api-platform / api-platform/api-doc-parser

Every property marked as optional + 'any' types

Abierto
#158 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
113
Forks
80
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**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;
}
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.