Closed manolitooo closed 7 months ago
Working as expected. Sorry :).
@manolitooo Do you know why the partial methods aren't created?
@manolitooo Do you know why the partial methods aren't created?
It's invalid c#.
How is this supposed to be used if the generated code has errors?
FWIW, I had the same issue and I resolved it by defining a (common to clients) base class
in settings
"codeGenerators": {
"openApiToCSharpClient": {
"clientBaseClass": "BaseClient",
And then for example (you can use Task or ValueTask, your mileage may vary depending on your other settings):
public abstract class BaseClient
{
protected virtual ValueTask PrepareRequestAsync(HttpClient client, HttpRequestMessage request, string url, CancellationToken cancellationToken)
{
return ValueTask.CompletedTask;
}
protected virtual ValueTask PrepareRequestAsync(HttpClient client, HttpRequestMessage request, StringBuilder url, CancellationToken cancellationToken)
{
return ValueTask.CompletedTask;
}
protected virtual ValueTask ProcessResponseAsync(HttpClient client, HttpResponseMessage response, CancellationToken cancellationToken)
{
return ValueTask.CompletedTask;
}
}
Now you can override this in the class you need to do it.
Hi,
By having a look into this closed issue, I'm wondering if I'm doing something incorrectly. But after diving in the NSwag code, it does not seem so. I have found out the following within Client.Class.liquid:
Isn't it missing an "else" block to define the partial methods for the async case? Currently, I am getting the following error:
And I can confirm the generated code is missing that block of code where it is expected to be written.
Thanks in advance.