-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for a custom/wrapped HttpClient class #646
Comments
I'd say we add a setting SwaggerToCSharpClientGeneratorSettings.HttpClientType (default "System.Net.Http.HttpClient") and replace all "System.Net.Http.HttpClient" with this setting... What do you think? |
Seems to be just like the approach we took. Except for the naming, but HttpClientType would certainly cut it. |
Yes, the naming is like DateTimeType which already exists... Can you create a PR with only these changes? |
I've prepared a pull request, but I've got a couple of issues due to only having VS2017 at my disposal. I'm not able to check in the NSwagStudio because VS2017 restructured it & I can't open the NSwag.Core.sln because VS2017 will automatically try to convert the .xproj files to the new .csproj files. Do you have any objection to these conversion? If you do, I can push an isolated pull request without touching the abovementioned projects. |
I'll do this upgrade myself and remove the NSwag.Core.sln solution completely if this is possible... Just create a PR for the new setting |
I'd like to have the possibility to specify which HttpClient to use. Although the
System.Net.Http.HttpClient
doesn't really implement an interface, I still want to be able to specify another type which completely respects the method signatures currently found on theSystem.Net.Http.HttpClient
. The type I would specify would be a wrapper around the currentSystem.Net.Http.HttpClient
.Why would I need this? I'm currently in need to wrap the HttpClient calls in order to make my client more robust. With this I mean that when a call to a service fails, due to timeouts, or network errors, ... I'd likt to retry the call a number of times, or with an exponential backoff mechanism. For this I would currenlty use the Polly library which allows me to do just that. However, today I need to wrap the calls the client calls, while it would be really helpful to have this functionality by being able to inject the HttpClient type.
If desired I can even create a pull request as I already have the code changes.
The text was updated successfully, but these errors were encountered: