-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
.NET 6 support (DateOnly/TimeOnly) #3576
Comments
Sounds like you're better off than me. Just running with the VS2022 preview installed breaks my previously working nswag process looking for Microsoft.AspNetCore.Authentication, Version=5.0.0.0 Stack TraceSystem.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Authentication, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.AspNetCore.Authentication, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
I figured basically everyone would hit this, but since you clearly didn't, it's probably worth mentioning here 😄 |
@GrahamTheCoder You should not use WebApiToSwaggerCommand but AspNetCoreToSwaggerCommand because the WebApi one is reflection only and should only be used for legacy (ie asp.net mvc) apps. |
@stephtr if this is only about missing type support (like DateOnly) we can already add support for this (in NJsonSchema). Currently I'm a bit hesitant to already add new target frameworks for .NET 6 yet (ie for the CLI etc) - however referencing NSwag as nuget package (NSwag.AspNetCore) should work in general... Right now you could add a custom primitive type mapper for e.g. DateOnly and map it to type "string" and format "date" |
|
Thanks, that's perfect! Since currently I can't think of any other .NET 6 only features, I'll close the issue. |
Works fine if the DateOnly is in the results, but if used as an action parameters, DateOnly appears as a Complex Type and not a string with date format.
Edit: It's normal for nswag, as the dotnet team doesn't fully support it. |
@Itori I wonder why that is, the type DateOnly should be resolved the same way and it should end up with a string property... or is it reported as multiple properties/params automatically by API explorer? |
Not sure exactly but it's not simply a problem of exposure, as if I query with a string, I got an exception. Find this issue planing support for .Net 7 : dotnet/aspnetcore#34591 |
This fixes DateOnly model properties serialization, but I'm wondering how fix the parameters too...
|
@Havunen This worked for me for query parameters:
|
Pretty sure this thread is about NSwag, not Swashbuckle, and you're confusing matters by referencing a method from Swashbuckle:
Found it:
|
Hi,
What is the current plan for .NET 6 (preview) support? Currently NSwag fails when using for example the new
DateOnly
type.The text was updated successfully, but these errors were encountered: