当前位置:网站首页>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 !
边栏推荐
- Analysis and solution of lazyinitializationexception
- Advanced C language - pointer 2 - knowledge points sorting
- 2020.2.14
- Arc 135 supplementary report
- 8. Go implementation of string conversion integer (ATOI) and leetcode
- [2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
- 1214 print diamond
- Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
- A-Frame虚拟现实开发入门
- What insurance products should be bought for the elderly?
猜你喜欢
MySQL winter vacation self-study 2022 12 (1)
Sequence list and linked list
What does redis do? Redis often practices grammar every day
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
How to use AHAS to ensure the stability of Web services?
Regular expressions and text processors for shell programming
Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
A dichotomy of Valentine's Day
功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
随机推荐
Is the account opening of Guoyuan securities really safe and reliable
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
Optimization of for loop
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
我管你什么okr还是kpi,PPT轻松交给你
Arc 135 supplementary report
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
不得不会的Oracle数据库知识点(三)
Subgraph isomorphism -subgraph isomorphism
打印菱形图案
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
Similarities and differences of text similarity between Jaccard and cosine
Network layer - routing
Is the securities account opened by Caicai for individuals safe? Is there a routine
What are the application fields of digital twins in industry?
P1339 [USACO09OCT]Heat Wave G
1214 print diamond
Swagger2 quick start and use