Skip to content
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

Fix optional parameter ordering in generated TS/CS clients #5135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Apr 6, 2025

This was a regression caused by #5044 . The PR unintentionally "fixed" the swallowed double-OrderBy where only second one would run by changing second one to ThenBy, but actually the second one was the primary ordering.

Now trying to follow the desired path were anything non-optional makes priority in ordering and only after then the parameter's actual position is being considered.

fixes #5131

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptOperationModel.cs:45

  • Verify that reversing the ordering with '!p.IsRequired' correctly prioritizes required parameters as intended, since the test expects required parameters to appear before optional ones.
.OrderBy(p => !p.IsRequired)

src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs:61

  • Confirm that using '!p.IsRequired' to order required parameters before optional ones aligns with the expected client output in C#.
.OrderBy(p => !p.IsRequired)

src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs:62

  • Check if the additional ordering based on whether 'p.Default' is null is intentional to further prioritize parameters, and ensure it does not conflict with the desired ordering logic.
.ThenBy(p => p.Default == null)

@lahma lahma requested a review from RicoSuter April 6, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid order of optional params included by operationProcessors after updating to NSwag v14.3.0
1 participant