loopbackio / loopbackio/loopback-next
lb4 openapi doesn't work with openapi specs generated by loopback itself
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the lb4-ex-openapi application using a specification generated by the linked LoopBack app. Start with the lb4 openapi generation flow and inspect the generated src/models/index.ts exports and the request passed to swagger-client. Done means the generated application builds without duplicate model exports and requests do not contain filter=undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100