3636import org .apache .commons .lang3 .StringUtils ;
3737
3838import java .util .*;
39- import java .util .stream .Collectors ;
4039
4140/**
4241 *
@@ -52,6 +51,11 @@ public class OpenApiBuilder extends AbstractOpenApiBuilder {
5251 */
5352 private static final OpenApiBuilder INSTANCE = new OpenApiBuilder ();
5453
54+ /**
55+ * OperationId OrderNo Map
56+ */
57+ private static final Map <String , Integer > OPERATIONID_ORDER_NO_MAP = new HashMap <>();
58+
5559 /**
5660 * private constructor
5761 */
@@ -148,8 +152,19 @@ public Map<String, Object> buildPathUrlsRequest(ApiConfig apiConfig, ApiMethodDo
148152 request .put ("deprecated" , apiMethodDoc .isDeprecated ());
149153 List <String > paths = OpenApiSchemaUtil .getPatternResult ("[A-Za-z0-9_{}]*" , apiMethodDoc .getPath ());
150154 paths .add (apiMethodDoc .getType ());
151- String operationId = paths .stream ().filter (StringUtils ::isNotEmpty ).collect (Collectors .joining ("-" ));
152- request .put ("operationId" , operationId );
155+
156+ // add operationId
157+ String methodName = apiMethodDoc .getMethodName ();
158+ if (OPERATIONID_ORDER_NO_MAP .containsKey (methodName )) {
159+ int order = OPERATIONID_ORDER_NO_MAP .get (methodName );
160+ request .put ("operationId" , methodName + "_" + order );
161+ OPERATIONID_ORDER_NO_MAP .put (methodName , order + 1 );
162+ }
163+ else {
164+ request .put ("operationId" , methodName );
165+ OPERATIONID_ORDER_NO_MAP .put (methodName , 1 );
166+ }
167+
153168 // add extension attribution
154169 if (apiMethodDoc .getExtensions () != null ) {
155170 apiMethodDoc .getExtensions ().forEach ((key , value ) -> request .put ("x-" + key , value ));
0 commit comments