Skip to content

[golang] Array type alias produces empty struct #393

@bonifaido

Description

@bonifaido
Description

Array type alias produces empty struct, it only produces working code if I inline the schema definition to the response block.

openapi-generator version

36f4452

openapi: 3.0.0

OpenAPI declaration file content or url
....
      responses:
        '200':
          description: Secrets listed
          content:
            application/json:
              schema:
                  $ref: '#/components/schemas/SecretsListResponse'

...

    SecretsListResponse:
      type: array
      items:
        $ref: '#/components/schemas/SecretsListItem'

...

    SecretsListItem:
      type: object
      properties:
        id:
          type: string
          example: "62bc3c75-91fb-4670-bad4-24b401a9deac"

##### Command line used for generation

`docker run --rm -v $PWD:/local openapitools/openapi-generator-cli generate \
	--additional-properties packageName=client \
	-i /local/docs/openapi/pipeline.yaml \
	-g go \
	-o /local/client
Steps to reproduce
Related issues/PRs

#391 maybe.

Suggest a fix/enhancement

Instead of this code:

package client

type SecretsListResponse struct {
}

I think this should be produced:

package client

type SecretsListResponse []SecretsListItem

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions