Skip to content

Commit 289b6a5

Browse files
committed
Proof-read doc
1 parent 96fb347 commit 289b6a5

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

README.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Here is an example of full Node-RED flow: [Node-RED_example_of_flow.json](exampl
3030
* *Purpose*: Ability to determine the URL of the JSON Schema (e.g. FIWARE NGSI) or JSONata expression to use for a given JSON payload received.
3131
* *Configuration*: A Node-RED `mappingsUrl` property to indicate the URL of a file listing which JSON Schema or JSONata expression to use for which data input. (See examples below).
3232
* *Input*: A JSON observation (e.g. one of the FIWARE NGSI types) in the `msg.payload` property.
33-
* *Output*: The unmodified JSON observation in the `msg.payload` property, and the resolved schema URL in the `msg.schemaUrl` property (if any match was found).
33+
* *Output*: The unmodified JSON observation in the `msg.payload` property, and the resolved schema URL in the `msg.schemaUrl` property (if any match was found), and potential resolution errors in the `msg.error` property.
3434

3535
### Example of input data
3636
This is an example of [standard payload](https://fiware-datamodels.readthedocs.io/en/latest/Transportation/Vehicle/Vehicle/doc/spec/index.html), for which we need to look-up the [corresponding JSON Schema](https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/VehicleModel/schema.json).
@@ -73,6 +73,7 @@ In the example, this JSON file is hosted at [`examples/smart-data-models.json`](
7373
"cases": {
7474
"AeroAllergenObserved": "https://smart-data-models.github.io/data-models/specs/Environment/AeroAllergenObserved/schema.json",
7575
...
76+
"NoiseLevelObserved": "https://smart-data-models.github.io/data-models/specs/Environment/NoiseLevelObserved/schema.json",
7677
"Vehicle": "https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json",
7778
"WasteContainer": "https://smart-data-models.github.io/data-models/specs/WasteManagement/WasteContainer/schema.json",
7879
}
@@ -114,6 +115,7 @@ In the example, this JSON file is hosted at [`examples/smart-data-transforms.jso
114115

115116
### Example of schema resolution from command line
116117
The JSON input messages must each be on one single line, and wrapped into a Node-RED structure `{"payload":...}`
118+
See the `jq` examples at the bottom on how to automatise the wrapping.
117119

118120
```sh
119121
echo '{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"}}' | \
@@ -174,30 +176,32 @@ It is typically used with a *json-multi-schema-resolver* node in front.
174176

175177
### Example of input data
176178

177-
This is an example of proprietary format, which we would like to be transformed into another format (a standard NGSI one).
179+
This is an example of proprietary format, which we would like to transform into another format (a standard NGSI one).
178180

179181
We represent the example as a full Node-RED message, i.e. wrapped into a `{"payload":...}` structure.
180182

181183
```json
182184
{
183-
"id": "TA120-T246177",
184-
"type": "Cesva-TA120",
185-
"NoiseLevelObserved": {
186-
"id": "TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z",
187-
"sonometerClass": "1",
188-
"location": {
189-
"coordinates": [
190-
24.985891,
191-
60.274286
185+
"payload": {
186+
"id": "TA120-T246177",
187+
"type": "Cesva-TA120",
188+
"NoiseLevelObserved": {
189+
"id": "TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z",
190+
"sonometerClass": "1",
191+
"location": {
192+
"coordinates": [
193+
24.985891,
194+
60.274286
195+
],
196+
"type": "Point"
197+
},
198+
"measurand": [
199+
"LAeq | 48.6 | A-weighted, equivalent, sound level"
192200
],
193-
"type": "Point"
194-
},
195-
"measurand": [
196-
"LAeq | 48.6 | A-weighted, equivalent, sound level"
197-
],
198-
"dateObserved": "2018-09-17T07:01:09.000000Z",
199-
"LAeq": 48.6,
200-
"type": "NoiseLevelObserved"
201+
"dateObserved": "2018-09-17T07:01:09.000000Z",
202+
"LAeq": 48.6,
203+
"type": "NoiseLevelObserved"
204+
}
201205
}
202206
}
203207
```
@@ -269,7 +273,7 @@ Output:
269273
It is typically used with a *json-multi-schema-resolver* node in front.
270274

271275
### Example of input data
272-
This is an example of [standard payload](https://fiware-datamodels.readthedocs.io/en/latest/Transportation/Vehicle/Vehicle/doc/spec/index.html), which we want to validate against its [corresponding JSON Schema](https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/VehicleModel/schema.json), which address is provided by the Node-RED property `msg.schemaUrl`.
276+
This is an example of [standard payload](https://fiware-datamodels.readthedocs.io/en/latest/Environment/NoiseLevelObserved/doc/spec/index.html#noise-level-observed), which we want to validate against its [corresponding JSON Schema](https://smart-data-models.github.io/data-models/specs/Environment/NoiseLevelObserved/schema.json), which address is provided by the Node-RED property `msg.schemaUrl`.
273277

274278
```json
275279
{
@@ -369,17 +373,6 @@ node ./index.js json-multi-schema-validator | \
369373
jq -c .
370374
```
371375

372-
 
373-
374-
---
375-
376-
 
377-
378-
## Caching
379-
380-
A disk copy of the downloaded JSON and JSONata documents is kept in cache on disk.
381-
By default, the cache path is `/tmp/` but that can be changed with the environment variable `SCHEMAS_CACHE_PATH`
382-
Cached files have a `*.tmp.js` suffix.
383376

384377

385378

@@ -447,8 +440,16 @@ Here is an example of full Node-RED flow: [Node-RED_example_of_HTTP_flow.json](e
447440

448441
Read more on the [Node-RED cookbook](https://cookbook.nodered.org/http/serve-json-content).
449442

450-
### Caching of schemas
443+
 
451444

452-
Once downloaded, a copy of the schemas is saved on local disk (by default in `/tmp/`).
445+
---
446+
447+
 
448+
449+
## Caching of schemas
450+
451+
A disk copy of the downloaded JSON and JSONata documents is kept in cache on disk.
452+
By default, the cache path is `/tmp/` but that can be changed with the environment variable `SCHEMAS_CACHE_PATH`
453+
Cached files have a `*.tmp.js` suffix.
453454

454455
If schemas are updated without changing their URL, it is possible to either purge the local cache manually, or add a version number at the end of their URL, such as `https://example.net/a-schema.json?v2`

0 commit comments

Comments
 (0)