loopbackio / loopbackio/loopback-next

lb4 openapi doesn't work with openapi specs generated by loopback itself

Aperta
#9,328 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug OpenAPI
Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
2g 21h
PR unite (30g)
27

Descrizione

### Describe the bug

The `lb4 openapi` command fails to generate working code in case the specification provided is generated by loopback itself. This shouldn't be the case as the specification is generated by LoopBack and the framework uses that same spec.

To reproduce this, generate specs from any lb4-based project. Then use that same specification to generate openapi artifacts with lb4 `openapi`. The resulting app creates buggy code.

The reproduction app is built based on openapi specs of [this](https://github.com/aaqilniz/lb4-ex-ref-many) application.

### Logs

```shell
src/models/index.ts:2:1 - error TS2308: Module './account-with-relations.model' has already exported a member named 'AccountWithRelations'. Consider explicitly re-exporting to resolve the ambiguity.

2 export * from './account.model';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/models/index.ts:6:1 - error TS2308: Module './customer-with-relations.model' has already exported a member named 'CustomerWithRelations'. Consider explicitly re-exporting to resolve the ambiguity.

6 export * from './customer.model';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

### Additional information

I tried removing duplicate entries which have been causing the problems. The resulting code still was not working and causing another issue. The request passed to swagger-client had `filter=undefined` in the URL which was making swagger-client fail to fetch any data.

### Reproduction

https://github.com/aaqilniz/lb4-ex-openapi

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Riproduci il problema con l’applicazione lb4-ex-openapi usando una specifica generata dall’app LoopBack collegata. Inizia con il flusso di generazione OpenAPI di lb4 e ispeziona gli export di src/models/index.ts generato e la richiesta passata a swagger-client. Il lavoro è completato quando l’applicazione generata viene compilata senza export di modelli duplicati e le richieste non contengono filter=undefined.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.