Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

martincostello
Copy link
Contributor

  • Add new OpenApiRecommendedRules class that adds a new GetOperationShouldNotHaveRequestBody rule.
  • Avoid using Enter() and Exit() operations in validation rules where possible to avoid stack push/pop calls these perform.
  • Use string not String.
  • Remove redundant comments.
  • Fix typo in comment.

Resolves #2454.

- 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.
@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 14:36
@martincostello martincostello requested a review from a team as a code owner August 22, 2025 14:36
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.

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 new OpenApiRecommendedRules 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.

Address Copilot feedback.
Copy link
Member

@baywet baywet left a 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)

Copy link
Member

@baywet baywet left a 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!

@baywet baywet enabled auto-merge August 25, 2025 12:17
@baywet baywet disabled auto-merge August 25, 2025 12:18
@baywet baywet enabled auto-merge (squash) August 25, 2025 12:18
@baywet baywet merged commit d101fc3 into microsoft:main Aug 25, 2025
9 checks passed
@martincostello martincostello deleted the gh-2454 branch August 25, 2025 12:24
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.

Add default Validation Rule for path operations to not have a request body
2 participants