Skip to content

Conversation

@paulomorgado
Copy link
Contributor

@paulomorgado paulomorgado commented Oct 20, 2025

Refactor code generation templates and enhance test coverage.

  • Added CSharpCompiler.AssertCompile assertions across multiple test files to ensure generated code compiles successfully.
  • Introduced new test cases for nullable path parameters, query string handling (arrays, dictionaries, deep objects), and OpenAPI specifications.
  • Refactored path and query parameter handling in Liquid templates for improved readability and correctness.
  • Generated auto-verified test outputs for new test cases.
  • Improved handling of constructor parameters in generated clients.

Addresses #5260 #4587 #5096

@paulomorgado
Copy link
Contributor Author

@RicoSuter, I noticed some tests override the .verified.txt file instead of generating a .received.txt file and comparing it in NSwag.CodeGeneration.CSharp.Tests.csproj. Is that intended?

@lahma
Copy link
Collaborator

lahma commented Oct 20, 2025

@RicoSuter, I noticed some tests override the .verified.txt file instead of generating a .received.txt file and comparing it in NSwag.CodeGeneration.CSharp.Tests.csproj. Is that intended?

It's for easier development, so you will see the changes when proposing a PR. Can't remember but this probably should only happen in development.

@paulomorgado
Copy link
Contributor Author

@RicoSuter, I noticed some tests override the .verified.txt file instead of generating a .received.txt file and comparing it in NSwag.CodeGeneration.CSharp.Tests.csproj. Is that intended?

It's for easier development, so you will see the changes when proposing a PR. Can't remember but this probably should only happen in development.

I don't like it. How can I change it?

@lahma
Copy link
Collaborator

lahma commented Oct 20, 2025

@RicoSuter, I noticed some tests override the .verified.txt file instead of generating a .received.txt file and comparing it in NSwag.CodeGeneration.CSharp.Tests.csproj. Is that intended?

It's for easier development, so you will see the changes when proposing a PR. Can't remember but this probably should only happen in development.

I don't like it. How can I change it?

I believe the switch is here:

https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.CodeGeneration.Tests/VerifyHelper.cs#L44

@paulomorgado paulomorgado force-pushed the issues/5260 branch 3 times, most recently from a4330d4 to 001581a Compare October 21, 2025 13:45
@paulomorgado paulomorgado changed the title Fix template errors Refactor code generation templates and enhance test coverage Oct 21, 2025
@paulomorgado paulomorgado marked this pull request as ready for review October 21, 2025 13:51
@paulomorgado paulomorgado force-pushed the issues/5260 branch 7 times, most recently from 7588b31 to 1102b8c Compare October 22, 2025 09:25
@paulomorgado paulomorgado force-pushed the issues/5260 branch 2 times, most recently from 2006ab5 to 40ff6e5 Compare November 5, 2025 18:22
- Added `CSharpCompiler.AssertCompile` assertions across multiple test files to ensure generated code compiles successfully.
- Introduced new test cases for nullable path parameters, query string handling (arrays, dictionaries, deep objects), and OpenAPI specifications.
- Refactored path and query parameter handling in Liquid templates for improved readability and correctness.
- Generated auto-verified test outputs for new test cases.
- Improved handling of constructor parameters in generated clients.
@paulomorgado
Copy link
Contributor Author

Hi @RicoSuter,

All tests passed!

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.

2 participants