-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
NSwag C# Client generation does not set BaseUrl properly #4637
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
Comments
is this with the latest preview packages? |
Yes. the latest i could get on saturday at least |
@paulomorgado is this related to your change? |
How can we repro this, @taori? |
I simply picked some swagger definition and generated a client from that. That constructor is being generated. Once i used it, i noticed it does not work as expected |
@taori, can you, please, provide a simple swagger definition and what were you expecting from the 14 generator and failed and how? We need concrete examples for the investigation. |
I'm having the same problem, it can be reproduced using this sample open api: https://petstore.swagger.io/v2/swagger.json, var settings = new CSharpClientGeneratorSettings
{
GenerateClientClasses = true,
GenerateOptionalParameters = true,
ClassName = "{controller}Client",
OperationNameGenerator = operationNameGenerator, //failing with both MultipleClientsFromFirstTagAndOperationNameGenerator and SingleClientFromOperationIdOperationNameGenerator
CSharpGeneratorSettings =
{
Namespace = "someCustomNamespace",
JsonLibrary = CSharpJsonLibrary.SystemTextJson,
ClassStyle = CSharpClassStyle.Poco,
},
UseHttpClientCreationMethod = false,
DisposeHttpClient = true,
GenerateSyncMethods = false,
GeneratePrepareRequestAndProcessResponseAsAsyncMethods = false,
}; generated code//---------------------- // // Generated using the NSwag toolchain v14.0.0.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) // //----------------------#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." namespace LINQPad.User
} #pragma warning restore 108 edit: actually my problem seems to be different in version 13 the url was initialized like this private string _baseUrl = "https://petstore.swagger.io/v2"; now its: #pragma warning disable 8618 // Set by constructor via BaseUrl property
private string _baseUrl;
#pragma restore disable 8618 // Set by constructor via BaseUrl property but it is not set in the constructor or anywhere else |
I think I have a working solution at #4691, but I need to do more tests. In the meantime, I'd appreciate if someone could test the template in the PR. |
This is a generated client:
The generated client should use the property setter to set the BaseUrl property, or the reader should add a trailing slash so the address is correct.
Obviously i can just fix this on my end myself but i thought i'd report it.
The text was updated successfully, but these errors were encountered: