1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00
Drasko DRASKOVIC 106c8996d4 Add schema
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:55:48 +02:00
..
2016-09-20 21:55:48 +02:00
2016-09-20 21:55:48 +02:00
2016-09-20 21:55:48 +02:00
2016-09-20 21:55:48 +02:00
2016-09-20 21:55:48 +02:00

JSON Modles

Mainflux uses 2 entities in the system to represent devices and their properties:

  • device
  • channel

Device represents device itself - model, type, serial number, location...

Channel represents an observable property of device that we measure - temperature, pressure, light, velocity...

Creating JSON Schema From the Model Templates

We use deviceTemplate.json and channelTemplate.json to describe our entities. Then based on these files we can create more decriptive documents - JSON Schemas.

To do this we can use on-line tool http://jsonschema.net/ or npm package json-schema-generator:

sudo npm install -g json-schema-generator
json-schema-generator ./deviceTemplate.json -o deviceSchema.json

Schemas will be used to perform JSON schema validation during API calls, as described in this article