-
-
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
Invalid order of optional params included by operationProcessors after updating to NSwag v14.3.0 #5131
Comments
We're seeing the same in generated Typescript code. Our code base has hundreds of API methods, most of which now have parameters in different order to what our client code expects - and we get errors due to optional being before required also in Typescript. |
We also get the order issue moving from 14.2.0 to 14.3.0. We do not make use of |
This does indeed seem to be broken in the generation of OpenAPI schemas. |
Same. |
If no one is willing to investigate further and some resolution is still expected, maybe creating a most simple reproduction without the need to copy and paste things to a some solution would help out. Ideally a direct test case against NSwag repo but that might be a hard ask. |
Looking through the merged PRs, I couldn't identify a possible PR directly... maybe it's easier to just debug it and see where the order breaks? I assume it's not happening always, so would be good if someone could provide a simple repro... |
I created a minimal repo here https://github.com/xC0dex/NSwagSample. I think this code is responsible for the correct order: 14.3.0 NSwag/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs Lines 56 to 68 in 62ab9f3
The only change from 14.2.0 to 14.3.0 in this code is the usage of collection expression: 14.2.0 NSwag/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs Lines 58 to 71 in 2888363
|
Describe the bug
The order of optional params in generated dotnet client added via OperationProcessor is invalid, as they should be added after all required params. Error CS1737
Version of NSwag toolchain, computer and .NET runtime used
Dotnet 9, NSwag v14.3.0 (there's no issue in v14.2.0)
To Reproduce
OperationProcessor
Controller
Configuration in Program.cs
WebApi.csproj
nswag.json
Additional context
It's just working totally fine when switching to NSwag 14.2.0.
Expected behavior
AS IS:
TO BE:
The text was updated successfully, but these errors were encountered: