Schema Linting
After selecting an appropriate example from the specification onboarding doc and modifying it to describe your specific event topic, call the Schema Linting API using the endpoint for version ‘Spec-Validator-1.0’ to ensure your spec conforms to the Event Service rules. These linting rules ensure basic syntax conformance and general consistency across all event topics. This makes it easier for event consumers to understand and integrate with your event, and ensures that the schema can be rendered in the Console UI.
Note that the schema must follow the EventSpec format and be expressed in either YAML or JSON.
You are allowed to create an event for any environment only if the spec passes the linting rules with no errors (warnings are permitted). You can view the Create New Event Topic page for full details around the full publisher workflow.
The API lints for the following rules:
- Version - It is mandatory field and must be of type string with the allowed version “0.1”.
- Schemaformat
- The “schemaformat” field specifies the format of the provided specification (JSON or YAML) and must match the schema format given.
- Allowed Values:
- “application/schema+json;version=draft-07”
- “application/schema+yaml;version=draft-07”
- “application/vnd.apache.avro+json;version=1.9.0”
- “application/vnd.apache.avro+yaml;version=1.9.0”
- Allowed Values:
NOTE
- When “schemaformat” not specified, the default format would be “application/schema+yaml;version=draft-07”
- The “schemaformat” field specifies the format of the provided specification (JSON or YAML) and must match the schema format given.
- Schema Validation
- The “schema” field must be provided and is validated against either Avro or JSON validations described below
- Avro Schema Validation
- Must be a valid Avro schema.
- Each field in the schema must have “type” and “doc” defined.
- Mandatory Fields: [“id,” “source,” “type,” and “specversion”]
- Requirements for Mandatory Field in the Schema:
- Mandatory Fields: [“id,” “source,” “type,” and “specversion”] must have “type” as “string” and “required” must be true.
- For “specversion”, If “default” is provided, it must be one of the allowed values: [1.0]
- JSON Schema Validation
- Must be a valid JSON schema.
- Schema properties must be mandatory
- “type” and “description” are mandatory for all properties defined in the schema.
- Mandatory Properties: [“id,” “source,” “type,” and “specversion”]
- “required” field is mandatory and must contain all the above mandatory properties.
- Requirements for Mandatory properties in the Schema:
- Mandatory Fields: [“id,” “source,” “type,” and “specversion”] must have “type” as “string”.
- For “specversion”, If “enum” is provided, it must be one of the allowed values: [1.0]
- Avro Schema Validation
- The “schema” field must be provided and is validated against either Avro or JSON validations described below
- Example Validation
- At least two examples must be provided for each of the described data schemas.
- Requirements for Provided Examples:
- Each example must contain “type,” “description,” and “payload.”
- Example “payload” must adhere to the provided schema.