-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add NSwag client test #3689
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
Add NSwag client test #3689
Conversation
martincostello
commented
Nov 30, 2025
- Add a test that uses an NSwag-generated client.
- Move/rename the tests to avoid ambiguity with the NSwag client.
Move/rename the tests to avoid ambiguity with an NSwag client.
Add a test that uses an NSwag-generated client.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3689 +/- ##
=======================================
Coverage 94.66% 94.66%
=======================================
Files 111 111
Lines 3861 3861
Branches 779 779
=======================================
Hits 3655 3655
Misses 206 206
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds NSwag client generation and testing capabilities alongside the existing Kiota client, and reorganizes the test structure to clearly distinguish between the two client types.
- Adds NSwag as a code generation tool with corresponding test suite
- Renames Kiota client namespace from
TodoApp.ClienttoTodoApp.KiotaClientfor clarity - Consolidates client generation into a single script supporting both Kiota and NSwag
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
.config/dotnet-tools.json |
Adds NSwag.ConsoleCore v14.6.3 as a dotnet tool |
generate-todo-clients.ps1 |
New unified script that generates both Kiota and NSwag clients |
generate-todo-client.ps1 |
Removed old Kiota-only generation script |
KiotaClientTests.cs |
New test file containing Kiota client integration tests (moved from CodeGenerationTests.cs) |
NSwagClientTests.cs |
New test file containing NSwag client integration tests |
CodeGenerationTests.cs |
Refactored to only verify generated client snapshots, removing actual API tests |
KiotaTodoClient/**/*.cs |
Updated namespace from TodoApp.Client to TodoApp.KiotaClient |
NSwagTodoClient/**/*.cs |
New NSwag-generated client code in TodoApp.NSwagClient namespace |
snapshots/**/*.verified.cs |
New snapshot files for both Kiota and NSwag generated clients |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| public override string ToString() | ||
| { | ||
| return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant call to 'ToString' on a String object.
|
|
||
| public override string ToString() | ||
| { | ||
| return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant call to 'ToString' on a String object.
| private string _baseUrl; | ||
| #pragma warning restore 8618 | ||
|
|
||
| private System.Net.Http.HttpClient _httpClient; |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_httpClient' can be 'readonly'.
| private System.Net.Http.HttpClient _httpClient; | |
| private readonly System.Net.Http.HttpClient _httpClient; |
| #pragma warning restore 8618 | ||
|
|
||
| private System.Net.Http.HttpClient _httpClient; | ||
| private static System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings, true); |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field '_settings' can be 'readonly'.
| private static System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings, true); | |
| private static readonly System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings, true); |