OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22.03k stars 6.61k forks source link

[BUG][Typescript - fetch]- `.openapi-generator-ignore` doesn't exclude files `import` in `apis/index.ts` & `models/index.ts` #17958

Open rallets opened 9 months ago

rallets commented 9 months ago

Bug Report Checklist

Description

I'm excluding some apis and models using .openapi-generator-ignore. The apis and models are filtered correctly, but the apis/index.ts and models/index.ts files contain the import of ALL the possible files, filtered or not. This is breaking the typescript build.

Am I doing something wrong, or this is effectively a bug?

openapi-generator version

7.4.0-SNAPSHOT

OpenAPI declaration file content or url

Full repro, including the code generated by openapi-generator.

https://github.com/rallets/openapi-generator-bug

Steps to reproduce

Just run the syncapi.bat script that use docker

Related issues/PRs

Haven't found similar issues.

Suggest a fix

The index.ts files should not include the excluded files.

Thank you

chris-hut commented 1 month ago

I'm running into this issue as well, did you ever find a solution? I've thought about looking into writing a custom template but that feels like a lot of work - and I agree with you that this is a bug!

rallets commented 1 month ago

@chris-hut I changed my approach in the generation of the apis/models. In the backend (Asp.net core) I added a custom swagger document just for the frontend, and decorated (minimal api) all the endpoint I was interested in. In this way I was able to generate only what I needed, and basically bypassed this bug ☺️