Backend api updates

This commit is contained in:
Jamie Curnow
2018-06-20 16:50:51 +10:00
parent 08fe46311d
commit 8942b99372
10 changed files with 95 additions and 52 deletions

View File

@@ -0,0 +1,7 @@
{
"anyOf": [
{
"$ref": "roles#/definitions/admin"
}
]
}

View File

@@ -0,0 +1,7 @@
{
"anyOf": [
{
"$ref": "roles#/definitions/admin"
}
]
}

View File

@@ -0,0 +1,7 @@
{
"anyOf": [
{
"$ref": "roles#/definitions/admin"
}
]
}

View File

@@ -0,0 +1,23 @@
{
"anyOf": [
{
"$ref": "roles#/definitions/admin"
},
{
"type": "object",
"required": ["data", "scope"],
"properties": {
"data": {
"$ref": "objects#/properties/users"
},
"scope": {
"type": "array",
"contains": {
"type": "string",
"pattern": "^user$"
}
}
}
}
]
}

View File

@@ -0,0 +1,26 @@
{
"anyOf": [
{
"$ref": "roles#/definitions/admin"
},
{
"type": "object",
"required": [
"data",
"scope"
],
"properties": {
"data": {
"$ref": "objects#/properties/users"
},
"scope": {
"type": "array",
"contains": {
"type": "string",
"pattern": "^user$"
}
}
}
}
]
}

View File

@@ -18,8 +18,8 @@ const ajv = require('ajv')({
/**
*
* @param {Object} schema
* @param {Object} payload
* @param {Object} schema
* @param {Object} payload
* @returns {Promise}
*/
function validator (schema, payload) {
@@ -34,8 +34,6 @@ function validator (schema, payload) {
if (valid && !validate.errors) {
resolve(_.cloneDeep(payload));
} else {
//console.log('Validation failed:', schema, payload);
let message = ajv.errorsText(validate.errors);
reject(new error.InternalValidationError(message));
}