OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.23k stars 6.43k forks source link

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

Open gibahjoe opened 4 years ago

gibahjoe commented 4 years ago

Bug Report Checklist

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
gibahjoe commented 4 years ago

I dont know if I am the one doing something wrong but none of the dart generators work. They have a lot of compile issues including the one above.

I am happy to contribute over the weekend of anyone can point me in the right direction

agilob commented 4 years ago

6729 will fix dart2, not dart-jaguar but it shows how to fix it, so you can go ahead and port my MR from dart2 to dart-jaguar