diff --git a/examples/go/go-client/helper/rest/flex/v1/README.md b/examples/go/go-client/helper/rest/flex/v1/README.md index 0e3536d92..bbb9ac9d1 100644 --- a/examples/go/go-client/helper/rest/flex/v1/README.md +++ b/examples/go/go-client/helper/rest/flex/v1/README.md @@ -43,7 +43,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - [ListCredentialAwsResponse](docs/ListCredentialAwsResponse.md) - - [UpdateCallResponse](docs/UpdateCallResponse.md) + - [UpdateCall200Response](docs/UpdateCall200Response.md) - [TestResponseObject](docs/TestResponseObject.md) - [ListCredentialAwsResponseMeta](docs/ListCredentialAwsResponseMeta.md) diff --git a/examples/go/go-client/helper/rest/flex/v1/model_update_call_response.go b/examples/go/go-client/helper/rest/flex/v1/model_update_call_200_response.go similarity index 86% rename from examples/go/go-client/helper/rest/flex/v1/model_update_call_response.go rename to examples/go/go-client/helper/rest/flex/v1/model_update_call_200_response.go index 293492b39..f0548e961 100644 --- a/examples/go/go-client/helper/rest/flex/v1/model_update_call_response.go +++ b/examples/go/go-client/helper/rest/flex/v1/model_update_call_200_response.go @@ -14,8 +14,8 @@ package openapi -// UpdateCallResponse struct for UpdateCallResponse -type UpdateCallResponse struct { +// UpdateCall200Response struct for UpdateCall200Response +type UpdateCall200Response struct { // Non-string path parameter in the response. Sid *int `json:"sid,omitempty"` } diff --git a/examples/go/go-client/helper/rest/flex/v1/voice.go b/examples/go/go-client/helper/rest/flex/v1/voice.go index c5285610d..88f989e29 100644 --- a/examples/go/go-client/helper/rest/flex/v1/voice.go +++ b/examples/go/go-client/helper/rest/flex/v1/voice.go @@ -20,7 +20,7 @@ import ( "strings" ) -func (c *ApiService) UpdateCall(Sid string) (*UpdateCallResponse, error) { +func (c *ApiService) UpdateCall(Sid string) (*UpdateCall200Response, error) { path := "/v1/Voice/{Sid}" path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) @@ -34,7 +34,7 @@ func (c *ApiService) UpdateCall(Sid string) (*UpdateCallResponse, error) { defer resp.Body.Close() - ps := &UpdateCallResponse{} + ps := &UpdateCall200Response{} if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { return nil, err } diff --git a/src/main/java/com/twilio/oai/TwilioGoGenerator.java b/src/main/java/com/twilio/oai/TwilioGoGenerator.java index 9c85c55b1..c14cbb92c 100644 --- a/src/main/java/com/twilio/oai/TwilioGoGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioGoGenerator.java @@ -2,9 +2,11 @@ import com.twilio.oai.common.Utility; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.function.Function; -import java.util.regex.Pattern; import java.util.stream.Collector; import java.util.stream.Collectors; @@ -20,7 +22,6 @@ import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationsMap; -import org.openapitools.codegen.utils.StringUtils; import static com.twilio.oai.common.ApplicationConstants.STRING; @@ -68,68 +69,6 @@ public ModelsMap postProcessModels(final ModelsMap objs) { return results; } - boolean containsAllOf(String modelName) { - return modelName.contains("allOf"); - } - - boolean containsStatusCode(String modelName) { - return Pattern.compile("_\\d{3}_").matcher(modelName).find(); - } - - String removeStatusCode(String modelName) { - if(modelName == null || modelName.isEmpty()) - return modelName; - return modelName.replaceFirst("_\\d{3}", ""); - } - - String removeDigits(String modelName) { - if(modelName == null || modelName.isEmpty() || modelName.contains("2010")) - return modelName; - return modelName.replaceFirst("\\d{3}", ""); - } - - String modelNameWithoutStatusCode(String modelName) { - if(modelName == null || modelName.isEmpty()) - return modelName; - String newModelName = removeStatusCode(modelName); - if(Objects.equals(newModelName, modelName)) - newModelName = removeDigits(newModelName); - return StringUtils.camelize(newModelName); - } - - @Override - public Map updateAllModels(Map objs) { - objs = super.updateAllModels(objs); - - Set modelNames = objs.keySet() - .stream() - .filter(key -> (containsStatusCode(key) || containsAllOf(key))) - .map(this::modelNameWithoutStatusCode) - .collect(Collectors.toSet()); - - objs.entrySet().removeIf(entry -> containsAllOf(entry.getKey()) || modelNames.contains(entry.getKey())); - Map updatedObjs = new HashMap<>(); - - objs.forEach((key, value) -> { - if (containsStatusCode(key)) { - ModelMap modelMap = value.getModels().get(0); - String importPath = (String) modelMap.get("importPath"); - CodegenModel model = modelMap.getModel(); - key = modelNameWithoutStatusCode(key); - model.setName(modelNameWithoutStatusCode(model.name)); - model.setClassname(modelNameWithoutStatusCode(model.classname)); - model.setClassVarName(modelNameWithoutStatusCode(model.classVarName)); - model.setClassFilename(removeStatusCode(model.classFilename)); - modelMap.setModel(model); - modelMap.put("importPath", removeDigits(importPath)); - value.put("classname", removeDigits((String) value.get("classname"))); - } - updatedObjs.put(key, value); - }); - - return updatedObjs; - } - @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); @@ -184,7 +123,6 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L for (final CodegenOperation co : opList) { Utility.populateCrudOperations(co); Utility.resolveContentType(co); - co.returnType = modelNameWithoutStatusCode(co.returnType); if (co.nickname.startsWith("List")) { // make sure the format matches the other methods