Repository navigation
Conversation
…quests Clients never send readOnly properties, so changes nested inside a readOnly property of a requestBody cannot affect the request contract. The property-level diff already filtered added/removed readOnly properties (isPropertyApplicable), but changes inside a shared readOnly property were still diffed: the nested changed schemas were reported in ChangedOpenApi#getChangedSchemas and flagged the diff backward incompatible, while the rendered report showed nothing. Skip the schema diff for shared properties that are marked readOnly on both sides in a request context, mirroring the writeOnly handling for responses. A change of the readOnly flag itself still recurses so the existing REQUEST_READONLY_* back-compat checks keep working. Response side behavior is unchanged.
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
…efs in requests Address cubic review feedback on OpenAPITools#934: - Remove the skipped readOnly property from the parent `required` diff (both increased and missing entries) so adding a response-only field to `required` can no longer flag the request as breaking. - Resolve `$ref`-referenced shared properties before checking the readOnly flag; the unresolved wrapper carries no readOnly flag, so changes inside referenced readOnly component schemas were still reported in request diffs. - Add fixtures/tests: readOnly property added to parent `required`, readOnly property referenced via `$ref`, and readOnly flag transitions (true -> false and false -> true) asserting the flag change and nested changes are still reported and never swallowed by the skip logic. Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
|
Addressed all three review threads (answers posted in each thread); pushed to
Full core suite green: 277 tests, 0 failures, 2 skipped (pre-existing). |
Summary
Fixes #357.
Per the OpenAPI spec,
readOnlyproperties are only sent in responses, never in requests. Changes nested inside areadOnlyproperty of arequestBodytherefore cannot affect the request contract and must not be reported as breaking.Previously the property-level diff already filtered added/removed
readOnlyproperties (isPropertyApplicableinSchemaDiffResult), but changes inside a sharedreadOnlyproperty were still diffed: the nestedChangedSchemaentries ended up inChangedOpenApi#getChangedSchemasand flagged the whole diff backward incompatible, while the rendered report showed nothing ("broke backward compatibility" with an empty change log).Change
In
SchemaDiffResult.diff, the shared-property loop now skips the schema diff for properties markedreadOnlyon both sides in a request context, mirroring how the existingisPropertyApplicablepattern treatsreadOnly/writeOnlyfor added/removed properties:readOnlyand the property is recursed into as before, so the existingREQUEST_READONLY_INCREASED/REQUEST_READONLY_REQUIRED_DECREASEDback-compat checks (covered byReadOnlyBCTest) keep working.readOnlyproperty in a response and awriteOnlyproperty in a response are still reported (locked with tests).readOnlyobjects are covered: skipping the diff at the outermost readOnly property prunes the whole subtree, so no recursion is added.Repro from the issue (before/after)
Before:
After:
Tests
New
Issue357Test(fixtures from the issue):changesInsideReadOnlyPropertyInRequestAreIgnored— the issue's old/new specs now produce no changed operations, no changed schemas, and an unchanged result.changesInsideWriteOnlyPropertyInResponseAreStillReported— counter-case locking current behavior: a change inside awriteOnlyproperty of a response schema is still reported and flagged incompatible.changesInsideReadOnlyPropertyInResponseAreStillReported— guards the response side: a change inside areadOnlyproperty of a response schema is still reported.Full
coremodule:mvn -pl core test— 273 tests, 0 failures (2 pre-existing skips inSwagger2CompatibilityTest).Summary by cubic
Fixes #357 by ignoring changes nested inside
readOnlyproperties in request bodies, which per the OpenAPI spec are never sent by clients and therefore can't affect the request contract.readOnlyon both sides in a request context, resolving$refwrappers before checking the flag.requireddiff, so adding a response-only field torequiredno longer flags the request as breaking.readOnlyflag itself differs between old and new, the property is still recursed into so the existing back-compat checks keep working.readOnlyorwriteOnlyresponse properties are still reported.Issue357Testcovering the issue repro,required/$refvariants,readOnlyflag transitions, and response counter-cases.Written for commit 97990c1. Summary will update on new commits.