Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate endpoints create conflicting data types #1155

Closed
CHE1RON opened this issue Oct 14, 2024 · 3 comments
Closed

Duplicate endpoints create conflicting data types #1155

CHE1RON opened this issue Oct 14, 2024 · 3 comments
Labels
bug 🔥 Something isn't working

Comments

@CHE1RON
Copy link

CHE1RON commented Oct 14, 2024

Description

Describe the bug
When having endpoints of the same name, eg tags/{tag}/export and labels/{label}/export, only one data type is generated (here ExportData) for all services, which is correct for the first, but wrong for all subsequent services.

Expected behavior
Data types free of conflicts, eg ExportData, ExportData1, etc

See my downstream issue here.

Reproducible example or configuration

To Reproduce

  1. Create API with endpoints tags/{tag}/export and labels/{label}/export
  2. Run script
  3. Inspect type errors in services.gen.ts

OpenAPI specification (optional)

OpenAPI spec file
routes.json

System information (optional)

  • OS: macOS v14.4
@CHE1RON CHE1RON added the bug 🔥 Something isn't working label Oct 14, 2024
@mrlubos
Copy link
Member

mrlubos commented Oct 14, 2024

Hi @CHE1RON, I might add support for invalid OpenAPI specs in future versions, but for now I'd recommend fixing your spec by making sure each operationId is unique. You might also try resolving the name yourself using services.methodNameBuilder(). I assume there's a reason you use the same identifier multiple times?

@CHE1RON
Copy link
Author

CHE1RON commented Oct 14, 2024

Hey there @mrlubos!

Honestly, our API endpoint naming scheme is pretty generic, but I'll see what I can do - thank you very much! 🙏

@CHE1RON CHE1RON closed this as completed Oct 14, 2024
@mrlubos
Copy link
Member

mrlubos commented Oct 14, 2024

@CHE1RON ha! I feel pretty strongly about investing in your OpenAPI spec and I plan to add some content about this in the future. You can't expect the tooling to create perfect clients if your spec is shoddy. Of course that's not always an option, but if it is, I'd recommend doing that.

In this case, the issue itself could be handled. I plan to add strict and loose modes that would either throw on any invalid definition or try to compile at the expense of output quality. But again, try to solve the problem at the source if possible (your OpenAPI spec), which it sounds like you chose to do. I support that! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants