From 75f426deb3cf97a33001233830f18fa54f704511 Mon Sep 17 00:00:00 2001 From: PIGCLOUD Date: Thu, 30 Jul 2026 18:12:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(swagger):=20=E4=BD=BF=E7=94=A8=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E5=9C=B0=E5=9D=80=E9=81=BF=E5=85=8D=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pigx-boot/src/main/resources/application-dev.yml | 2 +- .../pigx/common/swagger/config/OpenAPIDefinition.java | 3 ++- .../pigx/common/swagger/support/SwaggerProperties.java | 5 ----- .../src/main/resources/openapi-config.yaml | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pigx-boot/src/main/resources/application-dev.yml b/pigx-boot/src/main/resources/application-dev.yml index dfab16e68..92f19f112 100644 --- a/pigx-boot/src/main/resources/application-dev.yml +++ b/pigx-boot/src/main/resources/application-dev.yml @@ -34,4 +34,4 @@ jasypt: # swagger token url 配置 swagger: - token-url: ${swagger.gateway}/admin/oauth2/token + token-url: ${server.servlet.context-path}/oauth2/token diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/OpenAPIDefinition.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/OpenAPIDefinition.java index 944761e79..af1b096da 100644 --- a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/OpenAPIDefinition.java +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/OpenAPIDefinition.java @@ -16,6 +16,7 @@ */ package com.pig4cloud.pigx.common.swagger.config; +import cn.hutool.core.util.StrUtil; import com.pig4cloud.pigx.common.swagger.support.SwaggerProperties; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; @@ -79,7 +80,7 @@ public class OpenAPIDefinition extends OpenAPI implements InitializingBean, Appl this.schemaRequirement(HttpHeaders.AUTHORIZATION, this.securityScheme(swaggerProperties)); // servers List serverList = new ArrayList<>(); - serverList.add(new Server().url(swaggerProperties.getGateway() + "/" + path)); + serverList.add(new Server().url(StrUtil.SLASH + path)); this.servers(serverList); // 支持参数平铺 SpringDocUtils.getConfig().addSimpleTypesForParameterObject(Class.class); diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/support/SwaggerProperties.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/support/SwaggerProperties.java index a367f5415..41bb1d6f8 100644 --- a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/support/SwaggerProperties.java +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/support/SwaggerProperties.java @@ -63,11 +63,6 @@ public class SwaggerProperties { **/ private String title = ""; - /** - * 网关 - */ - private String gateway; - /** * 获取token */ diff --git a/pigx-common/pigx-common-swagger/src/main/resources/openapi-config.yaml b/pigx-common/pigx-common-swagger/src/main/resources/openapi-config.yaml index 1aaae169c..c7514b60f 100644 --- a/pigx-common/pigx-common-swagger/src/main/resources/openapi-config.yaml +++ b/pigx-common/pigx-common-swagger/src/main/resources/openapi-config.yaml @@ -2,6 +2,5 @@ swagger: enabled: true title: PigX Swagger API - gateway: http://${GATEWAY-HOST:pigx-gateway}:${GATEWAY-PORT:9999} - token-url: ${swagger.gateway}/auth/oauth2/token + token-url: /auth/oauth2/token scope: server