-
Notifications
You must be signed in to change notification settings - Fork 289
Open
Labels
CsharpPull requests that update .net codePull requests that update .net codestatus:waiting-for-triageAn issue that is yet to be reviewed or assignedAn issue that is yet to be reviewed or assignedtype:bugA broken experienceA broken experience
Description
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
This is related to #4309
When an endpoint define multiple response types for the same status code, then we can't access the non-json content
Example:
GET /tests - Accept: application/json --> returns json
GET /tests - Accept: application/octet-stream --> returns a pdf
await client.Tests.GetAsync() --> return type is the expected json object
await client.Tests.GetAsync(x =>
x.Headers.Add(HeaderNames.Accept, MediaTypeNames.Application.Json)) --> return type is the expected json object
await client.Tests.GetAsync(x =>
x.Headers.Add(HeaderNames.Accept, MediaTypeNames.Application.Octet)) --> return type is still the json object, but a Stream was expected. Pretty sure this will fail runtimeI'm expecting a Stream due to https://learn.microsoft.com/en-us/openapi/kiota/serialization?tabs=csharp#types-mapping
Expected behavior
I was expecting await client.Tests.GetAsync(x => x.Headers.Add(HeaderNames.Accept, MediaTypeNames.Application.Octet)) to return a Stream
Though I can see how that would be hard to implement. So some way to access the Stream will suffice.
Could just be
await client.Tests.GetJsonAsync();
await client.Tests.GetOctetAsync();How to reproduce
dotnet kiota generate -l CSharp -d <provided openapi> --exclude-backward-compatible --clean-output- observe you don't have access to the
application/octet-streamresponse
Open API description file
openapi: 3.0.1
info:
title: Test
version: 1.0.0
paths:
/tests:
get:
responses:
200:
description: Success
content:
application/json:
schema:
type: object
properties:
name:
type: string
application/octet-stream:
schema:
type: string
format: binaryKiota Version
1.29.0
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 codePull requests that update .net codestatus:waiting-for-triageAn issue that is yet to be reviewed or assignedAn issue that is yet to be reviewed or assignedtype:bugA broken experienceA broken experience
Type
Projects
Status
Needs Triage 🔍