Skip to content

JSON Schemas

Draft · schema 3.0.0-draft

TRP publishes JSON Schemas (draft 2020-12) at stable, versioned URLs under https://trp.ecoclaim.ca/schemas/v3/. Every resource validates against the shared envelope in common.schema.json plus the schema for its type.

Resource type value Schema
Common definitions and envelope n/a common.schema.json
Claim trp.claim claim.schema.json
MitigationEvent trp.mitigation_event mitigation-event.schema.json
WasteEvent trp.waste_event waste-event.schema.json
MaterialRequirement trp.material_requirement material-requirement.schema.json
OptionAssessment trp.option_assessment option-assessment.schema.json
ClaimReport trp.claim_report claim-report.schema.json

Schemas for the remaining resources in the catalog will follow in later drafts.

Any JSON Schema 2020-12 validator works. Load all schemas so $ref between them resolves, then select the schema by the record’s type. With Ajv:

import Ajv2020 from 'ajv/dist/2020.js';
import addFormats from 'ajv-formats';
const ajv = new Ajv2020({ allErrors: true });
addFormats(ajv);
// add every schema, then:
const validate = ajv.getSchema('https://trp.ecoclaim.ca/schemas/v3/waste-event.schema.json');
if (!validate(record)) console.log(validate.errors);

JSON Schema cannot express every rule. Some checks, such as gross weight below tare weight or a report marked complete while listing missing domains, need code. The reference validator in the repository implements a first set and tests it against the invalid fixtures.

Schema validity is necessary but not sufficient. See Conformance.

Schemas are versioned with semantic versioning. During 3.x draft releases, breaking changes may occur in any release and will be listed in the changelog. Readers SHOULD ignore unknown fields under extensions.