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

createClient name colision #1136

Open
mkeyy0 opened this issue Oct 10, 2024 · 3 comments
Open

createClient name colision #1136

mkeyy0 opened this issue Oct 10, 2024 · 3 comments
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon

Comments

@mkeyy0
Copy link

mkeyy0 commented Oct 10, 2024

Description

I have a createClient operation in my openAPI schema, generating the createClient function. But at the same time createClient function is imported from the @hey-api/client-fetch package. It results in the name collision in the services.gen file. It would be nice to have an option to avoid collision.

Reproducible example or configuration

No response

OpenAPI specification (optional)

No response

System information (optional)

No response

@mkeyy0 mkeyy0 added the bug 🔥 Something isn't working label Oct 10, 2024
@mrlubos
Copy link
Member

mrlubos commented Oct 10, 2024

Hey @mkeyy0, yeah that's always a risk. How would you resolve this conflict?

@mkeyy0
Copy link
Author

mkeyy0 commented Oct 11, 2024

@mrlubos I'm not sure, to be honest. It can be done in several ways:

  • For example, add the ability to override the createClient function name from the settings. But I'm not sure it's a good way to do this;
    I guess that preferred way is:
  • Leave the public API of '@hey-api/client-fetch` the same, to not introduce any breaking changes to it.
import { createClient } from '@hey-api/client-fetch';

In the generated file use the following syntax

import { createClient as _createClient } from '@hey-api/client-fetch';

Anyway, createClient is not exported from the generated file, it's an internal implementation. So, to avoid name collisions, we add the _ internal property mark. It can be the same for the createConfig function.

What are your thoughts on this?

@mrlubos
Copy link
Member

mrlubos commented Oct 11, 2024

Yeah I think I'll need to move the client entirely out of the file since you'd be running into the same problem if your service was called "client", except I wouldn't be able to alias it then. Thanks for reporting, will improve this

@mrlubos mrlubos added the prioritized 🚚 This issue has been prioritized and will be worked on soon label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

No branches or pull requests

2 participants