swagger - Springfox swagger ApiModelProperty 值未显示在对象上
问题描述
所以我在正在构建的文档中遇到了 Springfox Swagger 的这个问题。我使用的是 3.0.0 版。我有一个看起来像这样的课程
@ApiModel(value="foo")
public class foo {
@ApiModelProperty(value="Item A")
string a;
@ApiModelProperty(value="Item Object B")
MyObj b;
}
@ApiModel(value="myObj")
public class MyObj {
@ApiModelProperty(value="Item X")
int x;
@ApiModelProperty(value="Item Y")
int y;
}
All have generic getters and setters
但是,当我在我的 spring boot 应用程序上查看 swagger ui 中的模式模型页面时,参数 b 的值没有显示出来。我不能将描述放在 MyObj 中,因为这是一个在多个实例中使用的通用类,并且描述会根据使用情况而变化。
编辑:任何原始类型(例如 string 或 int)的描述都可以正常工作,只要使用对象即可。
编辑 2:我使用了 springfox-petstore 示例并添加了注释。它似乎适用于对象数组,但不适用于对象本身
category Category{...}
id integer($int64)
example: 10
ID for Pet
name* string
example: doggie
Pet Name
photoUrls* [
Photo URLs for Pets
string]
status string
pet status in the store
Enum:
[ available, pending, sold ]
tags [
Array of Tags
Tag{
id integer($int64)
name string
}]
}```
解决方案
尝试使用公共访问变量string a
和MyObj b
推荐阅读
- c# - 我可以使用 InkManager.RecognizeAsync 来识别数学公式吗?
- python-3.x - 在python3.6中反转字符数组
- python - Python Yahoo-Finance Try-Except with Continue for Problem Tickers in a List
- c# - LINQ where 子句中的 DateTime 属性错误
- jquery - jQuery 仅在 Rails 站点上本地工作
- visual-studio - 我只能在 HoloLens 上部署 1 个 Unity 应用
- java - java中添加二维数组的方法向量的问题
- php - 我想根据员工姓名打印负责人的姓名
- python - 去序列化二叉搜索树
- python - 有没有办法继承指向类自己的私有变量的方法?