ReadResponseAsString behavior #4482
-
Hi there, I wanted to ask about the intended behavior of the ReadResponseAsString option. I was hoping it would return the API response as a string to the caller, but it looks like the generated code shown below is still returning an object:
If I change the generated code to return the Text property instead, then it gives me the result I was hoping for:
However, I don't want to change the generated code. I was wondering if the generated code is working as intended, if it should actually be returning the Text property when the ReadResponseAsString flag is set to true. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
The goal of this property is not to return a string, but to read it as string. The HTTP response body is made available as a string. Therefore you can read directly from that and avoid the allocation of the string. But this has the disadvantage that deserialization errors are harder to debug. Therefore there is a property to configure that. For example you can set the property to true in you test or staging environment and set it to false in production to have better performance. |
Beta Was this translation helpful? Give feedback.
I create everything from a custom console program and have a few template customizations:
https://github.com/Squidex/squidex-samples/blob/master/csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs#L40