Skip to content

Generating different structs for different error codes #2085

@VladislavYakonyuk

Description

@VladislavYakonyuk

We use server code generation with the strict-server: true parameter. During generation, we obtain the following structures for the response

GetHealthcheck200JSONResponse{
   Timestamp: time.Now().UnixMilli(),
}

GetHealthcheck500JSONResponse{
   Timestamp: time.Now().UnixMilli(),
}

And this happens with absolutely any response, a separate structure is created for each error code specified in the API contract. We find this inconvenient, but couldn't figure out how to make a generic structure or our own wrapper. Could you suggest how to be in this situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions