假设我的负载类是:
public class Payload {
private final long id;
private final String aField;
}
springfox 将按字典顺序对有效载荷字段进行排序,这将产生以下有效载荷规范:
{
"aField": "string",
"id": 0
}
是否有任何控制参数告诉 springfox 保留原始字段顺序?
最佳答案
您可以使用 @ApiModelProperty并指定一个 position
:
public class Payload {
@ApiModelProperty(value = "The id", position = 1)
private final long id;
@ApiModelProperty(value = "The a field", position = 2)
private final String aField;
}
关于java - Swagger + Spring : is it possible to preserve the fields order in the payload?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48949624/