Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] dart generator creates invalid code #19026

Open
just-doit opened this issue Jun 27, 2024 · 0 comments
Open

[BUG] dart generator creates invalid code #19026

just-doit opened this issue Jun 27, 2024 · 0 comments

Comments

@just-doit
Copy link

just-doit commented Jun 27, 2024

Description

The attached example demonstrates the problem.

It contains two classes (Obj1 and Obj2).
Both have the same mode property.

In the class Obj1 this results in the property

Set<Obj1ModeEnum> mode;

while in the class Obj2 the property looks like this:

Set<ModeEnum> mode;

Here I would expect Set<Obj2ModeEnum> mode;.

In the file obj1.dart the associated type is

class Obj2ModeEnum {
  /// Instantiate a new enum with the provided [value].
  const Obj2ModeEnum._(this.value);
  ...

Here I would expect Obj1ModeEnum.

In the file obj2.dart the corresponding type is correct (but duplicate, since it's in obj1.dart already):

class Obj2ModeEnum {
  /// Instantiate a new enum with the provided [value].
  const Obj2ModeEnum._(this.value);
  ...
openapi-generator version
openapi-generator-cli 7.6.0
  commit : ab7d0cb
  built  : -999999999-01-01T00:00:00+18:00
  source : https://github.com/openapitools/openapi-generator
  docs   : https://openapi-generator.tech/
OpenAPI declaration file content or url
{
  "openapi": "3.0.1",
  "info": {
    "title": "api_test",
    "version": "1.0.0"
  },
  "paths": {},
  "components": {
    "schemas": {
      "Obj1": {
        "type": "object",
        "properties": {
          "mode": {
            "uniqueItems": true,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "mode1",
                "mode2",
                "mode3"
              ]
            }
          }
        }
      },
      "Obj2": {
        "type": "object",
        "properties": {
          "mode": {
            "uniqueItems": true,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "mode1",
                "mode2",
                "mode3"
              ]
            }
          }
        }
      }
    }
  }
}
Generation Details

I'm using the following command:

openapi-generator generate -g dart -i spapi.json -o "$(pwd)/spapi" --additional-properties=pubName=spapi
Steps to reproduce

Use provided sample json and command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant