当前位置:网站首页>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
边栏推荐
- [set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
- General undergraduate college life pit avoidance Guide
- [PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
- AWS VPC
- Php+mysql registration landing page development complete code
- Preliminary cognition of C language pointer
- Function introduction of member points mall system
- Reptile exercise 02
- 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
- 解决bp中文乱码
猜你喜欢
[fxcg] market analysis today
逆袭大学生的职业规划
GFS distributed file system (it's nice to meet it alone)
STM32 reverse entry
Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
[nlp] - brief introduction to the latest work of spark neural network
JVM原理简介
How to choose cross-border e-commerce multi merchant system
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
Human resource management system based on JSP
随机推荐
Prefix and (continuously updated)
重绘和回流
What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets
Library management system based on SSM
C language series - Section 3 - functions
7. Integrated learning
UiPath实战(08) - 选取器(Selector)
智能合约安全审计公司选型分析和审计报告资源下载---国内篇
Kubernetes source code analysis (I)
[set theory] binary relationship (binary relationship notation | binary relationship from a to B | number of binary relationships | example of binary relationship)
[Thesis Writing] how to write the overall design of JSP tourism network
How to choose cross-border e-commerce multi merchant system
Design and implementation of JSP logistics center storage information management system
Basic use of continuous integration server Jenkins
stm32逆向入门
【SQL注入】联合查询(最简单的注入方法)
Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
Dive into deep learning - 2.1 data operation & Exercise
Php+mysql registration landing page development complete code
RSRS指标择时及大小盘轮动