【发布时间】:2018-08-03 11:43:14
【问题描述】:
我正在使用 Swagger Core 2.0.2 for Java 来生成 OpenAPI 文档。其中,我有以下课程SomeDTO:
@Schema(name = "SomeDTO", description = "some description")
public class SomeDTO {
@Schema(description = "description of name")
private String name;
@Schema(required = true, description = "description of OtherDTO")
private OtherDTO otherDTO;
}
OtherDTO描述如下:
public class OtherDTO {
@Schema(required = true)
private String someField;
private String someOtherField;
}
我的问题是description 和otherDTO 字段上方的required 字段都没有任何效果。
生成的openapi.json 如下所示:
"components": {
"schemas": {
"SomeDTO" : {
"type": "object",
"properties": {
"name": {
"type" : "string"
}
"otherDTO" : {
"$ref": "#/components/schemas/OtherDTO"
}
},
"description": "some description"
},
"OtherDTO": {
"required": ["someField"],
"type": "object",
"properties": {
"somefield": {
"type": "string"
},
"someOtherField": {
"type": "string"
}
}
}
}
}
我期待SomeDTO 架构有一个包含OtherDTO 的required 数组,但它没有。描述也丢失了。
我尝试了多种架构设置组合,但均无济于事。我将非常感谢任何帮助以了解我做错了什么。
提前致谢。
【问题讨论】:
标签: java swagger swagger-2.0 openapi