-
Notifications
You must be signed in to change notification settings - Fork 4
/
json-multi-schema-resolver.html
61 lines (58 loc) · 2.16 KB
/
json-multi-schema-resolver.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script type="text/javascript">
/* global RED:false */
RED.nodes.registerType('json-multi-schema-resolver', {
category: 'function',
color: '#00B4FF',
defaults: {
name: { value: '' },
mappingsUrl: { value: '' },
},
inputs: 1,
outputs: 1,
icon: 'function.png',
label: function () {
return this.name || 'json-multi-schema-resolver';
},
});
</script>
<script type="text/x-red" data-template-name="json-multi-schema-resolver">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-input-mappingsUrl"><i class="icon-tag"></i> Mappings URL</label>
<input type="text" id="node-input-mappingsUrl" placeholder="mappingsUrl"
placeholder="https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/main/examples/smart-data-models.json" />
</div>
</script>
<script type="text/x-red" data-help-name="json-multi-schema-resolver">
<p>Node to determine the JSON Schema corresponding to a given message, based on a configurable list of schemas.</p>
<ul>
<li>The node will try to determine the URL of the JSON Schema to use for a given JSON payload received in <code>msg.payload</code></li>
<li>To do so, the node uses the configuration file which URL is given as a <code>mappingsUrl</code> property.</li>
<li>The URL of the corresponding JSON Schema is returned in <code>msg.schemaUrl</code>.</li>
<li>The original JSON data is kept unaltered in <code>msg.payload</code></li>
<li>Errors are returned on <code>msg.error</code></li>
</ul>
<p>Example of configuration file containing the mappings of schemas: </p>
<pre>
[
{
"query": "type",
"cases": {
"AeroAllergenObserved": "https://smart-data-models.github.io/data-models/specs/Environment/AeroAllergenObserved/schema.json",
...
"Vehicle": "https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json",
"WasteContainer": "https://smart-data-models.github.io/data-models/specs/WasteManagement/WasteContainer/schema.json",
}
},
{
"query": "...",
"cases": {
...
}
}
]
</pre>
</script>