confluent-kafka-dotnet
Show / Hide Table of Contents

Class Schema

Represents a schema.

Inheritance
object
Schema
RegisteredSchema
Implements
IComparable<Schema>
IEquatable<Schema>
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Confluent.SchemaRegistry
Assembly: Confluent.SchemaRegistry.dll
Syntax
[DataContract]
public class Schema : IComparable<Schema>, IEquatable<Schema>

Constructors

Schema()

Empty constructor for serialization

Declaration
protected Schema()

Schema(string, SchemaType)

Initializes a new instance of this class.

Declaration
public Schema(string schemaString, SchemaType schemaType)
Parameters
Type Name Description
string schemaString

String representation of the schema.

SchemaType schemaType

The schema type: AVRO, PROTOBUF, JSON

Schema(string, List<SchemaReference>, SchemaType)

Initializes a new instance of this class.

Declaration
public Schema(string schemaString, List<SchemaReference> references, SchemaType schemaType)
Parameters
Type Name Description
string schemaString

String representation of the schema.

List<SchemaReference> references

A list of schemas referenced by this schema.

SchemaType schemaType

The schema type: AVRO, PROTOBUF, JSON

Schema(string, List<SchemaReference>, SchemaType, Metadata, RuleSet)

Initializes a new instance of this class.

Declaration
public Schema(string schemaString, List<SchemaReference> references, SchemaType schemaType, Metadata metadata, RuleSet ruleSet)
Parameters
Type Name Description
string schemaString

String representation of the schema.

List<SchemaReference> references

A list of schemas referenced by this schema.

SchemaType schemaType

The schema type: AVRO, PROTOBUF, JSON

Metadata metadata

Metadata for the schema.

RuleSet ruleSet

Rule set for the schema.

Schema(string, int, int, string)

DEPRECATED. Initializes a new instance of the Schema class.

Declaration
[Obsolete("Included to maintain API backwards compatibility only. Use RegisteredSchema instead. This property will be removed in a future version of the library.")]
public Schema(string subject, int version, int id, string schemaString)
Parameters
Type Name Description
string subject

The subject the schema is registered against.

int version

The schema version, >= 0

int id

The globally unique identifier of the schema, >= 0

string schemaString

String representation of the schema.

Properties

Id

Unique identifier of the schema.

Declaration
public virtual int Id { get; set; }
Property Value
Type Description
int

Metadata

Metadata for the schema

Declaration
[DataMember(Name = "metadata")]
public Metadata Metadata { get; set; }
Property Value
Type Description
Metadata

References

A list of schemas referenced by this schema.

Declaration
[DataMember(Name = "references")]
public List<SchemaReference> References { get; set; }
Property Value
Type Description
List<SchemaReference>

RuleSet

RuleSet for the schema

Declaration
[DataMember(Name = "ruleSet")]
public RuleSet RuleSet { get; set; }
Property Value
Type Description
RuleSet

SchemaString

A string representation of the schema.

Declaration
[DataMember(Name = "schema")]
public string SchemaString { get; set; }
Property Value
Type Description
string

SchemaType

The type of schema

Declaration
public SchemaType SchemaType { get; set; }
Property Value
Type Description
SchemaType
Remarks

The .NET serialization framework has no way to convert an enum to a corresponding string value, so this property is backed by a string property, which is what is serialized.

Subject

The subject the schema is registered against.

Declaration
public virtual string Subject { get; set; }
Property Value
Type Description
string

Version

The schema version.

Declaration
public virtual int Version { get; set; }
Property Value
Type Description
int

Methods

CompareTo(Schema)

Compares this instance with another instance of this object type and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified schema reference.

Declaration
public int CompareTo(Schema other)
Parameters
Type Name Description
Schema other

The instance to compare with this instance.

Returns
Type Description
int

A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the other parameter. Less than zero: this instance precedes other. Zero: this instance has the same position in the sort order as other. Greater than zero: This instance follows other OR other is null.

Remarks

This method considers only the Schema property, since the other two properties are effectively derivatives of this property.

Equals(Schema)

Determines whether this instance and another specified object of the same type are the same.

Declaration
public bool Equals(Schema other)
Parameters
Type Name Description
Schema other

The instance to compare to this instance.

Returns
Type Description
bool

true if the value of the other parameter is the same as the value of this instance; otherwise, false. If other is null, the method returns false.

Equals(object)

Determines whether this instance and a specified object, which must also be an instance of this type, have the same value (Overrides Object.Equals(Object))

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The instance to compare to this instance.

Returns
Type Description
bool

true if obj is of the required type and its value is the same as this instance; otherwise, false. If obj is null, the method returns false.

Overrides
object.Equals(object)

GetHashCode()

Returns a hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

An integer that specifies a hash value for this instance.

Overrides
object.GetHashCode()
Remarks

The hash code returned is that of the Schema property, since the other properties are effectively derivatives of this property.

ToString()

Returns a summary string representation of the object.

Declaration
public override string ToString()
Returns
Type Description
string

A string that represents the object.

Overrides
object.ToString()

Operators

implicit operator string(Schema)

implicit cast to string.

Declaration
[Obsolete("Included to maintain API backwards compatibility only. This method will be removed in a future release.")]
public static implicit operator string(Schema s)
Parameters
Type Name Description
Schema s
Returns
Type Description
string

Implements

IComparable<T>
IEquatable<T>
In this article