I define OpenAPI 3.0 documents and use openapi-generator-cli-3.3.4.jar to generate Java code (DTO).
But I can't solve this case: List<Map<Integer, Set<String>>>
.
In
Map<Integer, String>
issue:As I know I can use schema object: additionalProperties define map type.
OpenAPI Specification additionalProperties: Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
According above, I can't set Map key to an integer, right? Have any suggestions on this issue?
In
set<String>
orset<List<String>>
issue: I have to try some effort:
Testing1: set "uniqueItems": true
{
"openapi": "3.0",
"info": {
"version": "1.0.0",
"title": "Dr.First Schema",
"license": {
"name": "MIT"
}
},
"components": {
"schemas": {
"Question": {
"type": "object",
"properties": {
"test": {
"type": "array",
"items":{
"type":"string"
}
}
}
}
}
}
}
Generate Java DTO: not Set is List
/**
* Get test
* @return test
**/
@ApiModelProperty(value = "")
public List<String> getTest() {
return test;
}
public void setTest(List<String> test) {
this.test = test;
}
Testing2: edit the properties test type to Set
"test": {
"type": "Set"
}
Warn
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: Set
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: Set
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: Set
Generate Java DTO: Have syntax error
/**
* Get test
* @return test
**/
@ApiModelProperty(value = "")
public java.util.* getTest() {
return test;
}
public void setTest(java.util.* test) {
this.test = test;
}
Testing3: edit the properties test type to set
"test": {
"type": "set"
}
Warn
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: set
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: set
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: set
Generate Java DTO: Have java Set type but no idea to setting generic
/**
* Get test
* @return test
**/
@ApiModelProperty(value = "")
public Set getTest() {
return test;
}
public void setTest(Set test) {
this.test = test;
}
- Have any suggestions to fix
Map<Integer, String>
and java Set generic issue in openapi-generator?