From 641601602429cc4403ba1d53959ff2b417440195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Wed, 7 Sep 2022 14:46:53 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20openapi=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=20=E5=9B=A0springdoc=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=A4=9A=E6=AC=A1=E6=8B=BC=E6=8E=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/doc/config/PlusPaths.java | 15 +++++++++++++++ .../doc/config/SwaggerAutoConfiguration.java | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/PlusPaths.java diff --git a/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/PlusPaths.java b/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/PlusPaths.java new file mode 100644 index 00000000..199297bc --- /dev/null +++ b/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/PlusPaths.java @@ -0,0 +1,15 @@ +package com.ruoyi.common.doc.config; + +import io.swagger.v3.oas.models.Paths; + +/** + * 单独使用一个类便于判断 解决springdoc路径拼接重复问题 + * + * @author Lion Li + */ +public class PlusPaths extends Paths { + + public PlusPaths() { + super(); + } +} diff --git a/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/SwaggerAutoConfiguration.java b/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/SwaggerAutoConfiguration.java index 6e71798e..63023cba 100644 --- a/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/SwaggerAutoConfiguration.java +++ b/ruoyi-common/ruoyi-common-doc/src/main/java/com/ruoyi/common/doc/config/SwaggerAutoConfiguration.java @@ -110,7 +110,10 @@ public class SwaggerAutoConfiguration { // 对所有路径增加前置上下文路径 return openApi -> { Paths oldPaths = openApi.getPaths(); - Paths newPaths = new Paths(); + if (oldPaths instanceof PlusPaths) { + return; + } + PlusPaths newPaths = new PlusPaths(); oldPaths.forEach((k,v) -> newPaths.addPathItem(finalContextPath + k, v)); openApi.setPaths(newPaths); };