我定义了 OpenAPI 3.0 文档并使用 openapi-generator-cli-3.3.4.jar 来生成 Java 代码 (DTO)。但我无法解决这个案例:List<Map<Integer, Set<String>>>.
在Map<Integer, String>问题:
据我所知,我可以使用架构对象: additionalProperties定义地图类型。
OpenAPI 规范additionalProperties:值可以是布尔值或对象。内联或引用模式必须是模式对象,而不是标准的 JSON 模式。
如上所述,我不能将 Map 键设置为整数,对吗?对这个问题有什么建议吗?
在set<String>或set<List<String>>问题:我必须尝试一些努力:
测试 1:设置“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"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
生成 Java DTO …