You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I generate server code it is ok, but when I generate client code oapi-codegen creates structs with Response suffix which causes deduplication of my structs.
Maybe it would be better to make this suffix configurable or change it and other suffix/prefix literals to with _ at the beginning so it would be OperationName_Response?
Initially I wanted to use a custom template, but this suffix is generated by the function.
For posterity, this still can occur when using the Client generation, i.e.:
internal/endoflifedate/client/client.gen.go:976:6: ProductResponse redeclared in this block
internal/endoflifedate/client/client.gen.go:187:6: other declaration of ProductResponse
internal/endoflifedate/client/client.gen.go:984:7: r.HTTPResponse undefined (type ProductResponse has no field or method HTTPResponse)
From code:
// ProductReleaseResponse A response containing a release cycle.typeProductReleaseResponsestruct {
// Result Full information about a product release cycle.ResultProductRelease`json:"result"`// SchemaVersion Version of this schema.SchemaVersionstring`json:"schema_version"`
}
// ClientWithResponsesInterface is the interface specification for the client with responses above.typeClientWithResponsesInterfaceinterface {
// ProductReleaseWithResponse requestProductReleaseWithResponse(ctx context.Context, productstring, releasestring, reqEditors...RequestEditorFn) (*ProductReleaseResponse, error)
}
typeProductReleaseResponsestruct {
Body []byteHTTPResponse*http.ResponseJSON200*ProductReleaseResponse
}
// Status returns HTTPResponse.Statusfunc (rProductReleaseResponse) Status() string {
ifr.HTTPResponse!=nil {
returnr.HTTPResponse.Status
}
returnhttp.StatusText(0)
}
This can be overridden when using output-options.response-type-suffix:
Activity
amanbolat commentedon Jun 20, 2021
I was able to tackle this issue by replacing
genResponseTypeNameandgenResponsePayloadby custom ones and do the generation in code.There is my code:
migueleliasweb commentedon Aug 26, 2021
I have the same problem with the docker
v1.41api (I've converted the format to openapi v3 with the official converter).This produces many duplicates of all types:
structs,constsand evenmethods.I ran the generation with
v1.8.2:Fix problem with code redeclarations
fix(response): added an option to override the response suffix
fix(response): added an option to override the response suffix
fix(response): added an option to override the response suffix
fix(response): added an option to override the response suffix
jamietanna commentedon May 3, 2025
For posterity, this still can occur when using the Client generation, i.e.:
From code:
This can be overridden when using
output-options.response-type-suffix:I'll look at getting this more prominently documented.