Skip to content

Parsing OpenAPI 2 specs with discriminator fails #360

Closed
@patrick246

Description

@patrick246

When loading an OpenAPI 2 spec that is using discriminator in models, then the spec parsing fails with
failed to unmarshal property "definitions" (*map[string]*openapi3.SchemaRef): failed to unmarshal property "discriminator" (*openapi3.Discriminator): failed to unmarshal extension properties: json: cannot unmarshal string into Go value of type map[string]json.RawMessage ("type")

Example: https://gist.github.com/patrick246/e8b329144d228b4a1892946162868e50

This issue was encountered by someone before (#214), but worked around by mixing OpenAPI 3 parts into their OpenAPI 2 spec. As far as I can tell, this is because the library is using OpenAPI 3 data types, but the discriminator changed between 2 and 3:
OpenAPI 2 uses string, while OpenAPI 3 uses a discriminator object.

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