Schemas and Schema Builder
This issue is an aggregation point for discussion and questions regarding the schema-builder
prototype to be discussed in today's meeting. This project is available here.
This project, developed in javascript, consists of a builder to support the development of the schemas necessary to validate messages exchanged in the AlpineBits DestinationDate
standard. These schemas, which are contained in the /build/schemas/
folder, can potentially be developed into a javascript module (i.e., a library) to explored as in the example below in the example below:
// schema-builder module (installed locally for this experimentation)
const schemaBuilder = require('schema-builder');
// an example message to be exchanged
const exampleMessage = { ... };
// retrieves the schema for the desired endpoint
const schema = schemaBuilder.schemas['/1.0/events/:id/organizers'];
// result of the validation against the schema of the endpoint and the schema of JSON:API v1.0
const result = schemaBuilder.validateMessage(exampleMessage,schema);
console.log('The result of the validation is:');
if(result) {
console.log(result); // true
}
else {
console.log(result.erros); // an array of objects describe the errors of the validation (either in JSON:API or the specific endpoint schema
}
The schemas available in this project cover each of the endpoints that described by the documentation and that may be supported by servers and also the schema for JSON:API v1.0:
"jsonapi"
"/1.0"
"/1.0/agents"
"/1.0/agents/:id"
"/1.0/agents/:id/multimediaDescriptions"
"/1.0/events"
"/1.0/events/:id"
"/1.0/events/:id/contributors"
"/1.0/events/:id/multimediaDescriptions"
"/1.0/events/:id/organizers"
"/1.0/events/:id/publisher"
"/1.0/events/:id/series"
"/1.0/events/:id/sponsors"
"/1.0/events/:id/subEvents"
"/1.0/events/:id/venues"
"/1.0/eventSeries"
"/1.0/eventSeries/:id"
"/1.0/eventSeries/:id/editions"
"/1.0/eventSeries/:id/multimediaDescriptions"
"/1.0/lifts"
"/1.0/lifts/:id"
"/1.0/lifts/:id/connections"
"/1.0/lifts/:id/multimediaDescriptions"
"/1.0/mediaObjects"
"/1.0/mediaObjects/:id"
"/1.0/mediaObjects/:id/copyrightOwner"
"/1.0/mountainAreas"
"/1.0/mountainAreas/:id"
"/1.0/mountainAreas/:id/areaOwner"
"/1.0/mountainAreas/:id/connections"
"/1.0/mountainAreas/:id/lifts"
"/1.0/mountainAreas/:id/multimediaDescriptions"
"/1.0/mountainAreas/:id/snowparks"
"/1.0/mountainAreas/:id/subAreas"
"/1.0/mountainAreas/:id/trails"
"/1.0/snowparks"
"/1.0/snowparks/:id"
"/1.0/snowparks/:id/connections"
"/1.0/snowparks/:id/multimediaDescriptions"
"/1.0/trails"
"/1.0/trails/:id"
"/1.0/trails/:id/connections"
"/1.0/trails/:id/multimediaDescriptions"
"/1.0/venues"
"/1.0/venues/:id"
"/1.0/venues/:id/multimediaDescriptions"