The following JSON file serves to illustrate the problem:
<code>{
"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" ]
}
}
}
}
}
}
}
</code>
<code>{
"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" ]
}
}
}
}
}
}
}
</code>
{
"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" ]
}
}
}
}
}
}
}
I used the following statement to generate the code.
<code>openapi-generator generate -g dart -i api_test.json -o "$(pwd)/api_test" --additional-properties=pubName=api_test
</code>
<code>openapi-generator generate -g dart -i api_test.json -o "$(pwd)/api_test" --additional-properties=pubName=api_test
</code>
openapi-generator generate -g dart -i api_test.json -o "$(pwd)/api_test" --additional-properties=pubName=api_test
My problem is that in the class Obj1
the property mode
is declared as follows.
<code> Set<Obj1ModeEnum> mode;
</code>
<code> Set<Obj1ModeEnum> mode;
</code>
Set<Obj1ModeEnum> mode;
While in the same file (obj1.dart
) the following class is defined:
<code>class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
...
</code>
<code>class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
...
</code>
class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
...
In the obj2.dart
file, the mode
property is then declared as follows:
<code>Set<ModeEnum> mode;
</code>
<code>Set<ModeEnum> mode;
</code>
Set<ModeEnum> mode;
Here the corresponding enum is defined again under the same name.
<code>class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
</code>
<code>class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
</code>
class Obj2ModeEnum {
/// Instantiate a new enum with the provided [value].
const Obj2ModeEnum._(this.value);
Is this an error in the dart generator or is the JSON faulty?