Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/main/java/com/ly/doc/builder/openapi/OpenApiBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.commons.lang3.StringUtils;

import java.util.*;
import java.util.stream.Collectors;

/**
*
Expand All @@ -52,6 +51,11 @@ public class OpenApiBuilder extends AbstractOpenApiBuilder {
*/
private static final OpenApiBuilder INSTANCE = new OpenApiBuilder();

/**
* OperationId OrderNo Map
*/
private static final Map<String, Integer> OPERATIONID_ORDER_NO_MAP = new HashMap<>();

/**
* private constructor
*/
Expand Down Expand Up @@ -148,8 +152,19 @@ public Map<String, Object> buildPathUrlsRequest(ApiConfig apiConfig, ApiMethodDo
request.put("deprecated", apiMethodDoc.isDeprecated());
List<String> paths = OpenApiSchemaUtil.getPatternResult("[A-Za-z0-9_{}]*", apiMethodDoc.getPath());
paths.add(apiMethodDoc.getType());
String operationId = paths.stream().filter(StringUtils::isNotEmpty).collect(Collectors.joining("-"));
request.put("operationId", operationId);

// add operationId
String methodName = apiMethodDoc.getMethodName();
if (OPERATIONID_ORDER_NO_MAP.containsKey(methodName)) {
int order = OPERATIONID_ORDER_NO_MAP.get(methodName);
request.put("operationId", methodName + "_" + order);
OPERATIONID_ORDER_NO_MAP.put(methodName, order + 1);
}
else {
request.put("operationId", methodName);
OPERATIONID_ORDER_NO_MAP.put(methodName, 1);
}

// add extension attribution
if (apiMethodDoc.getExtensions() != null) {
apiMethodDoc.getExtensions().forEach((key, value) -> request.put("x-" + key, value));
Expand Down