当前位置:网站首页>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
prodNext 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

边栏推荐
- GFS distributed file system (it's nice to meet it alone)
- 【工具跑SQL盲注】
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
- [literature reading] sparse in deep learning: practicing and growth for effective information and training in NN
- 带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
- Reptile exercise 03
- Ffmpeg mix
- 220214c language learning diary
- Some information about the developer environment in Chengdu
猜你喜欢

Some information about the developer environment in Chengdu
![[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius](/img/01/c118725f74e39742df021b5dbcc33b.jpg)
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
![[literature reading] sparse in deep learning: practicing and growth for effective information and training in NN](/img/7e/50fa6f65b5a4f0bb60909f57daff56.png)
[literature reading] sparse in deep learning: practicing and growth for effective information and training in NN

Php+mysql registration landing page development complete code

智能合约安全审计公司选型分析和审计报告资源下载---国内篇

BMZCTF simple_ pop

Function introduction of member points mall system

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

vulnhub HA: Natraj

Leetcode simple problem delete an element to strictly increment the array
随机推荐
Basic use of continuous integration server Jenkins
Kingbasees plug-in KDB of Jincang database_ database_ link
stm32逆向入门
2022 a special equipment related management (elevator) analysis and a special equipment related management (elevator) simulation test
Redis persistence principle
Kubernetes source code analysis (I)
跨境电商多商户系统怎么选
Hj35 serpentine matrix
A outsourcing boy's mid-2022 summary
Web security - CSRF (token)
2022-02-12 (338. Bit count)
[set theory] ordered pair (ordered pair | ordered triple | ordered n ancestor)
FISCO bcos zero knowledge proof Fiat Shamir instance source code
Web - Information Collection
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
Square root of X
Number of uniform strings of leetcode simple problem
Leetcode simple question: the key with the longest key duration
2022-02-14 (394. String decoding)
Bugku CTF daily question baby_ flag. txt