You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was need to send post request with body, serialized with some json options, so when I was adding refit-client I've added this RefitSettings in it:
var jsonOptions = new JsonSerializerOptions()
{
Converters = { new JsonStringEnumMemberConverter() },
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var refitSettings = new RefitSettings(
new SystemTextJsonContentSerializer(jsonOptions)
);
services
.AddRefitClient<IMyClient>(refitSettings)
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri("http://myclienturl");
});
And all was good, request via refit-client worked as it was expected.
But a few time later, there was a need to add settings for url parameter's keys, then I've updated refit settings, adding urlParameterKeyFormatter to it like this:
var refitSettings = new RefitSettings(
new SystemTextJsonContentSerializer(jsonOptions),
urlParameterKeyFormatter: new CamelCaseUrlParameterKeyFormatter());
And formatting for url parameter's keys is working now as well, BUT - the first setting for content serialization was broken, and it doesn't work when urlParameterKeyFormatter is added to refit settings.
I checked it once again - when I remove urlParameterKeyFormatter setting, then setting for content serialization starts to work, and its stops to work when I turn back urlParameterKeyFormatter setting.
Step to reproduce
Create refit-client with settings
var jsonOptions = new JsonSerializerOptions()
{
Converters = { new JsonStringEnumMemberConverter() },
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var refitSettings = new RefitSettings(
new SystemTextJsonContentSerializer(jsonOptions),
urlParameterKeyFormatter: new CamelCaseUrlParameterKeyFormatter()
);
services
.AddRefitClient<IMyClient>(refitSettings)
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri("http://myclienturl");
});
public interface IMyClient
{
[Post("/Actions/Test")]
Task<TestResponse> TestMethod(TestRequest request);
}
public record TestRequest
{
public string TestRequestProp { get; set; }
}
public record TestResponse
{
public string TestResponseProp { get; set; }
}
2 Send POST request to client, that receives body's content only in lowerCamelCase casing.
4. See that client will return error
This should happen...
The next Refit's settings should work for both - url parameter's keys and content serialization
var jsonOptions = new JsonSerializerOptions()
{
Converters = { new JsonStringEnumMemberConverter() },
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var refitSettings = new RefitSettings(
new SystemTextJsonContentSerializer(jsonOptions),
urlParameterKeyFormatter: new CamelCaseUrlParameterKeyFormatter());
services
.AddRefitClient<IMyClient>(refitSettings)
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri("http://myclienturl");
});
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
No response
Version
No response
Device
No response
Refit Version
7.1.2
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered:
Describe the bug 🐞
I was need to send post request with body, serialized with some json options, so when I was adding refit-client I've added this RefitSettings in it:
And all was good, request via refit-client worked as it was expected.
But a few time later, there was a need to add settings for url parameter's keys, then I've updated refit settings, adding urlParameterKeyFormatter to it like this:
And formatting for url parameter's keys is working now as well, BUT - the first setting for content serialization was broken, and it doesn't work when urlParameterKeyFormatter is added to refit settings.
I checked it once again - when I remove urlParameterKeyFormatter setting, then setting for content serialization starts to work, and its stops to work when I turn back urlParameterKeyFormatter setting.
Step to reproduce
2 Send POST request to client, that receives body's content only in lowerCamelCase casing.
4. See that client will return error
Reproduction repository
https://github.com/reactiveui/refit
Expected behavior
This should happen...
The next Refit's settings should work for both - url parameter's keys and content serialization
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
No response
Version
No response
Device
No response
Refit Version
7.1.2
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered: