当前位置:网站首页>How to set the response description information when the response parameter in swagger is Boolean or integer
How to set the response description information when the response parameter in swagger is Boolean or integer
2022-07-04 00:40:00 【Firewood boy】
Problem description
Project use swagger Display document information , Now there is an enterprise user information verification interface for recruiters , Response parameters will only return true or false, How to add the description information of the return field in the response parameter column of the interface document (true: Check success ;false: Check failed )?
swagger The description information of the response parameters in is through the entity class @ApiModelProperty add to , But if you return a Boolean Or other non object types , There is no place to add this annotation . Here is my summary of the treatment plan .
Solution
1. Comment directly from the method description @ApiOperation Add response result description information , As long as the front end can understand the meaning of the returned fields .
@ApiOperation(" Check the enterprise user information of the recruiter ( Return parameter description :true: Check success ;false: Check failed )")
@GetMapping("/checkRecruitBusinessInfo")
public ResultVo<Boolean> checkRecruitBusinessInfo(@Validated BusinessInfoDto businessInfoDto) throws Exception {
Boolean businessInfoRight = newStoreService.checkRecruitBusinessInfo(businessInfoDto);
return ResultVoUtil.success(businessInfoRight);
}
The interface document is shown below :
2. Custom return parameter object , Label the returned field information .
Custom add return parameter description object :
@ApiModel(" Check the return parameter information of the recruiter's enterprise user information ")
@Data
public class ReturnInfo {
@ApiModelProperty(value = " Check the enterprise user information of the recruiter :true: Check success ;false: Check failed ",dataType = "Boolean",example = "false")
private Boolean businessInfoRight;
}
modify controller Object information returned in :
@ApiOperation(" Check the enterprise user information of the recruiter ")
@GetMapping("/checkRecruitBusinessInfo")
public ResultVo<ReturnInfo> checkRecruitBusinessInfo(@Validated BusinessInfoDto businessInfoDto) throws Exception {
Boolean businessInfoRight = newStoreService.checkRecruitBusinessInfo(businessInfoDto);
ReturnInfo returnInfo = new ReturnInfo();
returnInfo.setBusinessInfoRight(businessInfoRight);
return ResultVoUtil.success(returnInfo);
}
The modified interface document , The field description information has been displayed in the marked place :
In actual development, as long as the front and back ends can understand the meaning of parameter transmission and use the first method ; But for OCD players like me , There is a problem if the meaning of the field is not displayed in the response parameters , But the second way is really a little redundant , It's really not a wise way to create objects just to show problems . If you are usually about swagger There are other ways to deal with this scenario , Leave a comment in the comments section !
边栏推荐
- P1629 postman delivering letter
- It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
- UTS | causal reasoning random intervention based on Reinforcement Learning
- Data storage - interview questions
- 基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
- What does redis do? Redis often practices grammar every day
- Test the influence of influent swacth on the electromagnetic coil of quartz meter
- Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
- 网上的低佣金链接安全吗?招商证券怎么开户?
- 数据库表外键的设计
猜你喜欢

Gauss elimination method and template code

Att & CK actual combat series - red team actual combat - V
![[about text classification trick] things you don't know](/img/c0/fdb04f6b31f1dba2658c2430dc4036.jpg)
[about text classification trick] things you don't know

Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
![[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)](/img/44/aa4963d07d046deb2bc76eb59f8ff7.jpg)
[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)
![[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections](/img/c6/3dc7d01600f6713afdbb4cf3df5238.jpg)
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections

机器学习基础:用 Lasso 做特征选择

(Introduction to database system | Wang Shan) Chapter V database integrity: Exercises

Cloud dial test helps Weidong cloud education to comprehensively improve the global user experience
随机推荐
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
【.NET+MQTT】.NET6 环境下实现MQTT通信,以及服务端、客户端的双边消息订阅与发布的代码演示
A-Frame虚拟现实开发入门
Self study software testing. To what extent can you go out and find a job?
On covariance of array and wildcard of generic type
Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
[NLP] text classification still stays at Bert? Duality is too strong than learning framework
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
【leetcode】374. Guess the size of the number
Sequence list and linked list
[CSDN Q & A] experience and suggestions
关于 uintptr_t和intptr_t 类型
我管你什么okr还是kpi,PPT轻松交给你
打印菱形图案
The culprit of unrestrained consumption -- Summary
system. Exit (0) and system exit(1)
For loop
P1656 bombing Railway