Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Every property marked as optional + 'any' types

Aperta
#158 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
openapi, typescript
Ambito
api, tooling

Direzione di ricerca

Inizia dal TypeScript interface generator e segui come vengono mappati l’obbligatorietà e i tipi primitivi delle proprietà Swagger/OpenAPI. Confronta l’esempio ContactPerson con il relativo schema, quindi verifica che le proprietà obbligatorie non siano opzionali e che le proprietà documentate di tipo string o date non diventino any.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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:

{
  "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;
}
Lingua principale
TypeScript
Stelle
113
Fork
80
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/api-doc-parser

Tutte le issue di api-platform/api-doc-parser

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.