Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/validation/ValidationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class ValidationError extends Error {
}

let message = "Configuration ";
if (error.dataPath) {
message += chalk.underline(chalk.red(error.dataPath.substr(1))) + " ";
if (error.instancePath) {
message += chalk.underline(chalk.red(error.instancePath.substr(1))) + " ";
}

switch (error.keyword) {
Expand All @@ -99,7 +99,7 @@ class ValidationError extends Error {

static _findDuplicateError(error, errorIndex, errors) {
const foundIndex = errors.findIndex(($) => {
if ($.dataPath !== error.dataPath) {
if ($.instancePath !== error.instancePath) {
return false;
} else if ($.keyword !== error.keyword) {
return false;
Expand All @@ -123,13 +123,13 @@ class ValidationError extends Error {
}

static analyzeYamlError({error, yaml}) {
if (error.dataPath === "" && error.keyword === "required") {
if (error.instancePath === "" && error.keyword === "required") {
// There is no line/column for a missing required property on root level
return {line: -1, column: -1};
}

// Skip leading /
const objectPath = error.dataPath.substr(1).split("/");
const objectPath = error.instancePath.substr(1).split("/");

if (error.keyword === "additionalProperties") {
objectPath.push(error.params.additionalProperty);
Expand Down
9 changes: 8 additions & 1 deletion lib/validation/schema/specVersion/2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion"],
"properties": {
"specVersion": { "enum": ["2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "$ref": "#/definitions/specVersions-2.x" },
"kind": {
"enum": ["project", "extension", null],
"$comment": "Using null to allow not defining 'kind' which defaults to project"
Expand Down Expand Up @@ -33,5 +33,12 @@
"then": {
"$ref": "2.0/kind/extension.json"
}
},
"definitions": {
"specVersions-2.x": { "enum": ["2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"customConfiguration": {
"type": "object",
"additionalProperties": true
}
}
}
2 changes: 1 addition & 1 deletion lib/validation/schema/specVersion/2.0/kind/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion", "kind", "type", "metadata"],
"properties": {
"specVersion": { "enum": ["2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "$ref": "../../2.0.json#/definitions/specVersions-2.x" },
"kind": {
"enum": ["extension"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"$ref": "#/definitions/shims"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"$ref": "#/definitions/middleware"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"$ref": "#/definitions/task"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
4 changes: 1 addition & 3 deletions lib/validation/schema/specVersion/2.0/kind/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "object",
"required": ["specVersion", "type"],
"properties": {
"specVersion": { "enum": ["2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] },
"specVersion": { "$ref": "../../2.0.json#/definitions/specVersions-2.x" },
"kind": {
"enum": ["project", null],
"$comment": "Using null to allow not defining 'kind' which defaults to project"
Expand Down Expand Up @@ -113,7 +113,6 @@
},
"builder-bundles": {
"type": "array",
"additionalProperties": false,
"items": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -184,7 +183,6 @@
},
"builder-bundles-2.4": {
"type": "array",
"additionalProperties": false,
"items": {
"type": "object",
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -72,8 +71,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -109,8 +107,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -146,8 +143,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
12 changes: 4 additions & 8 deletions lib/validation/schema/specVersion/2.0/kind/project/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -72,8 +71,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -109,8 +107,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -146,8 +143,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand All @@ -60,8 +59,7 @@
"$ref": "#/definitions/resources"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down Expand Up @@ -72,8 +71,7 @@
"$ref": "../project.json#/definitions/server"
},
"customConfiguration": {
"type": "object",
"additionalProperties": true
"$ref": "../../../2.0.json#/definitions/customConfiguration"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/schema/ui5.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

"if": {
"properties": {
"specVersion": { "enum": ["2.5", "2.4", "2.3", "2.2", "2.1", "2.0"] }
"specVersion": { "$ref": "specVersion/2.0.json#/definitions/specVersions-2.x" }
}
},
"then": {
Expand Down
6 changes: 4 additions & 2 deletions lib/validation/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class Validator {
const Ajv = require("ajv");
this.ajv = new Ajv({
allErrors: true,
jsonPointers: true,
loadSchema
loadSchema,
code: {
optimize: false
}
});
const ajvErrors = require("ajv-errors");
ajvErrors(this.ajv);
Expand Down
64 changes: 50 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading