From 9ac0f8fa9a2874c182259f6f8f815fb6577e83c8 Mon Sep 17 00:00:00 2001 From: localleon Date: Sat, 5 Oct 2019 17:28:24 +0200 Subject: [PATCH 1/4] We only need the yaml file for the OpenAPI Specification --- go/api/openapi.json | 137 -------------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 go/api/openapi.json diff --git a/go/api/openapi.json b/go/api/openapi.json deleted file mode 100644 index 4588e18..0000000 --- a/go/api/openapi.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "Barco SLM Network API", - "version": "1.0.0" - }, - "tags": [ - { - "name": "Write", - "description": "Write related requests" - }, - { - "name": "Command", - "description": "Command related requests" - } - ], - "paths": { - "/api/{cmd}/{data}": { - "get": { - "operationId": "getCmdData", - "summary": "Write data to serial", - "tags": [ - "Command", - "Write" - ], - "parameters": [ - { - "in": "path", - "name": "cmd", - "required": true, - "schema": { - "type": "string", - "maximum": 1 - }, - "description": "The command to run" - }, - { - "in": "path", - "name": "data", - "required": true, - "schema": { - "type": "string", - "maximum": 1 - }, - "description": "The data to provide to the command" - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/api/{cmd}": { - "get": { - "operationId": "getCmd", - "summary": "Run a command", - "tags": [ - "Command" - ], - "parameters": [ - { - "in": "path", - "name": "cmd", - "required": true, - "schema": { - "type": "string", - "maximum": 1 - }, - "description": "The command to run" - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/api/lcdread": { - "get": { - "operationId": "getlcdread", - "summary": "Run the lcdread command", - "tags": [ - "Command" - ], - "responses": { - "200": { - "$ref": "#/components/responses/lcd" - } - } - } - }, - "/": { - "get": { - "operationId": "root", - "summary": "Return the main web interface", - "responses": { - "200": { - "description": "HTML UI" - }, - "default": { - "description": "Web Handling Error" - } - } - } - } - }, - "components": { - "schemas": { - "lcdObj": { - "type": "object", - "properties": { - "first": { - "type": "string" - }, - "second": { - "type": "string" - } - } - } - }, - "responses": { - "lcd": { - "description": "The LCD response object", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/lcdObj" - } - } - } - } - } - } - } \ No newline at end of file From e6760a82b1517c0f734b128b210e20c278949641 Mon Sep 17 00:00:00 2001 From: localleon Date: Sat, 5 Oct 2019 17:43:34 +0200 Subject: [PATCH 2/4] Updated openAPI Specification --- go/api/openapi.yaml | 179 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 162 insertions(+), 17 deletions(-) diff --git a/go/api/openapi.yaml b/go/api/openapi.yaml index f49cf14..3e70051 100644 --- a/go/api/openapi.yaml +++ b/go/api/openapi.yaml @@ -1,56 +1,201 @@ openapi: 3.0.0 info: title: "Barco SLM Network API" - version: "1.0.0" + version: "2.1" tags: - - name: Write - description: Write related requests - name: Command - description: Command related requests + description: Commands that can be sent to the Beamer paths: - /api/{cmd}/{data}: + /api/infrared/{data}: get: - operationId: getCmdData - summary: Write data to serial - tags: [ 'Command', 'Write' ] + operationId: CMDinfrared + summary: Control Infrared Functions with possible Option + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["*", 1,2,3,4,5,6,7,8,9,"arrowdown","arrowup","arrowright","arrowleft","enter","exit","standby"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/lcdbacklight/{data}: + get: + operationId: CMDlcdbacklight + summary: Toggle Backlight of LCD Display + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["off","on"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/shutterclose/{data}: + get: + operationId: CMDshutterclose + summary: Close the Shutter with diffrent Speeds + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["fast","slow"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/shutteropen/{data}: + get: + operationId: CMDshutteropen + summary: Opens the Shutter with diffrent Speeds + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["fast","slow"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/lensfocus/{data}: + get: + operationId: CMDlensfocus + summary: Focus the Lens of the Beamer + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["near","far"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/lensshift/{data}: + get: + operationId: CMDlensshift + summary: Move the projected image by shifting the lens + tags: [ 'Command' ] parameters: - in: path - name: cmd + name: data required: true schema: type: string + enum: ["up","down","left","right"] maximum: 1 - description: The command to run + description: The data to provide to the command + responses: + '200': + description: OK + /api/lenszoom/{data}: + get: + operationId: CMDlenszoom + summary: Zooming the projected picture + tags: [ 'Command' ] + parameters: - in: path name: data required: true schema: type: string + enum: ["in","out"] maximum: 1 description: The data to provide to the command responses: '200': description: OK - /api/{cmd}: + /api/menuexit/{data}: get: - operationId: getCmd - summary: Run a command + operationId: CMDmenuexit + summary: Exit from a LCD Menu Item tags: [ 'Command' ] parameters: - in: path - name: cmd + name: data required: true schema: type: string + enum: ["one","all"] maximum: 1 - description: The command to run + description: The data to provide to the command + responses: + '200': + description: OK + /api/source/{data}: + get: + operationId: CMDsource + summary: Select a Video Source to display + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["1","2","3","4"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/pattern/{data}: + get: + operationId: CMDpattern + summary: Display a default pattern to check lens + tags: [ 'Command' ] + parameters: + - in: path + name: data + required: true + schema: + type: string + enum: ["convergence-g","convergence-rg","convergence-gb","hatch","checkerboard","colorbars","multiburst","outline","chars"] + maximum: 1 + description: The data to provide to the command + responses: + '200': + description: OK + /api/freezeoff: + get: + operationId: CMDfreezeoff + summary: Unfreezes the picture + tags: [ 'Command' ] + responses: + '200': + description: OK + /api/freezen: + get: + operationId: CMDfreezeon + summary: Freezes the picture + tags: [ 'Command' ] responses: '200': description: OK /api/lcdread: get: operationId: getlcdread - summary: Run the lcdread command + summary: This returns the text currently displayed on the LCD tags: [ 'Command' ] responses: '200': @@ -79,4 +224,4 @@ components: content: application/json: schema: - $ref: "#/components/schemas/lcdObj" + $ref: "#/components/schemas/lcdObj" \ No newline at end of file From e24aa353f3de368f9f1f8aba260a9730ad7ac296 Mon Sep 17 00:00:00 2001 From: localleon Date: Sat, 5 Oct 2019 17:48:28 +0200 Subject: [PATCH 3/4] Readme now includes OpenAPI Notice --- README.md | 83 +++++-------------------------------------------------- 1 file changed, 7 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 0f45115..cc634ae 100644 --- a/README.md +++ b/README.md @@ -55,87 +55,18 @@ Default Universe is 1, but can be changed via Flag --universe. - Set Channel 2 to 255 to open the Shutter. ## API -The Projects exposes a simple HTTP API under localhost:80/api/. Just send an HTTP Get to one of the following EndPoints.Caution, there's not authorization on the API. This Project is only intended to run in protected networks +The Projects exposes a simple HTTP API under localhost:80/api/. Just send an HTTP Get to one of the following EndPoints.Caution, there's **no authorization** on the API. This Project is only intended to run in protected networks. +This API is documented with the [OpenAPI v3.0.0 Specification](https://github.com/OAI/OpenAPI-Specification). The Specification file (YAML) can be found under `go/api/openapi.yaml`. To view the file use something like Postman or [Swagger Editor](https://editor.swagger.io/) + +``` Generic Call: -` curl localhost:80/api/ENDPOINT/FUNCTION` +curl localhost:80/api/ENDPOINT/FUNCTION Example Call: -` curl localhost:80/api/shutteropen/fast ` - - -``` -# Shutter Functions -shutterclose / - fast - slow -shutteropen / - fast - slow -# Backlight of LCD -lcdbacklight / - off - on -# Freezing -freezeoff -freezeon -# Focus of the Lens -lensfocus / - near - far -# Shift the Lens in multiple Directions -lensshift / - up - down - left - right -# Zoom of the Lens -lenszoom / - in - out -# Exit Menu on LCD -menuexit / - one - all -# Select Video Source -source / - 1 - 2 - 3 - 4 - -# Multiple Sample Patterns are displayed -pattern / - convergence-g - convergence-rg - convergence-gb - hatch - chars - checkerboard - colorbars - multiburst - outline -# Every Button from the IR Remote -infrared / - 7 - 0 - 1 - 2 - arrowleft - 4 - 8 - arrowdown - 6 - standby - * - 3 - 5 - enter - exit - 9 - arrowup - arrowright +curl localhost:80/api/shutteropen/fast ``` + ## Dependencies Infos about the Dependencies can be found in [go.mod](https://github.com/localleon/barco-slm-network/blob/master/go/go.mod) and [go.sum](https://github.com/localleon/barco-slm-network/blob/master/go/go.sum). From a720a42f475cf963a3843581a90b658f1706c015 Mon Sep 17 00:00:00 2001 From: localleon Date: Sat, 5 Oct 2019 18:34:01 +0200 Subject: [PATCH 4/4] openAPI: Description for response object --- go/api/openapi.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/api/openapi.yaml b/go/api/openapi.yaml index 3e70051..4e5a316 100644 --- a/go/api/openapi.yaml +++ b/go/api/openapi.yaml @@ -216,12 +216,14 @@ components: properties: first: type: string + description: the first line of the 16x2 LCD screen. Should not exceed 16 characters second: type: string + description: the second line of the 16x2 LCD screen. Should not exceed 16 characters responses: lcd: description: The LCD response object content: application/json: schema: - $ref: "#/components/schemas/lcdObj" \ No newline at end of file + $ref: "#/components/schemas/lcdObj"