Closed bzwieratinnovadis closed 10 months ago
Not sure if related, but I checked with version built in #4680 and it works correctly (i used NSwag.Studio instead of MSBuild)
"/api/Values/confirm/{batch}": {
"get": {
"tags": [
"Values"
],
"operationId": "Values_Confirm",
"parameters": [
{
"name": "batch",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
},
"x-position": 1
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(BaseUrl)) urlBuilder_.Append(BaseUrl);
// Operation Path: "api/Values/confirm/{batch}"
urlBuilder_.Append("api/Values/confirm/");
urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(batch, System.Globalization.CultureInfo.InvariantCulture)));
So I've been messing around with NSwagStudio to reproduce the issue and figured out why the code was generated incorrectly. Apparently there was a template being used that causes the issue, because without it everything works fine and path/route parameters are handled correctly. Hopefully this will help someone.
Closing the issue. Thanks everyone!
@RicoSuter I'm having an issue with route parameters with the stable release (v14.0.0) in a .NET 8 project. It seems to be related to issue #4587. I'm using NSwag.MSBuild to generate a CSharp client.
I have the following controller action:
OpenAPI definition:
The resulting client:
The request URI ends up being:
api/message-box-batch/confirm/{batch}462995b7-433b-4382-b4d7-5f84599cf732
When the client is called the API returns a 400 Bad Request response due to the malformed URI.
In v13.20.0 the client was generated correctly:
Is there some workaround in terms of configuration? Or should I wait for the next minor/patch version?