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

边栏推荐
- Leetcode simple problem delete an element to strictly increment the array
- Leetcode simple question: check whether the array is sorted and rotated
- 2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical
- Wine travel Jianghu War: Ctrip is strong, meituan is strong, and Tiktok is fighting
- [set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
- Leetcode simple question: the key with the longest key duration
- Writing skills of multi plate rotation strategy -- strategy writing learning materials
- [pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
- 带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
- Dismantle a 100000 yuan BYD "Yuan". Come and see what components are in it.
猜你喜欢

MC Layer Target

跨境电商多商户系统怎么选
![[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

FISCO bcos zero knowledge proof Fiat Shamir instance source code

data2vec! New milestone of unified mode

使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错

SSM based campus part-time platform for College Students

解决bp中文乱码

Which Bluetooth headset is good about 400? Four Bluetooth headsets with strong noise reduction are recommended
![[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
随机推荐
2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination
Solve BP Chinese garbled code
Web - Information Collection
C primre plus Chapter 10 question 6 inverted array
有道云笔记
How to retrieve the password for opening word files
会员积分商城系统的功能介绍
重绘和回流
Dive Into Deep Learning——2.1数据操作&&练习
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
Reptile exercise 03
2.14 summary
stm32逆向入门
How to use kotlin to improve productivity: kotlin tips
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me
2022 P cylinder filling test content and P cylinder filling simulation test questions
商城系统搭建完成后需要设置哪些功能
Dismantle a 100000 yuan BYD "Yuan". Come and see what components are in it.
SSM based campus part-time platform for College Students
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