diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java index 6bdca6548..30ba8054f 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java @@ -79,7 +79,7 @@ public User create(final BearerTokenTwilioRestClient client){ Domains.PREVIEWIAM.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java index 5e5e82f58..f56013776 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java @@ -82,7 +82,7 @@ public User update(final BearerTokenTwilioRestClient client){ Domains.PREVIEWIAM.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); addHeaderParams(request); Response response = client.request(request); diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 3e95f1123..7c71de2ca 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -96,16 +96,24 @@ public IApiResourceBuilder updateTemplate() { return this; } + private void populateContentType(CodegenOperation co) { + if(co.consumes != null && !co.consumes.isEmpty()) + co.consumes.forEach(consume -> { + if(consume.getOrDefault("mediaType", "").equals(CONTENT_TYPE_JSON)) + co.vendorExtensions.put("x-is-json", true); + }); + } + @Override public ApiResourceBuilder updateOperations(Resolver codegenParameterIResolver) { headerParamModelList = new HashSet<>(); JsonRequestBodyResolver jsonRequestBodyResolver = new JsonRequestBodyResolver(this, codegenPropertyIResolver); this.codegenOperationList.forEach(co -> { updateNestedContent(co); + populateContentType(co); updateHttpMethod(co); List filePathArray = new ArrayList<>(Arrays.asList(co.baseName.split(PATH_SEPARATOR_PLACEHOLDER))); String resourceName = filePathArray.remove(filePathArray.size()-1); - co.allParams.stream() .filter(item -> !(item.getContent() != null && item.getContent().get("application/json") != null)) @@ -631,7 +639,7 @@ public void addEnums(IJsonSchemaValidationProperties item) { } else { enumName = ((CodegenProperty) enumItem).enumName; } - + if (enumName.equals(newItemEnumName)) { isDuplicate = true; break; // No need to continue checking duplicates