Skip to content

KiotaBuilder is incorrectly finding and using Default media types for contentless responses #6413

@JSparshottO2

Description

@JSparshottO2

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Csharp

Describe the bug

As mentioned and exampled in this discussion. The content types for the default are found and used for the Accept header in a generated request when they shouldn't be.

Expected behavior

Accept header isn't provided when calling an API whose definition provides no media type.

How to reproduce

see associated discussion

Open API description file

{
"openapi": "3.0.1",
"info": {
"title": "My Api",
"description": "An example spec with a generational issue",
"version": "v1",
"x-framework": {
"name": "blablabla"
}
},
"servers": [{
"url": "https://my.exampledomain.com/awesome/api"
}
],
"security": [{
"OAuth_1.0_authorization": []
}
],
"paths": {
"/data": {
"post": {
"tags": ["data"],
"summary": "Insert data.",
"requestBody": {
"description": "Request body.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/data"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "Inserted record."
},
"default": {
"description": "Error response.",
"content": {
"application/custom-error": {
"schema": {
"$ref": "#/components/schemas/error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"error": {
"type": "object",
"properties": {
"message": {
"title": "Error reason",
"type": "string",
"readOnly": true
}
}
},
"data": {
"type": "object",
"properties": {
"stuff": {
"title": "Some Data",
"type": "string"
},
"numberedStuff": {
"title": "Some number",
"type": "integer",
"format": "int64"
}
}
}
}
}
}

Kiota Version

1.24.3

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

_No response_

Metadata

Metadata

Assignees

Labels

CsharpPull requests that update .net codegeneratorIssues or improvements relater to generation capabilities.help wantedIssue caused by core project dependency modules or librarytype:bugA broken experience

Type

Projects

Status

Done ✔️

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions