Skip to content

field that starts with underscore generates a conflict #1767

@gainsley

Description

@gainsley

The OSM SOL005 API spec has a bunch of objects that define the following two ID fields:

    Alarm:
      description: |
        Alarm Information
      type: object
      properties:
        _id:
          description: Identifier of the Alarm.
          type: string
          format: uuid
        id:
          description: Identifier of the Alarm.
          type: string
          format: uuid

The generated go code becomes:

// Alarm Alarm Information
type Alarm struct {
	// Id Identifier of the Alarm.
	Id openapi_types.UUID `json:"_id"`

	// Id Identifier of the Alarm.
	Id openapi_types.UUID `json:"id"`

Which causes a compile error.

For reference, using config.yaml of

package: osmapi
generate:
  models: true
  client: true
output: osm-generated.go

and
gen.go:

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml SOL005.yaml

package osmapi

I believe there needs to be some logic that checks that renaming a field that starts with underscore doesn't conflict with the names of any other fields.

Btw this is a really great project, it's been very helpful for my work, thanks so much for creating it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions