loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.88k stars 1.06k forks source link

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

Open aaqilniz opened 1 year ago

aaqilniz commented 1 year ago

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 application.

Logs

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

aaqilniz commented 1 year ago

Hi @samarpanB. Can you please provide me with some guidance about this issue?