@ApiOperationSupport
时间: 2024-04-13 22:10:32 浏览: 170
@ApiOperationSupport是一个注解,用于在swagger中隐藏请求参数。如果想要在swagger中隐藏请求参数,需要进行以下配置步骤:
1. 首先,在pom.xml文件中引入knife4j的依赖:
```xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>
```
2. 然后,在Swagger配置类中添加@EnableKnife4j注解,启用knife4j:
```java
@Configuration
@EnableSwagger2
@EnableKnife4j
public class SwaggerConfig {
// 配置swagger相关信息
}
```
3. 在需要隐藏请求参数的接口方法上使用@ApiOperationSupport注解,并通过ignoreParameters属性指定需要忽略的参数名,多个参数名使用逗号分隔。例如:
```java
@ApiOperation(value = "添加")
@ApiOperationSupport(ignoreParameters = {"sysDict.id,sysDict.status"})
@PostMapping("/add")
public R<Boolean> insert(@RequestBody SysDict sysDict) {
// 方法实现
}
```
在上述代码中,ignoreParameters属性指定了需要忽略的参数名为"sysDict.id"和"sysDict.status"。
注意,使用@ApiOperationSupport注解时,需要确保已经正确配置了swagger2。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ApiOperationSupport注解的使用](https://blog.csdn.net/m0_54854484/article/details/123250673)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [常见的问题系列---【@ApiOperationSupport忽略失效的问题】](https://blog.csdn.net/weixin_44988127/article/details/130074545)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文