Skip to content

Commit

Permalink
Add additional schemas (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmior authored Sep 24, 2024
1 parent 6ddb9c3 commit d7d38d1
Show file tree
Hide file tree
Showing 17 changed files with 7,037 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ define docker_run
$(eval $@_INPUT = $(2))
$(shell docker run --rm -v $(CURDIR):/workspace jsonschema-benchmark/$($@_TOOL) $($@_INPUT) > $@)
@sed -i 's/$$/,$(.SHELLSTATUS)/' $@
@exit $(.SHELLSTATUS)
endef

# JSON Toolkit
Expand Down
7 changes: 4 additions & 3 deletions implementations/ajv/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ async function validateSchema(schemaPath, instancePath) {
console.log(durationNs.toFixed(0));

// Exit with non-zero status on validation failure
if (failed) {
process.exit(1);
}
// XXX Skip since we allow ajv to fail
// if (failed) {
// process.exit(1);
// }
}

if (process.argv.length !== 4) {
Expand Down
3 changes: 3 additions & 0 deletions implementations/jsontoolkit/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ int validate(const std::filesystem::path &example) {

const auto timestamp_start{std::chrono::high_resolution_clock::now()};

auto num = 0;
for (const auto &instance : instances) {
num += 1;
const auto result{
sourcemeta::jsontoolkit::evaluate(schema_template, instance)};
if (!result) {
std::cerr << "Error validating instance " << num << "\n";
return EXIT_FAILURE;
}
}
Expand Down
483 changes: 483 additions & 0 deletions schemas/aws-cdk/instances.jsonl

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions schemas/aws-cdk/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://json.schemastore.org/cdk.json",
"properties": {
"app": {
"type": "string",
"minLength": 1
},
"build": {
"type": "string"
},
"versionReporting": {
"type": "boolean"
},
"watch": {
"type": "object",
"properties": {
"include": {
"type": "array",
"items": {
"type": "string"
}
},
"exclude": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"context": {
"type": "object"
}
},
"title": "Schema for AWS CDK context files (cdk.json)",
"type": "object"
}
794 changes: 794 additions & 0 deletions schemas/babelrc/instances.jsonl

Large diffs are not rendered by default.

200 changes: 200 additions & 0 deletions schemas/babelrc/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf": [
{
"$ref": "#/definitions/Options"
},
{
"properties": {
"env": {
"description": "This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the environment variable BABEL_ENV is set to \"production\". If BABEL_ENV isn't set then NODE_ENV will be used, if it's not set then it defaults to \"development\"",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Options"
},
"default": {}
}
}
}
],
"definitions": {
"Options": {
"type": "object",
"properties": {
"ast": {
"description": "Include the AST in the returned object",
"type": "boolean",
"default": true
},
"auxiliaryCommentAfter": {
"description": "Attach a comment after all non-user injected code.",
"type": "string"
},
"auxiliaryCommentBefore": {
"description": "Attach a comment before all non-user injected code.",
"type": "string"
},
"code": {
"description": "Enable code generation",
"type": "boolean",
"default": true
},
"comments": {
"description": "Output comments in generated output.",
"type": "boolean",
"default": true
},
"compact": {
"description": "Do not include superfluous whitespace characters and line terminators. When set to \"auto\" compact is set to true on input sizes of >500KB.",
"type": [
"string",
"boolean"
],
"enum": [
"auto",
true,
false
],
"default": "auto"
},
"extends": {
"description": "A path to a .babelrc file to extend",
"type": "string"
},
"filename": {
"description": "Filename for use in errors etc.",
"type": "string",
"default": "unknown"
},
"filenameRelative": {
"description": "Filename relative to sourceRoot (defaults to \"filename\")",
"type": "string"
},
"highlightCode": {
"description": "ANSI highlight syntax error code frames",
"type": "boolean"
},
"ignore": {
"description": "Opposite of the \"only\" option",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"inputSourceMap": {
"description": "If true, attempt to load an input sourcemap from the file itself. If an object is provided, it will be treated as the source map object itself.",
"type": [
"boolean",
"object"
],
"default": true
},
"keepModuleIdExtensions": {
"description": "Keep extensions in module ids",
"type": "boolean",
"default": false
},
"moduleId": {
"description": "Specify a custom name for module ids.",
"type": "string"
},
"moduleIds": {
"description": "If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules)",
"type": "string",
"default": false
},
"moduleRoot": {
"description": "Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. (defaults to \"sourceRoot\")",
"type": "string"
},
"only": {
"description": "A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim.",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"plugins": {
"description": "List of plugins to load and use",
"type": "array",
"items": {
"type": [
"string",
"array"
],
"items": [
{
"description": "The name of the plugin.",
"type": "string"
},
{
"description": "The options of the plugin.",
"type": "object"
}
]
}
},
"presets": {
"description": "List of presets (a set of plugins) to load and use",
"type": "array",
"items": {
"type": [
"string",
"array"
],
"items": [
{
"description": "The name of the preset.",
"type": "string"
},
{
"description": "The options of the preset.",
"type": "object"
}
]
}
},
"retainLines": {
"default": false,
"description": "Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. NOTE: This will obviously not retain the columns.",
"type": "boolean"
},
"sourceFileName": {
"description": "Set sources[0] on returned source map. (defaults to \"filenameRelative\")",
"type": "string"
},
"sourceMaps": {
"default": false,
"description": "If truthy, adds a map property to returned output. If set to \"inline\", a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to \"both\" then a map property is returned as well as a source map comment appended.",
"type": [
"string",
"boolean"
],
"enum": [
"both",
"inline",
true,
false
]
},
"sourceMapTarget": {
"description": "Set file on returned source map. (defaults to \"filenameRelative\")",
"type": "string"
},
"sourceRoot": {
"description": "The root from which all sources are relative. (defaults to \"moduleRoot\")",
"type": "string"
}
}
}
},
"id": "https://json.schemastore.org/babelrc.json",
"title": "JSON schema for Babel 6+ configuration files",
"type": "object"
}
Loading

0 comments on commit d7d38d1

Please sign in to comment.