如何忽略特定 http 动词(GET、POST、PUT)的 swagger 资源属性 [英] How to ignore swagger resource property for specific http verb(GET,POST,PUT)

查看:46
本文介绍了如何忽略特定 http 动词(GET、POST、PUT)的 swagger 资源属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们实现了 2.6.1 版的 spring fox swagger 2,我想为 HTTP GET METHOD 而不是 POST METHOD 显示资源的特定属性,我还没有找到任何使用 swagger 2 的方法.请帮忙,谢谢.

We are implemented spring fox swagger 2 of version 2.6.1, i wanted to display a specific property of a resource for HTTP GET METHOD and not for POST METHOD, i haven't find any approach using swagger 2. Please help thanks.

例如:

Class Employee{

Integer id;
String name;

}

请求 URI:GET/api/employee/{id}我应该看到 swagger 请求文档为

Request URI: GET /api/employee/{id} i should see the swagger request document as

{
  id:"",
  name:""
}

请求 URI:POST/api/employee我应该将 swagger 请求示例视为

Request URI: POST /api/employee i should see the swagger request sample as

{
    name:""
}

推荐答案

我升级到了 2.8.0 版,@ApiModelProperty(readOnly = true) 可以实现.这会导致该属性被 GET #Returned,在 POST/PUT/PATCH 中不使用

I upgraded to version 2.8.0 and it is possible with @ApiModelProperty(readOnly = true). This causes the property to be #Returned by GET, not used in POST / PUT / PATCH

这篇关于如何忽略特定 http 动词(GET、POST、PUT)的 swagger 资源属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆