当前位置:网站首页>The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
2022-07-03 04:35:00 【Programmers who can't manage money are not good DJs】
- Swagger Access as an interface document tool springboot The project is very convenient , Just one starter, One configuration The integration can be completed
- But for systems with more microservices , One service, one document address , Will feel more troublesome . Is there any good way to gather them ?
- At this time, the solution of aggregating documents appears , Place all the microservice addresses in swagger Show in groups , Switching packets is equivalent to directly switching the entire microservice .
- SpringBlade Optimized the aggregated document , It's much simpler 、 Configure a more convenient solution , Now let's see how to operate .
Configuration steps (SpringBlade Project as an example )
- open blade-gateway Configuration file for bootstrap.yml
- The configuration needs to appear in the service address of the gateway , And the displayed service name
Corresponding service engineering is introduced blade-starter-swagger Rely on it
Document address
1. Open the address of the aggregated document : http://localhost/doc.html
2. Click the drop-down box in the upper left corner , We can see that it has been configured 3 Different microservice documents .
Multi package name scanning
bladex Provides the configuration of multi packet scanning , As follows :
to API Touch up
1. We can see , Demonstrate the module of API It's all in English , There is no Chinese description , It looks like it will be more difficult , Then let's combine swagger And swagger-bootstrap-ui Configuration of , To fully display the next regular API form .
2. First, turn on the personalized configuration .
3. Then add the request header Token value ( It can be obtained directly from the authorization module ), After obtaining, it will Token Set to request header
4. Then open the demonstration module , In the second place /blade-demo/api/detail
Interface, for example , I want to put him first , And describe his in Chinese form api
5. To find the corresponding API, Add the following configuration ,@ApiOperation
Medium position
It is used to set sorting , The smaller the value. , The higher up the list .
@RestController
@AllArgsConstructor
@RequestMapping("api")
@Api(value = " Demo interface ", tags = " Demo interface ")
public class DemoController {
private BlogService service;
/**
* details
*/
@GetMapping("/detail")
@ApiOperation(value = " Check the details ", notes = " Incoming primary key ", position = 1)
public R<Blog> detail(@ApiParam(value = " Primary key value ") @RequestParam Integer id) {
Blog detail = service.getById(id);
return R.data(detail);
}
}
6. Restart the service to view the aggregated document , You can see , Sort 、 Effective in Chinese , A regular API Form is born .
7. Call next API, See if it returns successfully .
8. If there are some API We don't want to show it on the document , have access to @ApiIgnore annotation , For example, add to BlogClientImpl
On .
@ApiIgnore
@RestController
@AllArgsConstructor
public class BlogClientImpl implements BlogClient {
private BlogService service;
@Override
@GetMapping(API_PREFIX + "/detail")
public R<Blog> detail(Integer id) {
return R.data(service.getById(id));
}
}
9. Restart the service , This is no longer available in the view document interface API It describes .
Be careful
- swagger The default is in the production environment
prod
Next close cannot be used , Because it is very dangerous to expose the interface in the production environment - If necessary, turn on , You can delete the configuration from the corresponding file
边栏推荐
- 7. Integrated learning
- 2022-02-12 (338. Bit count)
- Integration of Android high-frequency interview questions (including reference answers)
- Kingbasees plug-in KDB of Jincang database_ database_ link
- Internationalization and localization, dark mode and dark mode in compose
- 消息队列(MQ)介绍
- C Primer Plus Chapter 10, question 14 3 × 5 array
- C language series - Section 3 - functions
- 2022-02-13 (347. Top k high frequency elements)
- Kubernetes source code analysis (I)
猜你喜欢
Internationalization and localization, dark mode and dark mode in compose
2022 new examination questions for the main principals of hazardous chemical business units and examination skills for the main principals of hazardous chemical business units
解决bp中文乱码
Solve BP Chinese garbled code
2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
Auman Galaxy new year of the tiger appreciation meeting was held in Beijing - won the double certification of "intelligent safety" and "efficient performance" of China Automotive Research Institute
Leetcode simple problem delete an element to strictly increment the array
I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional
Youdao cloud notes
Number of uniform strings of leetcode simple problem
随机推荐
C primre plus Chapter 10 question 6 inverted array
2.14 summary
Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected
4 years of experience to interview test development, 10 minutes to end, ask too
[software testing-6] & Test Management
Bugku CTF daily question baby_ flag. txt
X-ray normal based contour rendering
一名外包仔的2022年中总结
Triangular rasterization
RSRS index timing and large and small disc rotation
智能合约安全审计公司选型分析和审计报告资源下载---国内篇
AWS VPC
Ffmpeg mix
How to use kotlin to improve productivity: kotlin tips
Dismantle a 100000 yuan BYD "Yuan". Come and see what components are in it.
2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
解决bp中文乱码
[literature reading] sparse in deep learning: practicing and growth for effective information and training in NN
Priv app permission exception
[Chongqing Guangdong education] reference materials for design and a better life of Zhongyuan Institute of science and technology