OpenAPI generators break generic API responses

(github.com)

1 points | by barissayli 1 hour ago

1 comments

  • barissayli 1 hour ago
    I kept running into the same issue with OpenAPI-generated clients.

    You define a simple generic response:

    ServiceResponse<T>

    But after client generation, generics are gone.

    You get this instead:

    ServiceResponseCustomerDto ServiceResponsePageCustomerDto ServiceResponseOrderDto

    Each one duplicates the same fields, only changing the inner type.

    After digging through Swagger/OpenAPI issues, this appears to be a structural limitation of the current tooling — OpenAPI describes schemas, not type systems.

    I ended up treating OpenAPI as a projection layer and keeping a canonical generic contract outside of it.

    How are you dealing with this in your clients?