Skip to content

gen: OptError isn't generated during nested recursion schema with AllOf #1488

@IgorMoiseev1988

Description

@IgorMoiseev1988

What version of ogen are you using?

$ go list -m github.com/ogen-go/ogen

github.com/ogen-go/ogen v1.14.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

When specification openapi3.0 has nested field with recursive ref into allOf:

      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "cause": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Error"
              }
            ],
            "nullable": true
          }
        }
      }

then ogen generate structure like this:

type Error struct {
	Code           OptNilString `json:"code"`
	Cause          *OptError    `json:"cause"`
}

But ogen doesn't generate OptError struct, so we have compilation error

If we delete allOf from specification:

      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "cause": {
            "$ref": "#/components/schemas/Error",
            "nullable": true
          }
        }
      }

Then ogen generates structure like this:

type Error struct {
	Code           OptNilString `json:"code"`
        Cause          *Error       `json:"cause"`
}

and additional generate OptError structure and it's methods

What did you expect to see?

Expected: generation OptError structure is independent of allOf

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions