Skip to content

Generated path responses can conflict with schema definitions #2097

@joshprzybyszewski-wf

Description

@joshprzybyszewski-wf

Example: #2096

I noticed when using this generator that when attempting to use the "client with response", the returned type is busted. In particular, it's because there are two types with the same name: one seems to be defined in the schemas and one seems to be generated from the paths definition.

Image

Example OAS

https://github.com/joshprzybyszewski-wf/oapi-codegen/blob/jp/reproStatusConflict/examples/conflicting-fields/api.yaml#L6-L26

https://github.com/joshprzybyszewski-wf/oapi-codegen/blob/jp/reproStatusConflict/examples/conflicting-fields/api.yaml#L27-L35

How the problem appears

The presenting problem was that resp.Status gave me an IDE warning: invalid operation: cannot indirect resp.Status (value of type func() string). In reality, there are two types in the generated file with the same name:

https://github.com/joshprzybyszewski-wf/oapi-codegen/blob/jp/reproStatusConflict/examples/conflicting-fields/conflicting_fields.gen.go#L23-L27

https://github.com/joshprzybyszewski-wf/oapi-codegen/blob/jp/reproStatusConflict/examples/conflicting-fields/conflicting_fields.gen.go#L195-L207

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