enhanced JSON interface to retrieve definition and raw messages, fixed for JSON strings with quotes

This commit is contained in:
john30
2017-06-05 18:16:13 +02:00
parent 7a569e274a
commit e451e96a90
12 changed files with 420 additions and 186 deletions
+139 -20
View File
@@ -7,6 +7,7 @@ schemes:
- http
produces:
- 'application/json;charset=utf-8'
host: 'l:8080'
paths:
/data:
get:
@@ -34,6 +35,8 @@ paths:
- $ref: '#/parameters/fullQuery'
- $ref: '#/parameters/requiredQuery'
- $ref: '#/parameters/writeQuery'
- $ref: '#/parameters/rawQuery'
- $ref: '#/parameters/defQuery'
- $ref: '#/parameters/userQuery'
- $ref: '#/parameters/secretQuery'
/data/{circuit}:
@@ -64,6 +67,8 @@ paths:
- $ref: '#/parameters/fullQuery'
- $ref: '#/parameters/requiredQuery'
- $ref: '#/parameters/writeQuery'
- $ref: '#/parameters/rawQuery'
- $ref: '#/parameters/defQuery'
- $ref: '#/parameters/userQuery'
- $ref: '#/parameters/secretQuery'
/data/{circuit}/{message}:
@@ -89,6 +94,8 @@ paths:
- $ref: '#/parameters/fullQuery'
- $ref: '#/parameters/requiredQuery'
- $ref: '#/parameters/writeQuery'
- $ref: '#/parameters/rawQuery'
- $ref: '#/parameters/defQuery'
- $ref: '#/parameters/userQuery'
- $ref: '#/parameters/secretQuery'
/{file}:
@@ -115,6 +122,7 @@ paths:
- image/jpeg
- image/svg+xml
- 'application/json;charset=utf-8'
- 'application/yaml;charset=utf-8'
head:
summary: Retrieve headers for a certain file.
responses:
@@ -157,6 +165,12 @@ definitions:
description: the maximum symbol rate on the bus seen since start.
minimum: 0
example: 167
qq:
type: integer
description: the ebusd master address (only if not readonly).
minimum: 0
maximum: 255
example: 49
reconnects:
type: integer
description: the number of reconnects to the device since start.
@@ -186,39 +200,87 @@ definitions:
- lastup
Circuit:
type: object
items:
$ref: '#/definitions/Message'
properties:
name:
type: string
description: the circuit name.
zz:
type: integer
description: the circuit slave address.
minimum: 0
maximum: 255
example: 8
messages:
type: object
additionalProperties:
$ref: '#/definitions/Message'
Message:
type: object
properties:
name:
type: string
description: the message name.
lastup:
type: integer
description: the time in UTC seconds of the last update of the message.
minimum: 0
zz:
type: string
description: destination bus address.
pattern: '[0-9a-f]{2}'
comment:
type: string
description: the message comment (only with verbose).
fields:
type: object
items:
$ref: '#/definitions/Field'
passive:
type: boolean
description: true when this is a passive message.
write:
type: boolean
description: true for a write message, false for a read message.
lastup:
type: integer
description: the time in UTC seconds of the last update of the message (0 for never).
minimum: 0
qq:
type: integer
description: limited source master address (only with def).
minimum: 0
maximum: 255
example: 49
zz:
type: integer
description: destination master or slave address.
minimum: 0
maximum: 255
example: 8
id:
type: array
description: the message ID composed of PBSB and further master data bytes (only with def).
items:
type: integer
minimum: 0
maximum: 255
comment:
type: string
description: the message comment (only with verbose).
master:
type: array
description: the last seen master data bytes (only with raw and if available).
items:
type: integer
minimum: 0
maximum: 255
slave:
type: array
description: the last seen slave data bytes (only with raw and if available).
items:
type: integer
minimum: 0
maximum: 255
fields:
type: object
description: the decoded fields the message is composed of (only if available).
additionalProperties:
$ref: '#/definitions/Field'
fielddefs:
type: array
description: the field definitions the message is composed of (only with def).
items:
$ref: '#/definitions/FieldDef'
required:
- lastup
- name
- passive
- write
- lastup
Field:
type: object
properties:
@@ -233,12 +295,57 @@ definitions:
comment:
type: string
description: the field comment (only with verbose).
FieldDef:
type: object
properties:
name:
type: string
description: the field name.
slave:
type: boolean
description: whether the field is part of the slave data.
type:
type: string
description: the field type.
isbits:
type: boolean
description: true when the length is in bits.
length:
type: number
description: the field length in bytes (-1 for remainder, number of bits when isbits is true).
divisor:
type: number
description: the extra divisor applied to the raw value (only if applicable).
value:
type: string
description: the constant value (only if applicable).
verify:
type: boolean
description: whether the constant value is verified when decoding (only if applicable).
values:
type: object
description: the raw numeric value to name assignments (only if applicable).
additionalProperties:
type: string
description: the value name.
unit:
type: string
description: the field unit.
comment:
type: string
description: the field comment.
required:
- name
- slave
- type
- isbits
- length
Data:
type: object
properties:
global:
$ref: '#/definitions/Global'
items:
additionalProperties:
$ref: '#/definitions/Circuit'
required:
- global
@@ -282,7 +389,7 @@ parameters:
indexedQuery:
name: indexed
in: query
description: return field indexes instead of names.
description: always return field indexes instead of names.
type: boolean
allowEmptyValue: false
numericQuery:
@@ -315,6 +422,18 @@ parameters:
description: retrieve write messages in addition to read/poll messages.
type: boolean
allowEmptyValue: false
rawQuery:
name: raw
in: query
description: include raw master/slave data.
type: boolean
allowEmptyValue: false
defQuery:
name: def
in: query
description: include message and field definition.
type: boolean
allowEmptyValue: false
userQuery:
name: user
in: query