Skip to content
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

[feature]: support various content types for response #4225

Closed
3 tasks done
archerzz opened this issue Aug 21, 2024 · 4 comments
Closed
3 tasks done

[feature]: support various content types for response #4225

archerzz opened this issue Aug 21, 2024 · 4 comments
Assignees
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@archerzz
Copy link
Member

Clear and concise description of the problem

Right now, we hard code JSON as the response content type, which is wrong:

BodyType: r.type ? fromSdkType(r.type, sdkContext, modelMap, enumMap) : undefined,
BodyMediaType: BodyMediaType.Json,
Headers: fromSdkServiceResponseHeaders(r.headers, sdkContext, modelMap, enumMap),

See an issue reported in #4208 (comment)

We should have support for various kinds of content types. That is:

  • replace hard coded media type with the one determined by parsing the operation response
  • dump BodyMediaType enum and corresponding reference, we should support a wide range of media types

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@archerzz archerzz added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Aug 21, 2024
archerzz pushed a commit to archerzz/typespec that referenced this issue Aug 21, 2024
- replace hard-coded value for `BodyMediaType`
- fix an bug in deducing media type from type, array should be `json`

part of microsoft#4208
work around microsoft#4225
@m-nash
Copy link
Member

m-nash commented Jan 8, 2025

MediaType/StringBody/getAsText is an example of the test that is failing here.

@JoshLove-msft
Copy link
Contributor

@archerzz I believe this is related to the discussion from the sync yesterday regarding how content types should work for both request/response in MGC.

@JoshLove-msft
Copy link
Contributor

We should not be hardcoding anything related to media type. This should come from the compiler only.

@JoshLove-msft JoshLove-msft self-assigned this Mar 25, 2025
@JoshLove-msft
Copy link
Contributor

This has been fixed - we no longer hardcode JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

No branches or pull requests

3 participants