RicoSuter/NSwag

Option to provide PrepareRequest etc. in base class for SwaggertoCSharpClientGenerator ?

Aperta

#1333 aperta il 19 mag 2018

 (3 commenti) (12 reazioni) (0 assegnatari)C# (1356 fork)batch import
help wantedtype: enhancement

Metriche repository

Star
 (7358 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Hi,

I would like an option so below methods are not partial but instead expected to be provided in a base class

        partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
        partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
        partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);

This since I use multiple clients from x versions of a swagger document, but they all share common base class (which I want use to log the requests with and add auth headers).

The current workaround I'm aware of is to create a dummy client for each generated client, just to invoke the base class dito of above partial method, which starts to pile up when I use generate 1 client per endpoint/resource.

(I guess this is sortof a light version of #1061 ?)

Maybe similar to GenerateUpdateJsonSerializerSettingsMethod, a new option something like GenerateRequestResponseProcessMethods or similar to define behavior of having them as partial or not?

Thanks.

Guida contributor