microsoft-identity-web
microsoft-identity-web copied to clipboard
Allow passing JsonSerializerOptions to DownstreamWebApiGenericExtensions
Is your feature request related to a problem? Please describe. I'm trying to call a downstream web api usnig IDownstreamWebApi. This works great, except for the fact that I want to use a custom JsonSerializerOptions class, to adjust json bevhavior.
Describe the solution you'd like Add an optional argument to all methods in DownstreamWebApiGenericExtensions, to allow passing in a JsonSerializerOptions instance.
Describe alternatives you've considered What I can do, is basically copy the extensions to my code and do it myself.
Additional context .
To be clear, if this is an enhancement that's ok by the team, I'd be happy to make a PR to implement this. Just want an OK for that first.
@mterwoord Instead of passing-in an option:
- would it work to inject a serializer in the construction of DownstreamWebApi by dependency injection? (would all the web api use the same serializer ?)
- otherwise, would it work to have an option in DownstreamWebApiOptions? Maybe an optional delegate to perform the serialization?
could you share for the moment what the public API change you have in mind?
I suggested passing-in a option, because that's how HttpClient.GetFromJsonAsync (extension method) works as well. To me this works nicely.
In my case, my whole api uses the same serializer options. In fact, to me, the HttpClient extensions work great. :-)
Any progress on this? or did i mis something?
Microsoft.Identity.Web 2.x brings the notion of IDownstreamRestApi which allows you to provide your own serializer. See
https://github.com/AzureAD/microsoft-identity-abstractions-for-dotnet/blob/b2eab97f3c0a3adc2b2bc3f51ba9a4c69c4e1cb8/src/Microsoft.Identity.Abstractions/DownstreamRestApi/DownstreamRestApiOptions.cs#L57-L78