Skip to content

deeply nested oneOf gets lost when merging allOf #1905

Description

@matgr1

for the following schema:

{
  "allOf": [
    {
      "allOf": [
        {
          "oneOf": [
            { "properties": { "a_foo_one_of_0": { "type": "string" } } },
            { "properties": { "a_foo_one_of_1": { "type": "string" } } }
          ]
        }
      ]
    },
    { "properties": { "a_foo": { "type": "string" } } }
  ]
}

this gets generated:

// Foo defines model for Foo.
type Foo struct {
	AFoo *string `json:"a_foo,omitempty"`
}

when it should generate (helper functions omitted for brevity):

// Foo defines model for Foo.
type Foo struct {
	AFoo  *string `json:"a_foo,omitempty"`
	union json.RawMessage
}

// Foo0 defines model for .
type Foo0 struct {
	AFooOneOf0 *string `json:"a_foo_one_of_0,omitempty"`
}

// Foo1 defines model for .
type Foo1 struct {
	AFooOneOf1 *string `json:"a_foo_one_of_1,omitempty"`
}

note that above has been fixed (and unit test added) in #1904

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