The following JSON file serves to illustrate the problem:
{
"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.
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.
Set<Obj1ModeEnum> mode;
While in the same file (obj1.dart
) the following class is defined:
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:
Set<ModeEnum> mode;
Here the corresponding enum is defined again under the same name.
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?