当前位置: 首页 > news >正文

springboot网关添加swagger

添加依赖

		<dependency><groupId>com.spring4all</groupId><artifactId>swagger-spring-boot-starter</artifactId><version>2.0.2</version></dependency>

添加配置类,与服务启动类同一个层级
地址:http://localhost:port/swagger-ui/index.html

package com.brt.cloudGateway;import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.*;@RestController
public class SwaggerHandlerController {@Autowired(required = false)private SecurityConfiguration securityConfiguration;@Autowired(required = false)private UiConfiguration uiConfiguration;private final SwaggerResourcesProvider swaggerResources;@Autowiredpublic SwaggerHandlerController(SwaggerResourcesProvider swaggerResources) {this.swaggerResources = swaggerResources;}@GetMapping("/swagger-resources/configuration/security")public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {return Mono.just(new ResponseEntity<>(Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));}@GetMapping("/swagger-resources/configuration/ui")public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {return Mono.just(new ResponseEntity<>(Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));}@GetMapping("/swagger-resources")public Mono<ResponseEntity> swaggerResources() {return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));}// @GetMapping("/")public Mono<ResponseEntity> swaggerResourcesN() {return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));}//@GetMapping("/csrf")public Mono<ResponseEntity> swaggerResourcesCsrf() {return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));}
}
http://www.lryc.cn/news/281011.html

相关文章:

  • 代码随想录 Leetcode383. 赎金信
  • 上下左右视频转场模板PR项目工程文件 Vol. 05
  • 【正点原子STM32连载】第三十三章 单通道ADC采集实验 摘自【正点原子】APM32E103最小系统板使用指南
  • Linux系统使用docker部署Geoserver(简单粗暴,复制即用)
  • libcurl使用默认编译的winssl进行https的双向认证
  • MySQL运维实战(3.3) 管理数据库(database)
  • Web3去中心化存储:重新定义云服务
  • 纸尿裤行业调研:预计到2024年提高至68.1%
  • 目标检测数据集 - 行人检测数据集下载「包含VOC、COCO、YOLO三种格式」
  • 重磅!巨匠纺品鉴正式签约“体坛冠军程晨”为品牌形象代言人
  • 亚信安慧AntDB超融合框架——数智化时代数据库管理的新里程碑
  • 设计模式之命令模式【行为型模式】
  • 肯尼斯·里科《C和指针》第6章 指针(4)实例
  • diffusers flask streamlit 简洁可视化文生图页面
  • ubuntu 使用VNC链接树莓派
  • 水利部:加大北斗、无人机等安全监测新技术的应用推广
  • 如何定位和优化程序CPU、内存等性能之巅
  • 一体机旅游景区污水处理设备工艺说明
  • java返回文件时为图片或pdf等设置在线预览或下载
  • 微信公众号对接--客服消息
  • 花几分钟整点jmeter花活,轻松超越90%软件测试
  • 类脑研究之脑组成及神经系统相关理论!大脑是什么?大脑和脑有什么区别?大脑皮层和脑膜什么关系?人的神经系统有哪些?
  • 【Vue按键修饰符详细介绍】
  • url 地址中的敏感信息脱敏处理
  • 慢速 HTTP 攻击 Slow HTTP Attack
  • 2024年“计算机视觉处理设计开发工程师”最后几天报考中!
  • 基于ssm的教务信息平台的设计与实现+jsp论文
  • 哪种护眼灯对眼睛好?五款高品质考研台灯推荐
  • 安防视频云平台/可视化监控云平台ARM版EasyCVR无法下载录像文件,如何解决?
  • 如何用Docker部署Nacos服务并结合内网穿透实现公网访问管理界面?