From 9821a215a7535e1bf34510bdc4db7eeca6a90875 Mon Sep 17 00:00:00 2001 From: sbansla <104902068+sbansla@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:03:52 +0530 Subject: [PATCH] corrected model json name and hasNestedRequestBody (#533) --- src/main/java/com/twilio/oai/api/ApiResourceBuilder.java | 5 +++-- src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java | 2 +- src/main/resources/twilio-java/models.mustache | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java index cf51cc0ee..c0c0a6228 100644 --- a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java @@ -3,6 +3,7 @@ import com.twilio.oai.DirectoryStructureService; import com.twilio.oai.PathUtils; import com.twilio.oai.StringHelper; +import com.twilio.oai.common.ApplicationConstants; import com.twilio.oai.common.Utility; import com.twilio.oai.resolver.Resolver; import com.twilio.oai.resource.Resource; @@ -20,7 +21,7 @@ public abstract class ApiResourceBuilder implements IApiResourceBuilder { public static final String META_LIST_PARAMETER_KEY = "x-list-parameters"; public static final String META_CONTEXT_PARAMETER_KEY = "x-context-parameters"; - public static final String NESTED_CONTENT_TYPE = "application/json"; + public static final String CONTENT_TYPE_JSON = "application/json"; protected final IApiActionTemplate template; @Getter @@ -338,7 +339,7 @@ protected void categorizeOperations() { protected boolean updateNestedContent(CodegenOperation co) { if(!hasNestedRequestBody) { if (co.bodyParam != null && co.bodyParam.getContent() != null) { - hasNestedRequestBody = co.bodyParam.getContent().containsKey(NESTED_CONTENT_TYPE); + hasNestedRequestBody = co.bodyParam.getContent().containsKey(CONTENT_TYPE_JSON); } } return hasNestedRequestBody; diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index d28bcef2b..15056d183 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -350,7 +350,7 @@ private void processDataTypesForParams(List finalQueryParamLis @Override protected Map mapOperation(CodegenOperation co) { Map operationMap = super.mapOperation(co); - if (hasNestedRequestBody) { + if (co.bodyParam !=null && co.bodyParam.getContent() != null && co.bodyParam.getContent().containsKey(CONTENT_TYPE_JSON)) { operationMap.put(SIGNATURE_LIST, generateSignatureListJson(co)); modelParameters = generateSignatureListBody(co); } else { diff --git a/src/main/resources/twilio-java/models.mustache b/src/main/resources/twilio-java/models.mustache index b1d489b31..701f91430 100644 --- a/src/main/resources/twilio-java/models.mustache +++ b/src/main/resources/twilio-java/models.mustache @@ -4,7 +4,7 @@ static public class {{classname}} { {{#vars}} @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("{{#lambda.lowercase}}{{{nameInSnakeCase}}}{{/lambda.lowercase}}") + @JsonProperty("{{{baseName}}}") @Getter @Setter private {{{dataType}}} {{name}}; {{#vendorExtensions.x-serialize}} public String get{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}() {