OpenAPITools / OpenAPITools/openapi-generator

[BUG] [DART] Wrong code generated for List if enums

Open
#5,583 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
    Yes
  • Have you validated the input using an OpenAPI validator (example)?
    Yes
  • What's the version of OpenAPI Generator used?
    4.2.3
  • Have you search for related issues/PRs?
    YES
  • What's the actual output vs expected output?
    The generated files have compile time errors related to enums
Description

List of Enums are not properly generated in dart model files

openapi-generator version

I used version 4.2.3 jar

OpenAPI declaration file content or url
(here your code)

(for YAML code) or

{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost",
      "description": "Generated server url"
    }
  ],
  "paths": {
    "/test": {
      "get": {
        "tags": [
          "greeting-controller"
        ],
        "operationId": "sayHello2",
        "parameters": [
          {
            "name": "helloDto",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/HelloDto"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "default response",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/test-multiple": {
      "get": {
        "tags": [
          "greeting-controller"
        ],
        "operationId": "searchDummyEntity",
        "parameters": [
          {
            "name": "predicate",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DummyEntityPredicateG"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "default response",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HelloDto": {
        "type": "object",
        "properties": {
          "enumParams": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "ENUM1",
                "ENUM2"
              ]
            }
          }
        }
      },
      "DummyEntityPredicateG": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "notCode": {
            "type": "string"
          }
        }
      }
    }
  }
}
Command line used for generation
openapi-generator generate -i spec.json -g dart-jaguar
Steps to reproduce

Generate SDK from spec files that have List of enums as fields in their pojo

Screen Shot 2020-03-12 at 12 30 02 AM

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

Run openapi-generator generate -i spec.json -g dart-jaguar using the OpenAPI declaration in this issue and inspect the generated Dart model for HelloDto.enumParams. Confirm the generated files fail to compile because of the list-of-enum representation; done means the generated Dart model compiles for this specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.