From 13e3db59e380378778accd8c93a67ac780f1351b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 1 Feb 2018 19:25:25 +0800 Subject: [PATCH] Add operationIdOriginal to store the original operationId (#7522) * add operationIdOriginal to store the original operationId * store the original operation Id in DefaultCodegen --- .../src/main/java/io/swagger/codegen/CodegenOperation.java | 4 ++++ .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 3 +++ 2 files changed, 7 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index d62aca3b5275..5857de4bb426 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -38,6 +38,7 @@ public class CodegenOperation { public ExternalDocs externalDocs; public Map vendorExtensions; public String nickname; // legacy support + public String operationIdOriginal; // for plug-in public String operationIdLowerCase; // for markdown documentation public String operationIdCamelCase; // for class names public String operationIdSnakeCase; @@ -294,6 +295,8 @@ public boolean equals(Object o) { return false; if ( prioritizedContentTypes != null ? !prioritizedContentTypes.equals(that.prioritizedContentTypes) : that.prioritizedContentTypes != null ) return false; + if ( operationIdOriginal != null ? !operationIdOriginal.equals(that.operationIdOriginal) : that.operationIdOriginal != null ) + return false; if ( operationIdLowerCase != null ? !operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase != null ) return false; return operationIdCamelCase != null ? operationIdCamelCase.equals(that.operationIdCamelCase) : that.operationIdCamelCase == null; @@ -349,6 +352,7 @@ public int hashCode() { result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); result = 31 * result + (nickname != null ? nickname.hashCode() : 0); result = 31 * result + (prioritizedContentTypes != null ? prioritizedContentTypes.hashCode() : 0); + result = 31 * result + (operationIdOriginal != null ? operationIdOriginal.hashCode() : 0); result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0); result = 31 * result + (operationIdCamelCase != null ? operationIdCamelCase.hashCode() : 0); return result; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index f1daba360f4b..68824a622a25 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2023,6 +2023,9 @@ public CodegenOperation fromOperation(String path, Set imports = new HashSet(); op.vendorExtensions = operation.getVendorExtensions(); + // store the original operationId for plug-in + op.operationIdOriginal = operation.getOperationId(); + String operationId = getOrGenerateOperationId(operation, path, httpMethod); // remove prefix in operationId if (removeOperationIdPrefix) {