-
Does Rhino have a Json schema validator library? if not is there a way to install it? Especially with VMware aria orchestrator integration |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello Dominic (@dapiced), in the VMware Aria Orchestrator you have also the possibility to use different runtime environments. Beside JavaScript is PowerShell available. PowerShell contains a cmdlet call Test-Json. With this cmdlet it is very easy to realize a JSON schema validator. Here the PowerShell action: function Handler($context, $inputs) {
$result = Test-Json -Json $inputs.in_jsonContent -Schema $inputs.in_jsonSchema;
$output=@{status = 'done'; result = $result};
return $output
} Now you can call this action from your JavaScript environment. Here I use the Microsoft example from the Test-Json description. Here the JavaScript action: var jsonContent = '{"name": "Ashley", "age": 25}';
var jsonSchema = '{ \
"definitions": {}, \
"$schema": "[http://json-schema.org/draft-07/schema#"](http://json-schema.org/draft-07/schema#%22), \
"$id": "[http://example.com/root.json"](http://example.com/root.json%22), \
"type": "object", \
"title": "The Root Schema", \
"required": [ \
"name", \
"age" \
], \
"properties": { \
"name": { \
"$id": "#/properties/name", \
"type": "string", \
"title": "The Name Schema", \
"default": "", \
"examples": [ \
"Ashley" \
], \
"pattern": "^(.*)$" \
}, \
"age": { \
"$id": "#/properties/age", \
"type": "integer", \
"title": "The Age Schema", \
"default": 0, \
"examples": [ \
25 \
] \
} \
} \
}';
var result = System.getModule("de.stschnell").jsonSchemaValidator(
jsonContent,
jsonSchema
);
return result.result; With this approach it is not necessary to install an additional library. You simply combine the existing possibilities of VMware Aria Automation. Because as far as I know a JSON schema validator is not available. Best regards |
Beta Was this translation helpful? Give feedback.
Hello Dominic (@dapiced),
in the VMware Aria Orchestrator you have also the possibility to use different runtime environments. Beside JavaScript is PowerShell available. PowerShell contains a cmdlet call Test-Json. With this cmdlet it is very easy to realize a JSON schema validator. Here the PowerShell action:
Now you can call this action from your JavaScript environment. Here I use the Microsoft example from the Test-Json description. Here the JavaScript action: