GfSE / SpecIF-Schema

Definition of the SpecIF JSON-schema and constraint checker
Apache License 2.0
1 stars 0 forks source link

SpecIF - Specification Integration Facility

SpecIF - JSON-schema and constraint checker

Definition of the SpecIF JSON-schema and constraint checker.

This repository is part of the SpecIF-initiative and included as submodule into the main repository https://github.com/GfSE/SpecIF. Take a look here or at https://specif.de for details.

Schema

The SpecIF schema is developed according to JSON-schema using this Github repository. It is hosted by

Sometimes the question is raised why there is a version v1.1 so shortly after v1.0. In fact there is no need for any additional feature. SpecIF v1.0 is particularly well suited to get acquainted with SpecIF concepts, as simple tasks allow a simple representation. If more advanced features such as multi-language support are needed, the SpecIF schema v1.0 would allow a more elaborate structure. While the learning is facilitated, the structural variance makes system implementation including transformations more complicated. Also, some development teams may decide to only implement certain structure variants, resulting in compatibility problems. For that reason the schema v1.1 has eliminated all structural variances. Now the data structure seems to be more complicated, because all features are always accounted for, but the structure is always the same: When a certain element may have several values, it is always a list, even if it has only one member.

Constraints

In addition to the schema, the following constraints apply for SpecIF v1.1:

Checking

A schema and constraint checker is available as JavaScript class using this Github repository. It is hosted by

Usage:

...
// Required: https://github.com/epoberezkin/ajv/releases/tag/4.8.0 or later 
let checker = new CCheck(),
    result;
// 1. Check the schema:
result = checker.checkSchema(<specif-data>, { schema: <specif-schema> });
if (result.status == 0) {
    // 2.  Further check the constraints:
    result = checker.checkConstraints(<specif-data>, { dontCheck: ['statement.subject','subject.object','text.length'] });
    if (result.status == 0) {
        // all is fine, continue processing:
        ...
    }
    else {
        // constraint checking has failed:
        ... process/show result
    };
}
else {
    // schema checking has failed:
    ... process/show result
};
...

The checking routines return an object similar to jqXHR, namely

{status:900,statusText:"<string>",responseType:"text",responseText:"<string>"}.