class SchemaComparator extends AnyRef
Utility for comparing schemas for compatibility. See compare for more details.
Since this class contains a cache of comparison results, it is meant to be reused between multiple schema comparisons.
- Alphabetic
- By Inheritance
- SchemaComparator
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new SchemaComparator(writerNamedSchemas: Map[String, Schema], readerNamedSchemas: Map[String, Schema])
- new SchemaComparator(writerSchemaResolver: SchemaResolver, readerSchemaResolver: SchemaResolver)
- writerSchemaResolver
can resolve named schemas which may be referred to by the writer schema
- readerSchemaResolver
can resolve named schemas which may be referred to by the reader schema
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def compare(writerSchema: SchemaLike, readerSchema: SchemaLike): List[SchemaCompatibilityIssue]
Compares two schemas for compatibility.
Compares two schemas for compatibility. More precisely, checks if data that is valid according to writerSchema is also valid according to readerSchema. If not, a list of compatibility issues is returned.
Determining compatibility (or incompatibility) of arbitrary schemas with certainty is non-trivial, or outright impossible in general. For this reason, this method works in a "best effort" manner, assuming that the schemas match one of the typical schema patterns generated by libraries like
tapir. In more complex situations, the comparator simply falls back to comparing schemas by plain equality, or returns a GeneralSchemaMismatch, which indicates comparator's inability to definitely determine compatibility or incompatibility of the schemas.In practice, the comparator is designed to detect typical changes that may appear in schemas during API evolution, e.g. adding new fields, changing types, etc.
Before being compared, all schemas are stripped of keywords which do not affect the comparison, e.g. annotations like
title,description, etc.- writerSchema
schema of the data being written
- readerSchema
schema of the data being read
- returns
a list of incompatibilities between the schemas
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)