-
Notifications
You must be signed in to change notification settings - Fork 271
Add Validation Rule for path operations to not have a request body #2472
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
- Avoid using `Enter()` and `Exit()` operations in validation rules where possible. - Use `string` not `String`. - Remove redundant comments. - Fix typo in comment.
Add new `OpenApiRecommendedRules` class and adds a new `GetOperationShouldNotHaveRequestBody` rule. Resolves microsoft#2454.
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 a new validation rule to check that GET operations should not have request bodies, along with several code quality improvements. The changes introduce the OpenApiRecommendedRules
class with a specific validation rule for GET operations and refactor existing validation rules to optimize performance.
- Adds
GetOperationShouldNotHaveRequestBody
validation rule in newOpenApiRecommendedRules
class - Optimizes validation rules by avoiding unnecessary
Enter()
/Exit()
calls when validation conditions aren't met - Standardizes string usage and fixes typos across validation rule files
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/Microsoft.OpenApi/Validations/Rules/OpenApiRecommendedRules.cs |
New class containing the GET operation request body validation rule |
test/Microsoft.OpenApi.Tests/Validations/OpenApiRecommendedRulesTests.cs |
Comprehensive tests for the new validation rule |
test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt |
Updates public API surface to include new class |
Multiple validation rule files | Performance optimizations and code quality improvements |
src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs |
Typo fix in comment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Microsoft.OpenApi/Validations/Rules/OpenApiResponsesRules.cs
Outdated
Show resolved
Hide resolved
Address Copilot feedback.
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.
Thanks for the contribution!
Can you please add a unit test to validate this rule IS NOT present in the default rules (prevent regressions)
Address feedback.
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.
Thank you for making the changes!
OpenApiRecommendedRules
class that adds a newGetOperationShouldNotHaveRequestBody
rule.Enter()
andExit()
operations in validation rules where possible to avoid stack push/pop calls these perform.string
notString
.Resolves #2454.