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

边栏推荐
- [free completion] development of course guidance platform (source code +lunwen)
- The programmer went to bed at 12 o'clock in the middle of the night, and the leader angrily scolded: go to bed so early, you are very good at keeping fit
- P35-P41 fourth_ context
- Kubernetes源码分析(一)
- Kingbasees plug-in KDB of Jincang database_ date_ function
- [fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries
- Preliminary cognition of C language pointer
- Internationalization and localization, dark mode and dark mode in compose
- Jincang KFS data bidirectional synchronization scenario deployment
- 带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
猜你喜欢
![[fxcg] market analysis today](/img/ac/294368e3496a5b808b38833053ee81.jpg)
[fxcg] market analysis today

The simple problem of leetcode: dismantling bombs

vulnhub HA: Natraj

540. Single element in ordered array

Leetcode simple question: check whether the string is an array prefix

消息队列(MQ)介绍

Solve BP Chinese garbled code

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

Redis persistence principle

Php+mysql registration landing page development complete code
随机推荐
General undergraduate college life pit avoidance Guide
[BMZCTF-pwn] 20-secret_ file
[set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
重绘和回流
Basic use of continuous integration server Jenkins
AWS VPC
2022-02-12 (338. Bit count)
解决bp中文乱码
Which Bluetooth headset is good about 400? Four Bluetooth headsets with strong noise reduction are recommended
How to use kotlin to improve productivity: kotlin tips
Matplotlib -- save graph
Joint set search: merge intervals and ask whether two numbers are in the same set
Dive Into Deep Learning——2.1数据操作&&练习
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
What functions need to be set after the mall system is built
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
多板块轮动策略编写技巧----策略编写学习教材
Web - Information Collection
[Thesis Writing] how to write the overall design of JSP tourism network
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...