Repository navigation
Conversation
What: - a request body changing from required to optional is now reported as a compatible change instead of an incompatible one - optional -> required stays incompatible; the check is now gated by the previously unused incompatible.request.body.increased property (REQUEST_BODY_REQUIRED_INCREASED) instead of incompatible.openapi.endpoints.decreased - a removed request body whose old body was required stays incompatible Why: - existing clients that keep sending the body still work when the body becomes optional, so the change cannot break them (Fixes OpenAPITools#329) How: - ChangedRequestBody.isCoreChanged short-circuits to COMPATIBLE when both bodies exist and only the required flag decreases, mirroring the directional checks in ChangedRequired and ChangedReadOnly - RequestBodyBCTest now covers both directions and RequestDiffTest gains model-level assertions for both directions Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/src/test/java/org/openapitools/openapidiff/core/RequestDiffTest.java">
<violation number="1" location="core/src/test/java/org/openapitools/openapidiff/core/RequestDiffTest.java:38">
P2: The new tests do not cover the stated invariant that removing a required request body remains incompatible. Add an old-required/new-no-`requestBody` fixture and assert the resulting operation and spec are incompatible.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| } | ||
|
|
||
| @Test | ||
| public void testRequestBodyRequiredIncreasedIsIncompatible() { |
There was a problem hiding this comment.
P2: The new tests do not cover the stated invariant that removing a required request body remains incompatible. Add an old-required/new-no-requestBody fixture and assert the resulting operation and spec are incompatible.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At core/src/test/java/org/openapitools/openapidiff/core/RequestDiffTest.java, line 38:
<comment>The new tests do not cover the stated invariant that removing a required request body remains incompatible. Add an old-required/new-no-`requestBody` fixture and assert the resulting operation and spec are incompatible.</comment>
<file context>
@@ -12,4 +15,37 @@ public class RequestDiffTest {
+ }
+
+ @Test
+ public void testRequestBodyRequiredIncreasedIsIncompatible() {
+ // optional -> required: clients that do not send the body break
+ ChangedOpenApi changedOpenApi =
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #329
What
Diffing a spec where an operation's request body changed from
required: trueto optional (required: falseor the key removed) now reports a compatible change instead of an incompatible one. The reverse direction, optional to required, stays incompatible.Why
Making a required request body optional cannot break existing clients: they keep sending the body, and the server must keep accepting it under the new spec. Reporting that as breaking is a false positive that blocks CI pipelines relying on
--fail-on-incompatible.How
ChangedRequestBody.isCoreChanged()now short-circuits toCOMPATIBLEwhen both the old and new request bodies exist and only the required flag decreases, mirroring the directional checks already used byChangedRequired(schema properties) andChangedReadOnly:incompatible.request.body.increasedproperty (REQUEST_BODY_REQUIRED_INCREASED) instead ofincompatible.openapi.endpoints.decreased, which the request body check had been borrowing as a placeholder. Wiring the intended property also brings the request body in line with every other backward-incompatibility check, which gates on its own property.Tests
RequestBodyBCTestnow covers both directions:requiredIncreased(incompatible whenincompatible.request.body.increasedis enabled, compatible when disabled) andrequiredDecreasedButCompatible(always compatible)RequestDiffTestgains model-level assertions for both directions, checking the operation and spec-level verdicts./mvnw testis greenCLI check
For
required: true->required: falseon the same operation:and the reverse pair still reports
incompatible.Summary by cubic
Fixes #329: a request body changing from
required: trueto optional (required: falseor the key removed) is now reported as a compatible change instead of an incompatible one. Optional to required stays incompatible.incompatible.request.body.increasedproperty instead of borrowingincompatible.openapi.endpoints.decreased.Written for commit 58c1d97. Summary will update on new commits.