-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
End-to-end client validation tests #3687
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
Conversation
Apply code review suggestions from #3686.
Add a functional Todo app with and API to use for further integration/end-to-end validation.
Add tests for Todo app before refactoring to use generated Kiota code.
Generate client code from Kiota for the Todo app.
Use Kiota-generated client to interact with the Todo app.
Add a snapshot test for the code generated by Kiota.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3687 +/- ##
==========================================
+ Coverage 94.64% 94.66% +0.02%
==========================================
Files 111 111
Lines 3865 3861 -4
Branches 780 779 -1
==========================================
- Hits 3658 3655 -3
+ Misses 207 206 -1
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:
|
test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs
Outdated
Show resolved
Hide resolved
Update the Todo app and tests to prepare to reproduce #3683.
The `nullable` property should not be emitted when `type` is not. Found via `https://apinotes.io/openapi-validator`. Relates to #3649 and #3683.
Explicitly set the version to OpenAPI 3.0.
Validate the snapshots against the OpenAPI JSON schemas.
Validate snapshots of OpenAPI specifications with Spectral for errors.
Add snapshots for all of the client generation tests.
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 comprehensive end-to-end testing for client code generation from OpenAPI documents. A Todo API application serves as the test subject, with generated clients from both Kiota and NSwag validated for correctness. The PR also fixes issue #3683 related to nullable property emission and adds OpenAPI schema validation using Spectral.
- Adds a working Todo Minimal API used to generate and test OpenAPI clients
- Introduces code snapshots for generated Kiota and NSwag clients
- Implements OpenAPI schema validation with Spectral and JSON schema validation
Reviewed changes
Copilot reviewed 160 out of 315 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Multiple snapshot files | Generated client code snapshots for NSwag and Kiota clients across various test scenarios |
| .spectral.yaml | Configuration file enabling Spectral-based OpenAPI validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a working Minimal API (the venerable "Todo" app) that is used to:
This was then used to create a repro for #3683, which is then fixed.
This also identified, via the use of https://apinotes.io/openapi-validator, that
nullableshouldn't be emitted for OpenAPI 3.0 iftypeisn't, so that has also been resolved. Unfortunately I haven't yet found a validator that flags that that can be used in CI.Also:
TODO
Investigate adding snapshot tests for the NSwag and Kiota clients added by Validate OpenAPI documents create valid C# clients #3686Investigate using IBM/openapi-validator or spectral to validate the OpenAPI snapshots