You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scaffolding minimal api from class with primary key Id capitalises method parameter but uses lower case for route pattern. This causes Connect Services OpenAPI code generation (NSwag) to generate erroneous code.
Steps to reproduce
Create simple dto
public class Dto
{
public string Id { get; set; }
}
Scaffold minimal api with read/write endpoints using Entity Framework and OpenAPI enabled. Code generated will look like this:
Note the parameter name Id instead of id. If scaffolding using controllers, the lower case version is used.
Using dotnet swagger to generate the open api json results in route with lower case, but parameter name capitalised. This in turn causes NSwag to generate incorrect code, where they try to replace {Id} but should be replacing {id}
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/Dto/{id}");
urlBuilder_.Replace("{Id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));
Microsoft.VisualStudio.Web.CodeGeneration.Design/Microsoft.DotNet.MSIdentity version: 6.0.6
Target framework: .NET 6.0
Operating system: Windows 11
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered:
Scaffolding minimal api from class with primary key
Id
capitalises method parameter but uses lower case for route pattern. This causes Connect Services OpenAPI code generation (NSwag) to generate erroneous code.Steps to reproduce
Note the parameter name
Id
instead ofid
. If scaffolding using controllers, the lower case version is used.Using
dotnet swagger
to generate the open api json results in route with lower case, but parameter name capitalised. This in turn causes NSwag to generate incorrect code, where they try to replace{Id}
but should be replacing{id}
Microsoft.VisualStudio.Web.CodeGeneration.Design/Microsoft.DotNet.MSIdentity version: 6.0.6
Target framework: .NET 6.0
Operating system: Windows 11
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered: