docs(gateway): updated swagger doc
Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
@@ -10,6 +10,8 @@ services:
|
|||||||
image: registry.forge.hefr.ch/team-raclette/project-softweng/gateway:latest
|
image: registry.forge.hefr.ch/team-raclette/project-softweng/gateway:latest
|
||||||
container_name: gateway
|
container_name: gateway
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
environment:
|
environment:
|
||||||
- INFLUXDB_TOKEN=$INFLUXDB_TOKEN
|
- INFLUXDB_TOKEN=$INFLUXDB_TOKEN
|
||||||
- INFLUXDB_ORG=$INFLUXDB_ORG
|
- INFLUXDB_ORG=$INFLUXDB_ORG
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ func (gh *Gateway) createMQTTGateway() error {
|
|||||||
// Get env variables and set default values if not set
|
// Get env variables and set default values if not set
|
||||||
MQTT_URL, ok := os.LookupEnv("MQTT_URL")
|
MQTT_URL, ok := os.LookupEnv("MQTT_URL")
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error("MQTT_URL not set, using default value: tcp://mqtt.mse.kb28.ch:1883")
|
log.Error("MQTT_URL not set, using default value: mqtt://mqtt.mse.kb28.ch:1883")
|
||||||
MQTT_URL = "tcp://mqtt.mse.kb28.ch:1883"
|
MQTT_URL = "mqtt://mqtt.mse.kb28.ch:1883"
|
||||||
}
|
}
|
||||||
|
|
||||||
CLIENT_ID, ok := os.LookupEnv("CLIENT_ID")
|
CLIENT_ID, ok := os.LookupEnv("CLIENT_ID")
|
||||||
|
|||||||
@@ -14,7 +14,190 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
"basePath": "{{.BasePath}}",
|
"basePath": "{{.BasePath}}",
|
||||||
"paths": {},
|
"paths": {
|
||||||
|
"/ping": {
|
||||||
|
"get": {
|
||||||
|
"description": "get ping response",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"ping"
|
||||||
|
],
|
||||||
|
"summary": "Ping test endpoint",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "pong",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/raclette": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BasicAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Request data from InfluxDB for a specific device in a room",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"request"
|
||||||
|
],
|
||||||
|
"summary": "Request Influx data",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Garage",
|
||||||
|
"description": "Room name",
|
||||||
|
"name": "room",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Door",
|
||||||
|
"description": "Device name",
|
||||||
|
"name": "device",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Returns a map of field names to their latest values.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/main.GarageDoorExample"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/gin.H"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BasicAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Publish a command to a specific device in a room",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"commands"
|
||||||
|
],
|
||||||
|
"summary": "Publish command",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Garage",
|
||||||
|
"description": "Room name",
|
||||||
|
"name": "room",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Door",
|
||||||
|
"description": "Device name",
|
||||||
|
"name": "device",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Command to publish",
|
||||||
|
"name": "command",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/main.Command"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "status:ok",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/gin.H"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"gin.H": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {}
|
||||||
|
},
|
||||||
|
"main.Command": {
|
||||||
|
"description": "Command structure for publishing",
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"command"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"command": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "UP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"main.GarageDoorExample": {
|
||||||
|
"description": "Example response for Garage Door status",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"IsClosed": {
|
||||||
|
"description": "example: true",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsDownButtonPressed": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsIRSensor": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsOpen": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsUpButtonPressed": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"securityDefinitions": {
|
"securityDefinitions": {
|
||||||
"BasicAuth": {
|
"BasicAuth": {
|
||||||
"type": "basic"
|
"type": "basic"
|
||||||
|
|||||||
@@ -8,7 +8,190 @@
|
|||||||
},
|
},
|
||||||
"host": "rest.mse.kb28.ch",
|
"host": "rest.mse.kb28.ch",
|
||||||
"basePath": "/",
|
"basePath": "/",
|
||||||
"paths": {},
|
"paths": {
|
||||||
|
"/ping": {
|
||||||
|
"get": {
|
||||||
|
"description": "get ping response",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"ping"
|
||||||
|
],
|
||||||
|
"summary": "Ping test endpoint",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "pong",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/raclette": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BasicAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Request data from InfluxDB for a specific device in a room",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"request"
|
||||||
|
],
|
||||||
|
"summary": "Request Influx data",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Garage",
|
||||||
|
"description": "Room name",
|
||||||
|
"name": "room",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Door",
|
||||||
|
"description": "Device name",
|
||||||
|
"name": "device",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Returns a map of field names to their latest values.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/main.GarageDoorExample"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/gin.H"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BasicAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Publish a command to a specific device in a room",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"commands"
|
||||||
|
],
|
||||||
|
"summary": "Publish command",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Garage",
|
||||||
|
"description": "Room name",
|
||||||
|
"name": "room",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"example": "Door",
|
||||||
|
"description": "Device name",
|
||||||
|
"name": "device",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Command to publish",
|
||||||
|
"name": "command",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/main.Command"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "status:ok",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/gin.H"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"gin.H": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {}
|
||||||
|
},
|
||||||
|
"main.Command": {
|
||||||
|
"description": "Command structure for publishing",
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"command"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"command": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "UP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"main.GarageDoorExample": {
|
||||||
|
"description": "Example response for Garage Door status",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"IsClosed": {
|
||||||
|
"description": "example: true",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsDownButtonPressed": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsIRSensor": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsOpen": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsUpButtonPressed": {
|
||||||
|
"description": "example: false",
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"securityDefinitions": {
|
"securityDefinitions": {
|
||||||
"BasicAuth": {
|
"BasicAuth": {
|
||||||
"type": "basic"
|
"type": "basic"
|
||||||
|
|||||||
@@ -1,11 +1,133 @@
|
|||||||
basePath: /
|
basePath: /
|
||||||
|
definitions:
|
||||||
|
gin.H:
|
||||||
|
additionalProperties: {}
|
||||||
|
type: object
|
||||||
|
main.Command:
|
||||||
|
description: Command structure for publishing
|
||||||
|
properties:
|
||||||
|
command:
|
||||||
|
example: UP
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- command
|
||||||
|
type: object
|
||||||
|
main.GarageDoorExample:
|
||||||
|
description: Example response for Garage Door status
|
||||||
|
properties:
|
||||||
|
IsClosed:
|
||||||
|
description: 'example: true'
|
||||||
|
type: boolean
|
||||||
|
IsDownButtonPressed:
|
||||||
|
description: 'example: false'
|
||||||
|
type: boolean
|
||||||
|
IsIRSensor:
|
||||||
|
description: 'example: false'
|
||||||
|
type: boolean
|
||||||
|
IsOpen:
|
||||||
|
description: 'example: false'
|
||||||
|
type: boolean
|
||||||
|
IsUpButtonPressed:
|
||||||
|
description: 'example: false'
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
host: rest.mse.kb28.ch
|
host: rest.mse.kb28.ch
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
description: REST API for the SoftwEng course in MSE
|
description: REST API for the SoftwEng course in MSE
|
||||||
title: Swagger SoftwEng API
|
title: Swagger SoftwEng API
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
paths: {}
|
paths:
|
||||||
|
/ping:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get ping response
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: pong
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
summary: Ping test endpoint
|
||||||
|
tags:
|
||||||
|
- ping
|
||||||
|
/raclette:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Request data from InfluxDB for a specific device in a room
|
||||||
|
parameters:
|
||||||
|
- description: Room name
|
||||||
|
example: Garage
|
||||||
|
in: query
|
||||||
|
name: room
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- description: Device name
|
||||||
|
example: Door
|
||||||
|
in: query
|
||||||
|
name: device
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Returns a map of field names to their latest values.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/main.GarageDoorExample'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/gin.H'
|
||||||
|
security:
|
||||||
|
- BasicAuth: []
|
||||||
|
summary: Request Influx data
|
||||||
|
tags:
|
||||||
|
- request
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Publish a command to a specific device in a room
|
||||||
|
parameters:
|
||||||
|
- description: Room name
|
||||||
|
example: Garage
|
||||||
|
in: query
|
||||||
|
name: room
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- description: Device name
|
||||||
|
example: Door
|
||||||
|
in: query
|
||||||
|
name: device
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- description: Command to publish
|
||||||
|
in: body
|
||||||
|
name: command
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/main.Command'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: status:ok
|
||||||
|
schema:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/gin.H'
|
||||||
|
security:
|
||||||
|
- BasicAuth: []
|
||||||
|
summary: Publish command
|
||||||
|
tags:
|
||||||
|
- commands
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
BasicAuth:
|
BasicAuth:
|
||||||
type: basic
|
type: basic
|
||||||
|
|||||||
Reference in New Issue
Block a user