Fixed up the API and added API doc
This commit is contained in:
parent
253208b6f9
commit
0efa7320e3
12 changed files with 313 additions and 58 deletions
25
hal-core/resource/resource/web/api/docs.html
Normal file
25
hal-core/resource/resource/web/api/docs.html
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hal OpenAPI Documentation</title>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4.15.3/swagger-ui.css">
|
||||
<script src="https://unpkg.com/swagger-ui-dist@4.15.3/swagger-ui-bundle.js"></script>
|
||||
|
||||
<script>
|
||||
function render() {
|
||||
var ui = SwaggerUIBundle({
|
||||
url: '/api/openapi.json',
|
||||
dom_id: '#swagger-ui',
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="render()">
|
||||
<div id="swagger-ui"></div>
|
||||
</body>
|
||||
</html>
|
||||
189
hal-core/resource/resource/web/api/openapi.json
Normal file
189
hal-core/resource/resource/web/api/openapi.json
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
{
|
||||
"components": {
|
||||
"schemas": {
|
||||
"sensorClass": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/dataClass"
|
||||
},
|
||||
"name": {"type": "string"},
|
||||
"id": {"type": "integer"},
|
||||
"map_x": {"type": "number"},
|
||||
"map_y": {"type": "number"},
|
||||
"user": {"type": "string"},
|
||||
"config": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/configClass"
|
||||
},
|
||||
"aggregate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"timestamps": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventClass": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/dataClass"
|
||||
},
|
||||
"name": {"type": "string"},
|
||||
"id": {"type": "integer"},
|
||||
"map_x": {"type": "number"},
|
||||
"map_y": {"type": "number"},
|
||||
"user": {"type": "string"},
|
||||
"config": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/configClass"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"configClass": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"typeConfig": {"type": "string"},
|
||||
"typeData": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"dataClass": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"valueStr": {"type": "string"},
|
||||
"value": {"type": "number"},
|
||||
"timestamp": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"description": "Hal Server",
|
||||
"url": "/api"
|
||||
}
|
||||
],
|
||||
"openapi": "3.0.1",
|
||||
"paths": {
|
||||
"/event": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/eventClass"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "id",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "typeConfig",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "typeData",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/sensor": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/components/schemas/sensorClass"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "id",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "typeConfig",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"in": "query",
|
||||
"name": "typeData",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"min",
|
||||
"hour",
|
||||
"day",
|
||||
"week",
|
||||
]
|
||||
},
|
||||
"in": "query",
|
||||
"name": "aggregation",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"description": "This API allows developers and external tools to interface to Hal data and trigger different actions.",
|
||||
"title": "Hal REST API",
|
||||
"version": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -93,8 +93,8 @@
|
|||
|
||||
<script>
|
||||
$(function(){
|
||||
createChart("#min-chart", "/api/sensor?aggr=minute&id={{sensor.getId()}}", 5*60*1000);
|
||||
createChart("#hour-chart", "/api/sensor?aggr=hour&id={{sensor.getId()}}", 60*60*1000);
|
||||
createChart("#week-chart", "/api/sensor?aggr=week&id={{sensor.getId()}}", 7*24*60*60*1000);
|
||||
createChart("#min-chart", "/api/sensor?aggregation=minute&id={{sensor.getId()}}", 5*60*1000);
|
||||
createChart("#hour-chart", "/api/sensor?aggregation=hour&id={{sensor.getId()}}", 60*60*1000);
|
||||
createChart("#week-chart", "/api/sensor?aggregation=week&id={{sensor.getId()}}", 7*24*60*60*1000);
|
||||
});
|
||||
</script>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<title>HAL is initializing...</title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/hal.css" rel="stylesheet">
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="/css/hal.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue