Skip to content

External references are not propagated recursively when merging "allOf" fields #1841

@hego-fdc

Description

@hego-fdc

Consider these two specifications:

#a.yaml
openapi: 3.0.0                
components:
  schemas:
    Merged:
      allOf:
        - $ref: '#/components/schemas/Example'
        - $ref: 'b.yaml#/components/schemas/Merge'
    Example:
      type: object
      properties:
        a:
          type: string
        c:
          $ref: 'b.yaml#/components/schemas/Element'
#b.yaml
openapi: 3.0.0
components:
  schemas:
    Merge:
      type: object
      properties:
        b:
          type: array
          items:
            $ref: "#/components/schemas/Element"
    Element:
      type: object
      properties:
        c:
          type: string

As well as the following options:

package: example
generate:
  models: true
import-mapping:
  b.yaml: example.com/b
output-options:
  skip-prune: true

Running oapi-codegen/oapi-codegen -config options.yaml a.yaml results in the following type for Merged:

type Merged struct {
	A *string               `json:"a,omitempty"`
	B *[]Element            `json:"b,omitempty"`
	C *externalRef0.Element `json:"c,omitempty"`
}

Where B should be *[]externalRef0.Element instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions