hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
Other
965 stars 77 forks source link

Duplicated response type caused by long $ref #771

Closed finas closed 2 weeks ago

finas commented 1 month ago

Description

Thank you all for this fantastic project that has greatly improved my coding experience Recently I created two classes with similar names: WebApi.Dto.Response.PageRespWrapper``1[[A......]] and WebApi.Dto.Response.PageRespWrapper``1[[B......]]. Both are convert to WebApi_Dto_Response_PageRespWrapper_1 which cause the different api refer to the same response type. image image

Any help will be appreciated!

Reproducible example or configuration

https://stackblitz.com/edit/hey-api-client-fetch-example-vn31nb?file=services%2Ftypes.gen.ts

OpenAPI specification (optional)

https://stackblitz.com/edit/hey-api-client-fetch-example-vn31nb?file=swagger.json image

System information (optional)

No response

stackblitz[bot] commented 1 month ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

mrlubos commented 1 month ago

Heh, funny how the issues always seem to come in bulk. I believe this one reported yesterday is the same underlying problem https://github.com/hey-api/openapi-ts/issues/765

finas commented 1 month ago

@mrlubos Thanks. Is there workaround or plan to fix it?

finas commented 1 month ago

Also, should i close this ticket?

mrlubos commented 1 month ago

Feel free to keep it, I don't mind. Of course it would be good to fix, it's only a question of priority. I am open to a pull request too, will see if I have time to look at this

finas commented 1 month ago

Maybe I can help with that. Let me try to set up local development. Can you give me some advice on what files I should look at to fix this?

mrlubos commented 1 month ago

Not exactly, the first thing I'd look at is why the parser seems to be discarding the generic from names. It's possible this will be fixed simply by resolving names better

chasewallis commented 1 month ago

If you do work on this, I highly suspect it has something to do with the brackets [ and ]. That is where both my and your variables get cut off. Maybe a regex that isn't including that or something like that.

mrlubos commented 1 month ago

@finas what would be the expected result for you?

mrlubos commented 1 month ago

In unrelated news, I found the matcher responsible for this issue, but waiting for your response before prioritising this