Request and response structs getting redeclared in the Go code
When I generate this manifest all the request and response structs are getting declared twice for some reason. When I check the schema I only see them defined once.
Here is an example: on line 1604 of the output, there is this struct:
// DeleteBusinessResponse defines model for DeleteBusinessResponse.
type DeleteBusinessResponse struct {
// Success Success value
Success bool `json:"success"`
}
But then it is re-declared on line 13872
type DeleteBusinessResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *DeleteBusinessResponse
JSON400 *BadRequestDto
JSON401 *UnauthorizedDto
JSON422 *UnprocessableEntityDto
}
Version: v1.16.2 OpenAPI Spec: https://raw.githubusercontent.com/cbnsndwch/ghl-app-template/develop/docs/openapi/ghl-api-v2.merged.yml Config Yaml:
package: highlevel
generate:
echo-server: false
client: true
models: true
embedded-spec: false
output: client.go
output-options:
skip-prune: false
client-type-name: HLClient
Thanks for raising - would you mind confirming if the same issue still happens on the latest version? v2 was a super minor breaking change, so shouldn't be too much to do the upgrade
That being said, it looks like this is due to:
generate:
client: true
models: true
I'd recommend only using client true when you're using the client, as models shouldn't be necessary, as you'll get all relevant types generated by client
I'm encountering the same issue on v2.1.0 using the following config:
package: main
generate:
client: true
models: true
output: bms-client.gen.go
output-options:
client-type-name: BMSClient
exclude-operation-ids:
- GetChartOfAccountsLookup
- GetProductWeightedCost
I tried removing models: true but now many structs are not generating including all Params and RequestBody structs.
My OpenAPI spec: https://api.bms.kaseya.com/swagger/v2/swagger.json
I found the ResponseTypeSuffix override in output options that avoids this naming overlap when setting it to some value other than Response