docs(gateway): updated swagger doc

Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
2025-04-15 00:26:05 +02:00
parent af893618c2
commit 0b57f26688
5 changed files with 495 additions and 5 deletions

View File

@@ -14,7 +14,190 @@ const docTemplate = `{
},
"host": "{{.Host}}",
"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": {
"BasicAuth": {
"type": "basic"

View File

@@ -8,7 +8,190 @@
},
"host": "rest.mse.kb28.ch",
"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": {
"BasicAuth": {
"type": "basic"

View File

@@ -1,11 +1,133 @@
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
info:
contact: {}
description: REST API for the SoftwEng course in MSE
title: Swagger SoftwEng API
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:
BasicAuth:
type: basic