Replies: 2 comments
-
|
The first thing you tried should work import "@typespec/http";
using Http;
@error
model ErrorResponse {
@header contentType: "application/problem+json";
data: unknown;
}
model Result {
data: string;
}
op getStuff(): Result | ErrorResponse; |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@timotheeguerin thanks for your reply. I seen now how it should work. My file is still not working, but at least you have given me a target to shoot at. Many thanks. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all. Firstly my apologies if I am asking a common question. I am new to typespec and have searched the documentation, and this discussion without success.
I am looking for a way of setting the Content-Type in the openapi file to application/problem+json. I have tried
setting the header in the model like so.
model ErrorResponse {
@Header contentType: "application/problem+json";
}
with a decorator like so
@ContentType("application/problem+json")
model ErrorResponse {
// ...fields...
}
setting the body (which feels wrong) like so
model ErrorResponse {
@Body({ contentType: "application/problem+json" })
}
And nothing seems to work for me. The openapi output file remains unchanged.
I would welcome any suggestions. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions