英文:
swagger-core - Schemas declared on maps are repeated for the key and value
问题
如果我为一个@Schema
定义了一个Map,生成的OpenAPI规范会出现重复。
例如:
@Schema(description = "Contents of the bag",
example="{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\",\"Melon\":\"Honeydew\"}",
allowableValues= {
"Apple", "Pear", "Melon", "Plum"
})
public final Map<String, Object> properties;
这将生成:
"properties" : {
"otherProp" : {
"type" : "string",
"description" : "..."
},
"properties" : {
"type" : "object",
"additionalProperties" : {
"type" : "object",
"description" : "Contents of the bag",
"example" : "{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\",\"Melon\":\"Honeydew\"}",
"enum" : [ "Apple", "Pear", "Melon", "Plum" ]
},
"description" : "Contents of the bag",
"example" : "{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\",\"Melon\":\"Honeydew\"}",
"enum" : [ "Apple", "Pear", "Melon", "Plum" ]
}
}
description
、example
和 enum
都是重复的。
有没有办法分别记录键和值?
英文:
If I define a @Schema
for a Map, the generated OpenAPI spec has duplications.
For example:
@Schema(description = "Contents of the bag",
example="{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\"\"Melon\":\"Honeydew\"}",
allowableValues= {
"Apple", "Pear", "Melon", "Plum"
})
public final Map<String, Object> properties;
This generates:
"properties" : {
"otherProp" : {
"type" : "string",
"description" : "...",
},
"properties" : {
"type" : "object",
"additionalProperties" : {
"type" : "object",
"description" : "Contents of the bag",
"example" : "{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\"\"Melon\":\"Honeydew\"}",
"enum" : [ "Apple", "Pear", "Melon", "Plum" ]
},
"description" : "Contents of the bag",
"example" : "{\"Apple\":\"Braeburn\",\"Pear\":\"Conference\"\"Melon\":\"Honeydew\"}",
"enum" : [ "Apple", "Pear", "Melon", "Plum" ]
}
}
description
, example
and enum
are duplicated.
Is there any way to document the key and value separately?
专注分享java语言的经验与见解,让所有开发者获益!
评论