diff --git a/templates/android/library/src/main/java/io/package/services/Service.kt.twig b/templates/android/library/src/main/java/io/package/services/Service.kt.twig index 351ed8cc9..10f4064e5 100644 --- a/templates/android/library/src/main/java/io/package/services/Service.kt.twig +++ b/templates/android/library/src/main/java/io/package/services/Service.kt.twig @@ -127,7 +127,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) { responseType = {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}::class.java ) {%~ else %} - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( {%~ for key, header in method.headers %} "{{ key }}" to "{{ header }}", {%~ endfor %} diff --git a/templates/dotnet/Package/Client.cs.twig b/templates/dotnet/Package/Client.cs.twig index 8e1ef34a9..c3ac1ae1e 100644 --- a/templates/dotnet/Package/Client.cs.twig +++ b/templates/dotnet/Package/Client.cs.twig @@ -149,9 +149,8 @@ namespace {{ spec.title | caseUcfirst }} new HttpMethod(method), _endpoint + path + queryString); - if ("multipart/form-data".Equals( - headers["content-type"], - StringComparison.OrdinalIgnoreCase)) + if (headers.TryGetValue("content-type", out var contentType) && + "multipart/form-data".Equals(contentType, StringComparison.OrdinalIgnoreCase)) { var form = new MultipartFormDataContent(); diff --git a/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig b/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig index 3e6f356cb..a95ca7c82 100644 --- a/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig +++ b/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig @@ -55,7 +55,7 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) { "{{ parameter.name }}" to {{ parameter.name | caseCamel }}, {%~ endfor %} ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( {%~ for key, header in method.headers %} "{{ key }}" to "{{ header }}", {%~ endfor %} diff --git a/tests/resources/spec.json b/tests/resources/spec.json index fd444d014..86b167074 100644 --- a/tests/resources/spec.json +++ b/tests/resources/spec.json @@ -77,9 +77,7 @@ "get": { "summary": "Get Bar", "operationId": "barGet", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -521,9 +519,7 @@ "get": { "summary": "Get Foo", "operationId": "fooGet", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -965,9 +961,7 @@ "get": { "summary": "400 Error", "operationId": "generalError400", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -1020,9 +1014,7 @@ "get": { "summary": "500 Error", "operationId": "generalError500", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -1075,9 +1067,7 @@ "get": { "summary": "502 Error", "operationId": "generalError502", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "text\/plain" ], @@ -1126,9 +1116,7 @@ "get": { "summary": "Download File", "operationId": "generalDownload", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "*\/*" ], @@ -1181,9 +1169,7 @@ "get": { "summary": "Empty Response", "operationId": "generalEmpty", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [], "tags": [ "general" @@ -1319,9 +1305,7 @@ "get": { "summary": "Get Cookie", "operationId": "generalGetCookie", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -1374,9 +1358,7 @@ "get": { "summary": "Get headers", "operationId": "generalHeaders", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [], "tags": [ "general" @@ -1514,9 +1496,7 @@ "get": { "summary": "Redirect", "operationId": "generalRedirect", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "text\/html" ], @@ -1566,9 +1546,7 @@ "get": { "summary": "Redirected", "operationId": "generalRedirected", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -1621,9 +1599,7 @@ "get": { "summary": "Set Cookie", "operationId": "generalSetCookie", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "application\/json" ], @@ -1767,9 +1743,7 @@ "get": { "summary": "OAuth2", "operationId": "generalOAuth2", - "consumes": [ - "application\/json" - ], + "consumes": [], "produces": [ "text\/plain" ],