Repository navigation
Conversation
What: - removing a property from a request or response schema is now reported as backward incompatible, gated by two new config flags enabled by default: incompatible.request.properties.decreased (REQUEST_PROPERTIES_DECREASED) and incompatible.response.properties.decreased (RESPONSE_PROPERTIES_DECREASED) - adding properties stays backward compatible - removal of a previously required response property is now governed by RESPONSE_PROPERTIES_DECREASED; RESPONSE_REQUIRED_DECREASED continues to cover required -> optional changes (property still present) Why: - previously only removing a required property from a response schema was incompatible; removing an optional property (or any property in a request context) was reported as compatible, so clients depending on the deleted property went unnoticed. Renames surface as the missing old property, since no rename heuristic is attempted (Fixes OpenAPITools#673, addresses OpenAPITools#611) How: - ChangedSchema.compatibleForRequest/compatibleForResponse now check missingProperties through the new BackwardIncompatibleProp entries, mirroring the directional pattern used by ChangedEnum and ChangedOneOfSchema; readOnly properties in requests and writeOnly properties in responses are already filtered out of missingProperties, so they remain unflagged - SchemaBCTest gains flag tests for request/response property removal, SchemaDiffTest gains model tests (removed -> incompatible, added -> compatible, required removed -> incompatible), fixtures that incidentally removed properties were cleaned up, and the expected AsciidocRenderTest output for a removed property now shows the incompatible verdict Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
1 issue found across 19 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
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/main/java/org/openapitools/openapidiff/core/model/ChangedSchema.java">
<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/model/ChangedSchema.java:227">
P2: Removing a previously required response property is still controlled by `RESPONSE_REQUIRED_DECREASED` through `ChangedRequired`, even when `RESPONSE_PROPERTIES_DECREASED` is disabled. Exclude removed property names from the required-decrease check so that flag applies only when the property remains and becomes optional.</violation>
</file>
Removing a previously required response property was still reported as incompatible through RESPONSE_REQUIRED_DECREASED via ChangedRequired, even when RESPONSE_PROPERTIES_DECREASED was disabled. Required entries whose property no longer exists are now excluded when building ChangedRequired, so RESPONSE_REQUIRED_DECREASED only covers required -> optional changes on properties that still exist and property removal is governed solely by RESPONSE_PROPERTIES_DECREASED, as described in the PR. Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
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/main/java/org/openapitools/openapidiff/core/compare/schemadiffresult/SchemaDiffResult.java">
<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/compare/schemadiffresult/SchemaDiffResult.java:174">
P2: Removing a property that is still listed in `required` makes this helper drop that name from the old required list, so `ListDiff` reports it as a required increase. In request context this yields `REQUEST_REQUIRED_INCREASED` even though the required set is unchanged and `REQUEST_PROPERTIES_DECREASED` is disabled. Keep names that are still present in `right.getRequired()` in the old list.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| Set<String> newProperties = | ||
| right.getProperties() == null ? new LinkedHashSet<>() : right.getProperties().keySet(); | ||
| List<String> result = new ArrayList<>(); | ||
| for (String name : left.getRequired()) { |
There was a problem hiding this comment.
P2: Removing a property that is still listed in required makes this helper drop that name from the old required list, so ListDiff reports it as a required increase. In request context this yields REQUEST_REQUIRED_INCREASED even though the required set is unchanged and REQUEST_PROPERTIES_DECREASED is disabled. Keep names that are still present in right.getRequired() in the old list.
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/main/java/org/openapitools/openapidiff/core/compare/schemadiffresult/SchemaDiffResult.java, line 174:
<comment>Removing a property that is still listed in `required` makes this helper drop that name from the old required list, so `ListDiff` reports it as a required increase. In request context this yields `REQUEST_REQUIRED_INCREASED` even though the required set is unchanged and `REQUEST_PROPERTIES_DECREASED` is disabled. Keep names that are still present in `right.getRequired()` in the old list.</comment>
<file context>
@@ -158,6 +162,23 @@ private Map<String, Schema<?>> filterProperties(
+ Set<String> newProperties =
+ right.getProperties() == null ? new LinkedHashSet<>() : right.getProperties().keySet();
+ List<String> result = new ArrayList<>();
+ for (String name : left.getRequired()) {
+ if (newProperties.contains(name) || !oldProperties.contains(name)) {
+ result.add(name);
</file context>
|
Valid — ChangedRequired was built from the raw required lists, so a fully removed property still landed in getMissing() and kept reporting incompatible via RESPONSE_REQUIRED_DECREASED even with RESPONSE_PROPERTIES_DECREASED disabled. Fixed by excluding required entries whose property no longer exists when building ChangedRequired: RESPONSE_REQUIRED_DECREASED now covers only required→optional on surviving properties, and property removal is governed solely by RESPONSE_PROPERTIES_DECREASED. Covered by SchemaBCTest#responsePropsRequiredRemoved and SchemaDiffTest#testRemovedRequiredPropertyNotReportedAsRequiredDecrease; full core suite green. |
Fixes #673; addresses the schema-property part of #611. Related: #724 (configurable rules), #264/#490 (adding must stay compatible — kept as is), #940 (same directional gating for request-body requiredness).
Problem
Only removing a required property from a response schema was incompatible; removing an optional property — or any property from a request schema — was reported as compatible.
Change
Removing a property from a request or response schema is now backward incompatible; adding properties stays compatible. Gated by two new flags, both enabled by default:
incompatible.request.properties.decreased(REQUEST_PROPERTIES_DECREASED)incompatible.response.properties.decreased(RESPONSE_PROPERTIES_DECREASED)Response required-property removal is governed by
RESPONSE_PROPERTIES_DECREASED;RESPONSE_REQUIRED_DECREASEDstill covers required→optional moves. No rename heuristic is attempted: a rename surfaces as the missing old property, which is now incompatible.ChangedSchema.compatibleForRequest()/compatibleForResponse()checkmissingPropertiesthrough the newBackwardIncompatibleProp, mirroringChangedEnum/ChangedOneOfSchema.Scope notes:
readOnly/writeOnlyproperties were already filtered out bySchemaDiffResult.filterProperties; the discriminator short-circuit inComposedSchemaDiffResultis unaffected.Verification
SchemaBCTestflag tests for request removal, response removal, response required-property removal, and addition (compatible);SchemaDiffTestmodel tests —testAnyOfDiff/testAllOfDiffnow expect incompatible,addPropertyHandlingTestre-pointed at the adding direction, incidental property drops cleaned from the BC fixtures;AsciidocRenderTest.validateAsciiDocChangeFileexpected output updated. CLI: removingfooreportsMissing property: fooand exits 1 with--fail-on-incompatible; both flags set tofalserestoresBackward compatible, exit 0.Summary by cubic
Removing a property from a request or response schema is now reported as backward incompatible, so clients that depend on the deleted property no longer go unnoticed. Previously only removing a required response property was flagged; removing optional properties or any request property was reported as compatible.
Adding properties stays compatible, and no rename heuristic is attempted, so renames surface as missing properties.
REQUEST_PROPERTIES_DECREASEDandRESPONSE_PROPERTIES_DECREASEDgate the verdict per direction, both enabled by default.RESPONSE_REQUIRED_DECREASEDnow only covers properties that remain but move from required to optional; removed required properties are excluded from the required diff so they don't trip that rule.Fixes #673 and addresses the schema-property part of #611.
Written for commit fd4f808. Summary will update on new commits.