Przeglądaj źródła

Create the docs for device creation

Lee Morgan 2 miesięcy temu
rodzic
commit
91eb13934f
2 zmienionych plików z 58 dodań i 2 usunięć
  1. 8 2
      docs/openapi.yaml
  2. 50 0
      docs/paths/device/create.yaml

+ 8 - 2
docs/openapi.yaml

@@ -11,6 +11,7 @@ servers:
 tags:
   - name: User
   - name: Home
+  - name: Devices
 
 components:
   schemas:
@@ -35,7 +36,7 @@ components:
     $ref: "./components/security.yaml"
 
 paths:
-  #User
+  #Users
   /user:
     post:
       $ref: "./paths/user/create.yaml"
@@ -48,7 +49,7 @@ paths:
     post:
       $ref: "./paths/user/logout.yaml"
 
-  #Home
+  #Homes
   /home:
     post:
       $ref: "./paths/home/create.yaml"
@@ -57,3 +58,8 @@ paths:
   /home/{home_id}:
     delete:
       $ref: "./paths/home/delete.yaml"
+
+  #Devices
+  /home/{home_id}/device:
+    post:
+      $ref: "./paths/device/create.yaml"

+ 50 - 0
docs/paths/device/create.yaml

@@ -0,0 +1,50 @@
+operationId: deviceCreate
+summary: Create
+security:
+  - UserAuth: []
+description: Create a new device for a home
+tags: [Device]
+parameters:
+  - name: home_id
+    in: path
+    description: ID of home to add device to
+    required: true
+    schema:
+      type: string
+      format: uuid
+      example: 019e1850-db33-7893-8cc0-61965e39e9bd
+requestBody:
+  content:
+    application/json:
+      schema:
+        type: object
+        required:
+          - name
+          - description
+        properties:
+          name:
+            type: string
+            description: Name of the device exactly matching the device on Zigbee2MQTT
+            example: north_bedroom_light
+          description:
+            type: string
+            description: Short user created description of the device
+            example: North Bedroom Light
+
+responses:
+  "200":
+    description: Device created
+    content:
+      application/json:
+        schema:
+          $ref: "#/components/schemas/Device"
+  "400":
+    $ref: "#/components/responses/400"
+  "401":
+    $ref: "#/components/responses/401"
+  "403":
+    $ref: "#/components/responses/403"
+  "404":
+    $ref: "#/components/responses/404"
+  "500":
+    $ref: "#/components/responses/500"