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

Should compiler guess a content type/accept header if it's absent #5408

Open
qiaozha opened this issue Dec 19, 2024 · 0 comments
Open

Should compiler guess a content type/accept header if it's absent #5408

qiaozha opened this issue Dec 19, 2024 · 0 comments

Comments

@qiaozha
Copy link
Member

qiaozha commented Dec 19, 2024

See this original issue Azure/typespec-azure#1994, in the case where the content type is absent.

  op default(
    @body
    value: bytes,
  ): NoContentResponse;

As discussed in DPG office hour, compiler have two options here:

  1. try our best to guess a content type.
  2. trust whatever the spec says.

Currently, we lean towards to take option1 for this on the client side. But as this information could be used in both server generation and client generation and maybe other emitters, it would be problematic if the server emitter is taking a different approach than the client emitter.
Maybe the compiler side should unify the logic here?

A proposed guessing logic is:

  1. bytes: octect-stream
  2. model: json
  3. everything else: text/plain

I think this also applies to accept header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant