OpenAPITools / OpenAPITools/openapi-generator

[BUG][ALL] Array of object not generated

Open
#9,150 0 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

https://github.com/OpenAPITools/openapi-generator/blob/ba4aae5074c6d786e375887b24a38703cf7a6410/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L487

openapi-generator version
v5.1.0

I got this error:

[main] INFO  o.o.codegen.DefaultGenerator - Model ListOfVariables not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)

I tried with the config generateAliasAsModel but it generates an empty model

I got this model:

    ListOfVariables:
      type: array
      items:
        type: object
        properties:
          name:
            type: string
          value:
            type: string

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at DefaultGenerator.java around line 487 and reproduce the issue with the supplied ListOfVariables array-of-object schema on v5.1.0. Trace how array aliases and generateAliasAsModel are handled, then verify that generation produces a non-empty model representing the inline object's name and value properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.