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.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Add an old-required/new-absent fixture pair and assert the operation and the whole spec are backward incompatible when a required request body is deleted. Signed-off-by: Vadim Lazuk <vadimlazuk5@gmail.com>
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. Making the body optional cannot break existing clients that keep sending it, so the change is listed under "What's Changed" as non-breaking.incompatible.request.body.increasedproperty instead of borrowingincompatible.openapi.endpoints.decreased.Written for commit 1b791d9. Summary will update on new commits.