Skip to content

[BUG] 3.1.0 Missing type for array when using allOf and $ref #18291

Description

@am-on

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When using allOf and $ref, the array from the referenced object doesn't include type.

Elm

type alias Foo =
    { arrayOfStrings : List String
    }

type alias Bar =
    { arrayOfStrings : List -- Should be `List String`
    }

Golang

type Foo struct {
	ArrayOfStrings []string `json:"arrayOfStrings"`
}

type Bar struct {
	ArrayOfStrings Array `json:"arrayOfStrings"` // Should be `ArrayOfStrings []string`
}
openapi-generator version

openapi-generator-cli 7.5.0-SNAPSHOT
commit : f357be4

OpenAPI declaration file content or url
openapi: 3.1.0
info:
  title: ""
  version: ""

paths:
  /user/getInfo:
    get:
      operationId: getUserInfo
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bar'
          description: |
            OK
      security:
        - Session: []
      x-accepts: application/json

components:
  schemas:
    Foo:
      type: object
      required:
        - arrayOfStrings
      properties:
        arrayOfStrings:
          type: array
          items:
            type: string

    Bar:
      allOf:
        - $ref: '#/components/schemas/Foo'
Generation Details

Elm:

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ 
      --input-spec openapi.yaml \
      --generator-name elm \
      --output "foo"

Golang:

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ 
      --input-spec openapi.yaml \
      --generator-name go \
      --output "foo"
Steps to reproduce

Use the provided OpenAPI declaration file and generate code.

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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