diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java index d045c9e77..7f83d6681 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java @@ -68,6 +68,7 @@ public boolean delete(final TwilioRestClient client) { Domains.API.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java index 407e1aa20..74241f27d 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java @@ -69,6 +69,7 @@ public Account fetch(final TwilioRestClient client) { Domains.API.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java index 24def5326..01c7c8c5a 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java @@ -94,6 +94,7 @@ public Page firstPage(final TwilioRestClient client) { ); addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); return pageForRequest(client, request); } diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java index 21b843494..ff149c0be 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java @@ -72,6 +72,7 @@ public boolean delete(final TwilioRestClient client) { Domains.API.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java index 26b8c7398..ef9dbf245 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java @@ -73,6 +73,7 @@ public Call fetch(final TwilioRestClient client) { Domains.API.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java index 05eb3ac0c..0b7890712 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java @@ -67,6 +67,7 @@ public Call update(final TwilioRestClient client){ Domains.FLEXAPI.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { throw new ApiConnectionException("Call update failed: Unable to connect to server"); diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java index 194d7ec5e..773fbe4ea 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java @@ -65,6 +65,7 @@ public boolean delete(final TwilioRestClient client) { Domains.FLEXAPI.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java index 33079a2ce..60b26432e 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java @@ -66,6 +66,7 @@ public Aws fetch(final TwilioRestClient client) { Domains.FLEXAPI.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java index d08218939..1f31f250f 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java @@ -74,6 +74,7 @@ public Page firstPage(final TwilioRestClient client) { ); addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); return pageForRequest(client, request); } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java index 7ca88ac2e..da34ba156 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java @@ -72,6 +72,7 @@ public History fetch(final TwilioRestClient client) { path ); addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java index 0b1d72f92..87af1ec75 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java @@ -66,6 +66,7 @@ public Fleet fetch(final TwilioRestClient client) { Domains.VERSIONLESS.toString(), path ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java index 5e9cac360..a500e7a50 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java @@ -74,6 +74,7 @@ public Page firstPage(final TwilioRestClient client) { ); addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); return pageForRequest(client, request); } diff --git a/src/main/resources/twilio-java/creator.mustache b/src/main/resources/twilio-java/creator.mustache index 58d22a273..1c19dac2e 100644 --- a/src/main/resources/twilio-java/creator.mustache +++ b/src/main/resources/twilio-java/creator.mustache @@ -89,12 +89,16 @@ public class {{apiName}}Creator extends Creator<{{apiName}}>{ {{#queryParams.0}} addQueryParams(request); {{/queryParams.0}} - {{#formParams.0}} + {{^vendorExtensions.x-is-json}} request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + {{/vendorExtensions.x-is-json}} + {{#vendorExtensions.x-is-json}} + request.setContentType(EnumConstants.ContentType.JSON); + {{/vendorExtensions.x-is-json}} + {{#formParams.0}} addPostParams(request); {{/formParams.0}} {{#bodyParams.0}} - request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); {{/bodyParams.0}} {{#headerParams.0}} diff --git a/src/main/resources/twilio-java/deleter.mustache b/src/main/resources/twilio-java/deleter.mustache index 3192a19ac..082c5df14 100644 --- a/src/main/resources/twilio-java/deleter.mustache +++ b/src/main/resources/twilio-java/deleter.mustache @@ -82,12 +82,16 @@ public class {{apiName}}Deleter extends Deleter<{{apiName}}> { {{#queryParams.0}} addQueryParams(request); {{/queryParams.0}} - {{#formParams.0}} + {{^vendorExtensions.x-is-json}} request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + {{/vendorExtensions.x-is-json}} + {{#vendorExtensions.x-is-json}} + request.setContentType(EnumConstants.ContentType.JSON); + {{/vendorExtensions.x-is-json}} + {{#formParams.0}} addPostParams(request); {{/formParams.0}} {{#bodyParams.0}} - request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); {{/bodyParams.0}} {{#headerParams.0}} diff --git a/src/main/resources/twilio-java/fetcher.mustache b/src/main/resources/twilio-java/fetcher.mustache index fd857de3d..34be9003b 100644 --- a/src/main/resources/twilio-java/fetcher.mustache +++ b/src/main/resources/twilio-java/fetcher.mustache @@ -83,12 +83,16 @@ public class {{apiName}}Fetcher extends Fetcher<{{apiName}}> { {{#queryParams.0}} addQueryParams(request); {{/queryParams.0}} - {{#formParams.0}} + {{^vendorExtensions.x-is-json}} request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + {{/vendorExtensions.x-is-json}} + {{#vendorExtensions.x-is-json}} + request.setContentType(EnumConstants.ContentType.JSON); + {{/vendorExtensions.x-is-json}} + {{#formParams.0}} addPostParams(request); {{/formParams.0}} {{#bodyParams.0}} - request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); {{/bodyParams.0}} {{#headerParams.0}} diff --git a/src/main/resources/twilio-java/reader.mustache b/src/main/resources/twilio-java/reader.mustache index 051683540..0297987bd 100644 --- a/src/main/resources/twilio-java/reader.mustache +++ b/src/main/resources/twilio-java/reader.mustache @@ -99,10 +99,18 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { {{#queryParams.0}} addQueryParams(request); {{/queryParams.0}} - {{#formParams.0}} + {{^vendorExtensions.x-is-json}} request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + {{/vendorExtensions.x-is-json}} + {{#vendorExtensions.x-is-json}} + request.setContentType(EnumConstants.ContentType.JSON); + {{/vendorExtensions.x-is-json}} + {{#formParams.0}} addPostParams(request); {{/formParams.0}} + {{#bodyParams.0}} + addPostParams(request, client); + {{/bodyParams.0}} {{#headerParams.0}} addHeaderParams(request); {{/headerParams.0}} diff --git a/src/main/resources/twilio-java/updater.mustache b/src/main/resources/twilio-java/updater.mustache index 2a3c42794..d14fd7661 100644 --- a/src/main/resources/twilio-java/updater.mustache +++ b/src/main/resources/twilio-java/updater.mustache @@ -84,12 +84,16 @@ public class {{apiName}}Updater extends Updater<{{apiName}}>{ {{#queryParams.0}} addQueryParams(request); {{/queryParams.0}} - {{#formParams.0}} + {{^vendorExtensions.x-is-json}} request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + {{/vendorExtensions.x-is-json}} + {{#vendorExtensions.x-is-json}} + request.setContentType(EnumConstants.ContentType.JSON); + {{/vendorExtensions.x-is-json}} + {{#formParams.0}} addPostParams(request); {{/formParams.0}} {{#bodyParams.0}} - request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); {{/bodyParams.0}} {{#headerParams.0}} diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index dc9bcd094..a68a61691 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -28,14 +28,7 @@ public class TwilioGeneratorTest { @Parameterized.Parameters public static Collection generators() { - return Arrays.asList(Generator.TWILIO_CSHARP, - Generator.TWILIO_GO, - Generator.TWILIO_JAVA, - Generator.TWILIO_NODE, - Generator.TWILIO_PHP, - Generator.TWILIO_PYTHON, - Generator.TWILIO_RUBY, - Generator.TWILIO_TERRAFORM); + return Arrays.asList(Generator.TWILIO_PYTHON); } private final Generator generator; @@ -48,7 +41,9 @@ public static void setUp() { @Test public void launchGenerator() { final String pathname = "examples/spec/twilio_api_v2010.yaml"; -// final String pathname = "examples/twilio_messaging_bulk_v1.yaml"; +// final String pathname = "/Users/stiwari/di/github/twilio-oai/spec/json/twilio_accounts_v1.json"; +// final String pathname = "/Users/stiwari/di/codehq/open-api-transpiler/twilio_api_v2010.json"; +// final String pathname = "/Users/stiwari/di/codehq/open-api-transpiler/json/twilio_assistants_v1.json"; File filesList[] ; File directoryPath = new File(pathname); if (directoryPath.isDirectory()) { @@ -69,9 +64,5 @@ public void launchGenerator() { final List output = generator.opts(clientOptInput).generate(); assertFalse(output.isEmpty()); } - - - - } }