当前位置:网站首页>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 !
边栏推荐
- Several ways to set up a blog locally [attach relevant software download links]
- P1629 postman delivering letter
- 功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
- BBS forum recommendation
- Test the influence of influent swacth on the electromagnetic coil of quartz meter
- MySQL is installed as a Windows Service
- system. Exit (0) and system exit(1)
- Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
- Axure resources and prototype tool Axure RP 9 download
- Stock price forecast
猜你喜欢

Shell script three swordsman sed

Interview script of Software Test Engineer

The difference between objects and objects
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/3f/75b3125f8779e6cf9467a30fd7eeb4.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
![[prefix and notes] prefix and introduction and use](/img/a6/a75e287ac481559d8f733e6ca3e59c.jpg)
[prefix and notes] prefix and introduction and use

Future源码一观-JUC系列
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/28/fc05f2e8d53cf81fd061c799090022.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!

@EnableAsync @Async

Similarities and differences of text similarity between Jaccard and cosine

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
随机推荐
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
A method to solve Bert long text matching
Regular expressions and text processors for shell programming
Joint examination of six provinces 2017
The difference between objects and objects
Development and application of fcitx functional plug-ins
Analysis and solution of lazyinitializationexception
Axure resources and prototype tool Axure RP 9 download
[prefix and notes] prefix and introduction and use
Analysis: misunderstanding of choosing WMS warehouse management system
[GNN] hard core! This paper combs the classical graph network model
[leetcode] interview question 17.08 Circus tower
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
1214 print diamond
P1629 postman delivering letter
[error record] configure NDK header file path in Visual Studio
swagger中响应参数为Boolean或是integer如何设置响应描述信息
功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
【leetcode】374. Guess the size of the number