Skip to content

Conversation

@stn1slv
Copy link
Contributor

@stn1slv stn1slv commented Oct 4, 2025

Summary

This PR implements comprehensive XSD (XML Schema Definition) compatibility checking for the Apicurio Registry, enabling validation of schema evolution according to industry-standard compatibility rules.

Changes

New Features

  • XSD Compatibility Checker - Full implementation supporting all compatibility modes:
    • BACKWARD - Old data readable by new schema
    • FORWARD - New data readable by old schema
    • FULL - Both backward and forward compatible
    • BACKWARD_TRANSITIVE, FORWARD_TRANSITIVE, FULL_TRANSITIVE - Historical version validation
    • NONE - No compatibility checking

Implementation Details

Core Implementation:

  • XsdCompatibilityChecker (~715 lines) - Main compatibility checker extending AbstractCompatibilityChecker
  • DOM-based XSD parsing with comprehensive element/attribute/type extraction
  • Validates schema evolution rules: element/attribute changes, occurrence constraints, type restrictions, enumerations

Key Capabilities:

  • Detects backward incompatibilities (adding required elements, removing content, tightening constraints)
  • Detects forward incompatibilities (adding optional elements, relaxing constraints, broadening types)
  • Validates across entire version history in transitive modes
  • Provides detailed error messages with XPath-like context

Modified Files

  • schema-util/xsd/src/main/java/io/apicurio/registry/rules/compatibility/XsdCompatibilityChecker.java (NEW)
  • schema-util/xsd/src/test/java/io/apicurio/registry/rules/compatibility/XsdCompatibilityCheckerTest.java (NEW)
  • schema-util/util-provider/src/main/java/io/apicurio/registry/types/provider/XsdArtifactTypeUtilProvider.java (Modified - 1 method)
  • schema-util/xsd/pom.xml (Added JUnit 5 dependency)
  • schema-util/xsd/README.md (NEW - Comprehensive documentation)

Testing

Test Coverage

  • 20 unit tests with 100% pass rate
  • 0 failures, 0 errors, 0 skipped

Test Categories:

  • 10 backward compatibility tests (5 compatible, 5 incompatible scenarios)
  • 7 forward compatibility tests (3 compatible, 4 incompatible scenarios)
  • 2 full compatibility tests
  • 1 NONE mode test

Test Scenarios Include:

  • Adding/removing optional and required elements
  • Adding/removing optional and required attributes
  • Changing occurrence constraints (minOccurs, maxOccurs)
  • Tightening/loosening type restrictions (numeric ranges, string lengths, patterns)
  • Adding/removing enumeration values
  • Transitive compatibility validation across version history

Build Status

[INFO] BUILD SUCCESS
[INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0

Enhanced the XSDCompatibilityChecker to detect removal of any elements/attributes (not just required ones) and addition of new required elements/attributes as backward incompatible. Improved parsing of elements and attributes from complex types. Updated test cases for clarity and added XsdCompatibilityManualTest for manual verification. Added documentation describing the implementation and rules.
Added IMPLEMENTATION_SUMMARY.md summarizing the XSD compatibility checker implementation and test results. Expanded XSD_COMPATIBILITY_IMPLEMENTATION.md with more details on compatibility modes, rules, and test coverage. Added new and improved tests for forward, full, and transitive compatibility in XsdCompatibilityCheckerTest.java to ensure comprehensive validation of XSD schema evolution scenarios.
Deleted IMPLEMENTATION_SUMMARY.md, XSD_COMPATIBILITY_IMPLEMENTATION.md, and XsdCompatibilityManualTest.java, consolidating documentation into a new comprehensive README.md for the XSD compatibility checker. This streamlines documentation and removes the standalone manual test, as all relevant information and usage details are now included in README.md.
Changed the XSD mapping support from 'None' to 'Full' in the assembly rule reference documentation to accurately reflect current capabilities.
Copilot AI review requested due to automatic review settings October 4, 2025 14:10
Copy link

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 implements comprehensive XSD compatibility checking for the Apicurio Registry, enabling validation of schema evolution according to industry-standard compatibility rules.

  • Adds full XSD compatibility checker supporting all compatibility modes (BACKWARD, FORWARD, FULL, and TRANSITIVE variants)
  • Implements DOM-based XSD parsing with comprehensive element/attribute/type extraction and validation
  • Provides 20 comprehensive unit tests covering all compatibility scenarios with 100% pass rate

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
XsdCompatibilityChecker.java New ~715 line implementation with DOM-based parsing and compatibility validation logic
XsdCompatibilityCheckerTest.java New comprehensive test suite with 20 tests covering all compatibility modes
XsdArtifactTypeUtilProvider.java Modified to use new XsdCompatibilityChecker instead of NoopCompatibilityChecker
pom.xml Added JUnit 5 dependency for testing
README.md New comprehensive documentation of implementation and usage
assembly-rule-reference.adoc Updated documentation to reflect XSD compatibility support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@EricWittmann
Copy link
Member

Thanks for the contribution @stn1slv 👍

@EricWittmann EricWittmann merged commit ab478f2 into Apicurio:main Oct 6, 2025
20 checks passed
@stn1slv stn1slv deleted the xsd-compartibility-rules branch October 7, 2025 06:59
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.

2 participants