Skip to content

Request and response structs getting redeclared in the Go code #1450

Closed

Description

@clintberry

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

Activity

  1. jamietanna commented on Feb 11, 2024

    @jamietanna
    Member

    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

  2. jamietanna commented on Feb 11, 2024

    @jamietanna
    Member

    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

  3. Akrugerus commented on Mar 19, 2024

    @Akrugerus

    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

  4. Akrugerus commented on Mar 21, 2024

    @Akrugerus

    I found the ResponseTypeSuffix override in output options that avoids this naming overlap when setting it to some value other than Response

  5. MikhailLipanin commented on Sep 24, 2024

    @MikhailLipanin

    @Akrugerus This helped, thanks!

  6. mromaszewicz commented on Mar 2, 2026

    @mromaszewicz
    Member

    This was addressed in #2213, please enable name conflict resolution via the output options and file a new issue if it doesn't work for you

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions