Open MeikelLP opened 1 month ago
@MeikelLP thanks for taking the time to suggest this
If you know what the Refit interface should look like in such a scenario, then it would be easier for me to add support. If what you need, has to be done on the contracts/models/dto then Refitter is limited by what NSwag can do for generating contracts/models/dto
@MeikelLP thanks for taking the time to suggest this
If you know what the Refit interface should look like in such a scenario, then it would be easier for me to add support. If what you need, has to be done on the contracts/models/dto then Refitter is limited by what NSwag can do for generating contracts/models/dto
Thanks for the quick response!
Currently the interface method is generated as
Task<IApiResponse<System.Text.Json.JsonElement>> CreateMessageAsync([Body] System.Text.Json.JsonElement body, CancellationToken cancellationToken = default);
however I'd like it to be like this:
Task<IApiResponse<System.Text.Json.JsonElement>> CreateMessageAsync([Body(BodySerializationMethod.Serialized)] System.Text.Json.JsonElement body, CancellationToken cancellationToken = default);
This will cause the body
to be serialized as json and send as StringContent
rather than a StreamContent
if I assume correctly.
@MeikelLP I have never used BodySerializationMethod.Json
so I'm not sure what it does. But I can try it out and set some sort of HttpClient delegating handler to look at what payload type is on the HttpRequestMessage
Would you mind providing an example OpenAPI spec I can use to try things out?
I'm currently working with a closed source proprietary API thus I cannot share the original schema. However I tried to mask everything unnecessary:
{
"openapi": "3.0.0",
"info": {
"title": "Example",
"version": "1.0.0"
},
"paths": {
"/some/endpoint": {
"post": {
"summary": "Example",
"operationId": "someThing",
"requestBody": {
"required": true,
"content": {
"application/ld+json": {
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
}
}
}
}
Is your feature request related to a problem? Please describe. I want to send and receive
AnyType
asSystem.Text.Json.JsonElement
for max convinienceDescribe the solution you'd like Add a property alongside
anyType
likeanyTypeBodySerializationMethod
and let us adjust how the body is send.Describe alternatives you've considered Writing the interface myself :(
Additional context
System.Text.Json.JsonElement
is send as a stream. This might work in some cases but most of the time we just wanna send it as string which is only possible withBodySerializationMethod.Json
from what I can tellMaybe my assumption is wrong - I'm new to Refit