Skip to content

Duplicated client code if you have multiple OpenAPI schemas #2579

Open

Description

@timofei-iatsenko

Hey, thanks for the great work.

We've been using the generator for a while now and recently tried to upgrade to the latest version. We were blocked by the Bundle @hey-api/client-* plugins change introduced in v0.73.0.

It seems this change completely ignored the use case of having multiple OpenAPI schemas in a single application. Our application communicates with about 10 microservices, and we generate types and an SDK for each of them. Starting with v0.73.0, the generator now creates 10 copies of the client, which is bloating our bundle and is not acceptable.

I believe this should be a configurable option, similar to how JavaScript transpilers can either inline common helpers or reference them from a package.

Activity

  1. added
    bug 🔥
    on Sep 1, 2025
  2. mrlubos commented on Sep 1, 2025

    @mrlubos
    Member

    Hey, I think this is related to #1056

    You're right in that we ignored that use case, because it's not something that's been explicitly supported. We'll need to come back to this, there are also people who want to use multiple clients in the same application.

  3. timofei-iatsenko commented on Sep 1, 2025

    @timofei-iatsenko
    Author

    I'm currently have a custom script which is using the generator programmatic api and generating schemas for separate microservices in a loop. That worked fine before, didn't feel that some additional support for that usecase is needed.

  4. mrlubos commented on Sep 1, 2025

    @mrlubos
    Member

    What does your output structure look like?

  5. timofei-iatsenko commented on Sep 1, 2025

    @timofei-iatsenko
    Author

    src/apis/{name of the service}

    When i want to add a new service, i have to create a new folder in the src/apis/ and put a api.json file there. Than the script will go each folder in src/apis/ one be one and generate sdks.

    Outputs something like that:

    Image

    We did face some challenges working with this setup, for example microservices may have clashing or too broad operation IDs, such as getSelf. Get self what? it makes sense in one microservice but doesnt when consumer has many of them. So i wanted to rename it to something like getPlayerSelfState for that i implemented a simple methodNameBuilder which allowing us to rename operations with ambigous names.

  6. timofei-iatsenko commented on Apr 3, 2026

    @timofei-iatsenko
    Author

    Just coming here to say that issue is still here. The recent ability to specify array of schemas for the generator does not resolve the issue, because it generates one massive sdk with schemas merged. In our case we need to access multiple microservices each of them has it's own endpoint and client configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions