Skip to content

fix: inference error for apiHeaders #1067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>(
{%~ for key, header in method.headers %}
"{{ key }}" to "{{ header }}",
{%~ endfor %}
Expand Down
5 changes: 2 additions & 3 deletions templates/dotnet/Package/Client.cs.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>(
{%~ for key, header in method.headers %}
"{{ key }}" to "{{ header }}",
{%~ endfor %}
Expand Down
52 changes: 13 additions & 39 deletions tests/resources/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@
"get": {
"summary": "Get Bar",
"operationId": "barGet",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -521,9 +519,7 @@
"get": {
"summary": "Get Foo",
"operationId": "fooGet",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -965,9 +961,7 @@
"get": {
"summary": "400 Error",
"operationId": "generalError400",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -1020,9 +1014,7 @@
"get": {
"summary": "500 Error",
"operationId": "generalError500",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -1075,9 +1067,7 @@
"get": {
"summary": "502 Error",
"operationId": "generalError502",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"text\/plain"
],
Expand Down Expand Up @@ -1126,9 +1116,7 @@
"get": {
"summary": "Download File",
"operationId": "generalDownload",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"*\/*"
],
Expand Down Expand Up @@ -1181,9 +1169,7 @@
"get": {
"summary": "Empty Response",
"operationId": "generalEmpty",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [],
"tags": [
"general"
Expand Down Expand Up @@ -1319,9 +1305,7 @@
"get": {
"summary": "Get Cookie",
"operationId": "generalGetCookie",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -1374,9 +1358,7 @@
"get": {
"summary": "Get headers",
"operationId": "generalHeaders",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [],
"tags": [
"general"
Expand Down Expand Up @@ -1514,9 +1496,7 @@
"get": {
"summary": "Redirect",
"operationId": "generalRedirect",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"text\/html"
],
Expand Down Expand Up @@ -1566,9 +1546,7 @@
"get": {
"summary": "Redirected",
"operationId": "generalRedirected",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -1621,9 +1599,7 @@
"get": {
"summary": "Set Cookie",
"operationId": "generalSetCookie",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"application\/json"
],
Expand Down Expand Up @@ -1767,9 +1743,7 @@
"get": {
"summary": "OAuth2",
"operationId": "generalOAuth2",
"consumes": [
"application\/json"
],
"consumes": [],
"produces": [
"text\/plain"
],
Expand Down