|
24 | 24 |
|
25 | 25 | import java.util.ArrayList;
|
26 | 26 | import java.util.HashMap;
|
| 27 | +import java.util.HashSet; |
27 | 28 | import java.util.LinkedHashMap;
|
28 | 29 | import java.util.LinkedHashSet;
|
29 | 30 | import java.util.List;
|
@@ -154,6 +155,7 @@ public Reader getTemplate(String name) {
|
154 | 155 | for (String tag : paths.keySet()) {
|
155 | 156 | List<CodegenOperation> ops = paths.get(tag);
|
156 | 157 | Map<String, Object> operation = processOperations(config, tag, ops);
|
| 158 | + |
157 | 159 | operation.put("basePath", basePath);
|
158 | 160 | operation.put("contextPath", contextPath);
|
159 | 161 | operation.put("baseName", tag);
|
@@ -363,10 +365,24 @@ public Map<String, Object> processOperations(CodegenConfig config, String tag, L
|
363 | 365 | Map<String, Object> operations = new HashMap<String, Object>();
|
364 | 366 | Map<String, Object> objs = new HashMap<String, Object>();
|
365 | 367 | objs.put("classname", config.toApiName(tag));
|
| 368 | + |
| 369 | + // check for operationId uniqueness |
| 370 | + Set<String> opIds = new HashSet<String>(); |
| 371 | + int counter = 0; |
| 372 | + for(CodegenOperation op : ops) { |
| 373 | + String opId = op.nickname; |
| 374 | + if(opIds.contains(opId)) { |
| 375 | + counter ++; |
| 376 | + op.nickname += "_" + counter; |
| 377 | + } |
| 378 | + opIds.add(opId); |
| 379 | + } |
366 | 380 | objs.put("operation", ops);
|
| 381 | + |
367 | 382 | operations.put("operations", objs);
|
368 | 383 | operations.put("package", config.apiPackage());
|
369 | 384 |
|
| 385 | + |
370 | 386 | Set<String> allImports = new LinkedHashSet<String>();
|
371 | 387 | for (CodegenOperation op : ops) {
|
372 | 388 | allImports.addAll(op.imports);
|
|
0 commit comments