Replies: 3 comments
-
Your TypeSpec seems fine to me, I would expect pet_name on the wire as a bare string (without even any quotes). And indeed the OpenAPI emit reflects this. This seems to be an issue with the code generator, maybe @m-nash can comment further. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is definitely a gap in our current generator. I have opened this issue to track Azure/autorest.csharp#3816 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@feyyangms This issue has been fixed. Please have a try. |
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
-
Hello! I'm new to TypeSpec
For example, an endpoint defined in routes.tsp:
tspconfig.yaml (partial):
Run
tsp compile .
to generate dotnet/C# client.Result:
The response body is a JSON string like "{"pet_name": "Meow"}"...but I want to keep it as a string instead of desacralize it into a Type...
That
ToObjectFromJson<string>()
is causing JSON deserialization error in this case.Manually changing it to response.Content.ToString() worked - the JSON string from the response body is directly passed to
Response.FromValue(string, Response)
.I'm assuming putting
@header contentType: "text/plain";
in the endpoint definition will tell TypeSpec to treat the response body as plain text instead of the default application/json, thus generatingresponse.Content.ToString()
. But seems that header specification isn't being picked up by TypeSpec?Am I missing anything on what I want to achieve? Or should I report this as an issue? Appreciate your help!
Beta Was this translation helpful? Give feedback.
All reactions