WLANThermo-nano / WLANThermo_ESP82XX_Software

GNU General Public License v3.0
32 stars 13 forks source link

Use swagger to design/create the api #111

Open galadril opened 4 years ago

galadril commented 4 years ago

Maybe it would be nice to define the api in a swagger file.

For example, i've quickly created a swagger file for the /data and /settings:


swagger: "2.0"
info:
  description: "This swagger document describes the WLANThermo api"
  version: "1.0.0"
  title: "WLANThermo"
  termsOfService: "http://swagger.io/terms/"
  contact:
    email: "admin@wlanthermo.de"
  license:
    name: "GPL-3.0"
    url: "https://github.com/WLANThermo-nano/WLANThermo_nano_Software/blob/master/LICENSE.md"
host: "192.168.1.58"
basePath: "/"

tags:
- name: "data"
  externalDocs:
    description: "Find out more"
    url: "https://github.com/WLANThermo-nano/WLANThermo_nano_Software/wiki/HTTP#data"
- name: "settings"
  externalDocs:
    description: "Find out more"
    url: "https://github.com/WLANThermo-nano/WLANThermo_nano_Software/wiki/HTTP#get--settings--"

schemes:
- "http"

paths:
  /data:
    get:
      tags:
      - "data"
      summary: "Get data from system, channel and pitmaster."
      operationId: "getData"
      produces:
      - "application/json"
      responses:
        200:
          description: OK
          examples:
            application/json: {"system":{"time":"1508849803","soc":43,"charge":false,"rssi":-62,"unit":"C"}, "channel":[{"number":1,"name":"Kanal 1","typ":8,"temp":19.90,"min":10.00,"max":25.00,"alarm":false,"color":"#0C4C88"},{"number":2,"name":"Kanal 2","typ":0,"temp":999.00,"min":10.00,"max":35.00,"alarm":false,"color":"#22B14C"}], "pitmaster":[{"id":0,"channel":1,"pid":0,"value":0,"set":20.80,"typ":"off"}]}

  /settings:
    get:
      tags:
      - "settings"
      summary: "Get settings values."
      operationId: "getSettings"
      produces:
      - "application/json"
      responses:
        200:
          description: OK
          examples:
            application/json: {"system":{"time":"1509047635","ap":"NANO-AP","host":"NANO-84ce37","language":"de","unit":"C","hwalarm":false,"fastmode":false,"version":"v0.8.8","getupdate":"v0.8.9","autoupd":true,"hwversion":"V1"},"sensors":["Maverick","Fantast-Neu","Fantast","iGrill2","ET-73","Perfektion","5K3A1B","MOUSER47K","100K6A1B","Weber_6743","Santos"],"pid":[{"name":"SSR SousVide","id":0,"aktor":0,"Kp":165.00,"Ki":0.59,"Kd":1000.00,"Kp_a":100.00,"Ki_a":0.08,"Kd_a":5.00,"DCmmin":0,"DCmmax":100},{"name":"TITAN 50x50","id":1,"aktor":1,"Kp":3.80,"Ki":0.01,"Kd":128.00,"Kp_a":6.20,"Ki_a":0.00,"Kd_a":5.00,"DCmmin":25,"DCmmax":100},{"name":"Kamado 50x50","id":2,"aktor":1,"Kp":7.00,"Ki":0.02,"Kd":630.00,"Kp_a":6.20,"Ki_a":0.00,"Kd_a":5.00,"DCmmin":25,"DCmmax":100}],"aktor":["SSR","FAN","SERVO"],"iot":{"TSwrite":"","TShttp":"","TSuser":"","TSchID":"","TSshow8":false,"TSint":30,"TSon":false,"PMQhost":"192.168.2.1","PMQport":1883,"PMQuser":"","PMQpass":"","PMQqos":0,"PMQon":false,"PMQint":30,"TGon":1,"TGtoken":"","TGid":"","CLon":true,"CLtoken":"84ce370d7a2118d8","CLint":30},"hardware":["V1"],"notification":["telegram","pushover"]}

If you open this in a swagger viewer:

afbeelding

You could try the api from this portal:

afbeelding

Phantomias2006 commented 4 years ago

Hi,

thank you for the information. I didn't know Swagger yet. I'll take a closer look at it. Please use the files from the following repo https://github.com/WLANThermo-nano/WLANThermo_ESP32_Software/tree/develop/webui for your implementation

This is the software version of the current hardware. Best regards

galadril commented 4 years ago

Tx, I'll check it

Op ma 3 aug. 2020 22:35 schreef Phantomias2006 notifications@github.com:

Hi,

thank you for the information. I didn't know Swagger yet. I'll take a closer look at it. Please use the files from the following repo https://github.com/WLANThermo-nano/WLANThermo_ESP32_Software/tree/develop/webui for your implementation

This is the software version of the current hardware. Best regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WLANThermo-nano/WLANThermo_nano_Software/issues/111#issuecomment-668228830, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADPDC2HTRDAUSXBNIFUDMRLR64NSTANCNFSM4PTITBLQ .