Skip to content

Commit

Permalink
corrected model json name and hasNestedRequestBody (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbansla authored Oct 30, 2023
1 parent 6e85d06 commit 9821a21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/twilio/oai/api/ApiResourceBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private void processDataTypesForParams(List<CodegenParameter> finalQueryParamLis
@Override
protected Map<String, Object> mapOperation(CodegenOperation co) {
Map<String, Object> 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/twilio-java/models.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}() {
Expand Down

0 comments on commit 9821a21

Please sign in to comment.