Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit 2833bdc

Browse files
authored
Merge pull request #1089 from CaroLe-prw/master
feat: Fixed the pathPrefix generation error in the OpenAPI document.
2 parents a27a294 + a8842c7 commit 2833bdc

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/main/java/com/ly/doc/builder/openapi/AbstractOpenApiBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ abstract Map<String, Object> buildPathUrlsRequest(ApiConfig apiConfig, ApiMethod
169169
* @return Map of paths
170170
*/
171171
@SuppressWarnings("unchecked")
172-
public Map<String, Object> buildPaths(ApiConfig apiConfig, ApiSchema<ApiDoc> apiSchema, Set<OpenApiTag> tags) {
172+
public Map<String, Object> buildPaths(ApiConfig apiConfig, ApiSchema<ApiDoc> apiSchema, Set<OpenApiTag> tags,
173+
boolean isSwagger) {
173174
Map<String, Object> pathMap = new LinkedHashMap<>(500);
174175

175176
List<ApiDoc> apiDocs = apiSchema.getApiDatas();
@@ -181,7 +182,7 @@ public Map<String, Object> buildPaths(ApiConfig apiConfig, ApiSchema<ApiDoc> api
181182
String[] paths = methodDoc.getPath().split(";");
182183
for (String path : paths) {
183184
path = path.trim();
184-
if (StringUtil.isNotEmpty(apiConfig.getPathPrefix())) {
185+
if (StringUtil.isNotEmpty(apiConfig.getPathPrefix()) && isSwagger) {
185186
path = path.replace(apiConfig.getPathPrefix(), "");
186187
}
187188
Map<String, Object> request = this.buildPathUrls(apiConfig, methodDoc, methodDoc.getClazzDoc(),

src/main/java/com/ly/doc/builder/openapi/OpenApiBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void openApiCreate(ApiConfig config, ApiSchema<ApiDoc> apiSchema) {
110110
json.put("servers", buildServers(config));
111111
Set<OpenApiTag> tags = new HashSet<>();
112112
json.put("tags", tags);
113-
json.put("paths", this.buildPaths(config, apiSchema, tags));
113+
json.put("paths", this.buildPaths(config, apiSchema, tags, false));
114114
json.put("components", this.buildComponentsSchema(apiSchema));
115115

116116
String filePath = config.getOutPath();

src/main/java/com/ly/doc/builder/openapi/SwaggerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void openApiCreate(ApiConfig config, ApiSchema<ApiDoc> apiSchema) {
109109
: DocGlobalConstants.PATH_DELIMITER);
110110
Set<OpenApiTag> tags = new HashSet<>();
111111
json.put("tags", tags);
112-
json.put("paths", buildPaths(config, apiSchema, tags));
112+
json.put("paths", buildPaths(config, apiSchema, tags, true));
113113
json.put("definitions", buildComponentsSchema(apiSchema));
114114

115115
String filePath = config.getOutPath();

0 commit comments

Comments
 (0)