Quellcode durchsuchen

feat: Implement favourites, clean up

Issue #10
Sean Blackburn vor 1 Jahr
Ursprung
Commit
ee3efb80fa

+ 8 - 0
src/components/parameters/me-event.yaml

@@ -0,0 +1,8 @@
+name: event
+in: path
+description: Event
+required: true
+schema:
+  type: integer
+  format: u32
+  summary: PK of an event

+ 8 - 0
src/components/parameters/me-favourite.yaml

@@ -0,0 +1,8 @@
+name: favourite
+in: path
+description: Favourite
+required: true
+schema:
+  type: integer
+  format: u32
+  summary: PK of a favourite

+ 1 - 0
src/components/responses/204.yaml

@@ -0,0 +1 @@
+description: OK

+ 10 - 0
src/components/responses/api/me/favourites/index-get-200.yaml

@@ -0,0 +1,10 @@
+description: OK
+content:
+  application/json:
+    schema:
+      type: array
+      items:
+        $ref: ../../../../schemas/api/favourite.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../examples/api/me/favourites/index.yaml

+ 10 - 0
src/components/responses/api/me/favourites/index-post-200.yaml

@@ -0,0 +1,10 @@
+description: OK
+content:
+  application/json:
+    schema:
+      type: array
+      items:
+        $ref: ../../../../schemas/api/favourite.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../examples/api/me/favourites/index.yaml

+ 8 - 0
src/components/responses/api/me/favourites/{favourite}/index-get-200.yaml

@@ -0,0 +1,8 @@
+description: OK
+content:
+  application/json:
+    schema:
+      $ref: ../../../../../schemas/api/favourite.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../../examples/api/me/favourites/index.yaml

+ 8 - 0
src/components/responses/api/me/favourites/{favourite}/index-put-200.yaml

@@ -0,0 +1,8 @@
+description: OK
+content:
+  application/json:
+    schema:
+      $ref: ../../../../../schemas/api/favourite.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../../examples/api/me/favourites/index.yaml

+ 0 - 10
src/components/responses/api/me/personal-events-get-200.yaml

@@ -1,10 +0,0 @@
-description: OK
-content:
-  application/json:
-    schema:
-      type: array
-      items:
-        $ref: ../../../schemas/api/personal-event.yaml
-    # TODO
-    # example:
-    #   $ref: ../../../examples/api/me/personal-events.yaml

+ 10 - 0
src/components/responses/api/me/personal-events/index-get-200.yaml

@@ -0,0 +1,10 @@
+description: OK
+content:
+  application/json:
+    schema:
+      type: array
+      items:
+        $ref: ../../../../schemas/api/personal-event.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../examples/api/me/personal-events.yaml

+ 8 - 0
src/components/responses/api/me/personal-events/index-post-200.yaml

@@ -0,0 +1,8 @@
+description: OK
+content:
+  application/json:
+    schema:
+      $ref: ../../../../schemas/api/personal-event.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../examples/api/me/personal-events.yaml

+ 8 - 0
src/components/responses/api/me/personal-events/{event}/index-get-200.yaml

@@ -0,0 +1,8 @@
+description: OK
+content:
+  application/json:
+    schema:
+      $ref: ../../../../../schemas/api/personal-event.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../../examples/api/me/personal-events.yaml

+ 8 - 0
src/components/responses/api/me/personal-events/{event}/index-put-200.yaml

@@ -0,0 +1,8 @@
+description: OK
+content:
+  application/json:
+    schema:
+      $ref: ../../../../../schemas/api/personal-event.yaml
+    # TODO
+    # example:
+    #   $ref: ../../../../../examples/api/me/personal-events.yaml

+ 9 - 0
src/components/schemas/api/favourite.yaml

@@ -0,0 +1,9 @@
+description: A single user favourite module
+type: object
+properties:
+  pk:
+    $ref: ../common/pk.yaml
+  module_pk:
+    $ref: ../relations/module.yaml
+required:
+  - module_pk

+ 1 - 0
src/components/schemas/api/me-enrolment.yaml

@@ -36,6 +36,7 @@ properties:
     format: u64
   end_date:
     description: When this enrolment ended (UNIX timestamp in seconds)
+    type: integer
     format: u64
 required:
   - status

+ 14 - 8
src/components/schemas/api/personal-event.yaml

@@ -1,6 +1,8 @@
 type: object
 description: A personal event entry for a single user
 properties:
+  pk:
+    $ref: ../common/pk.yaml
   term_pk:
     $ref: ../relations/term.yaml
   title:
@@ -8,18 +10,26 @@ properties:
     type: string
   location:
     description: The location of the private event
-    type: string
+    type:
+      - string
+      - "null"
+    default: "null"
   description:
     description: Any additional information / descriptions the user might want to add
-    type: string
+    type:
+      - string
+      - "null"
+    default: "null"
   travel_time_before:
     description: How long we need to travel to get to our private event (in seconds)
     type: integer
     format: u16
+    default: 0
   travel_time_after:
     description: How long we need to travel to get to back from our private event (in seconds)
     type: integer
     format: u16
+    default: 0
   start_time:
     description: When the actual event starts (Unix timestamp in seconds)
     type: integer
@@ -32,9 +42,11 @@ properties:
     description: Repeat this event every n <repeat_unit>
     type: integer
     format: u8
+    default: 0
   repeat_unit:
     description: The unit of how often to repeat this event
     type: string
+    default: once
     oneOf:
       - id: once
         const: once
@@ -47,11 +59,5 @@ properties:
 required:
   - term_pk
   - title
-  - location
-  - description
-  - travel_time_before
-  - travel_time_after
   - start_time
   - end_time
-  - repeat_every
-  - repeat_unit

+ 3 - 0
src/components/schemas/common/pk.yaml

@@ -0,0 +1,3 @@
+type: integer
+format: u32
+description: Primary key

+ 10 - 3
src/openapi.yaml

@@ -49,9 +49,16 @@ paths:
   # Me
   /me:
     $ref: ./paths/api/me/index.yaml
+
   /me/personal-events:
-    $ref: ./paths/api/me/personal-events.yaml
-  # /me/favourites:
-  #   $ref: ./paths/api/me/favourites.yaml
+    $ref: ./paths/api/me/personal-events/index.yaml
+  /me/personal-events/{event}:
+    $ref: ./paths/api/me/personal-events/{event}/index.yaml
+
+  /me/favourites:
+    $ref: ./paths/api/me/favourites/index.yaml
+  /me/favourites/{favourite}:
+    $ref: ./paths/api/me/favourites/{favourite}/index.yaml
+
   # /me/plans:
   #   $ref: ./paths/api/me/plans.yaml

+ 40 - 0
src/paths/api/me/favourites/index.yaml

@@ -0,0 +1,40 @@
+get:
+  operationId: GetFavourites
+  summary: >-
+    Get a list of favourites. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  tags:
+    - Me/Favourites
+  responses:
+    "200":
+      $ref: ../../../../components/responses/api/me/favourites/index-get-200.yaml
+    "401":
+      $ref: ../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../components/responses/404.yaml
+post:
+  operationId: PostFavourites
+  summary: >-
+    Create a new favourite. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  tags:
+    - Me/Favourites
+  requestBody:
+    required: true
+    content:
+      application/json:
+        schema:
+          $ref: "../../../../components/schemas/api/favourite.yaml"
+  responses:
+    "200":
+      $ref: ../../../../components/responses/api/me/favourites/index-post-200.yaml
+    "401":
+      $ref: ../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../components/responses/404.yaml

+ 65 - 0
src/paths/api/me/favourites/{favourite}/index.yaml

@@ -0,0 +1,65 @@
+get:
+  operationId: GetFavourite
+  summary: >-
+    Get a single personal favourite. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-favourite.yaml
+  tags:
+    - Me/Favourites
+  responses:
+    "200":
+      $ref: ../../../../../components/responses/api/me/favourites/{favourite}/index-get-200.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml
+
+put:
+  operationId: PutFavourite
+  summary: >-
+    Update a personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-favourite.yaml
+  tags:
+    - Me/Favourites
+  requestBody:
+    required: true
+    content:
+      application/json:
+        schema:
+          $ref: "../../../../../components/schemas/api/favourite.yaml"
+  responses:
+    "200":
+      $ref: ../../../../../components/responses/api/me/favourites/{favourite}/index-put-200.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml
+
+delete:
+  operationId: DeleteFavourite
+  summary: >-
+    Delete a personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-favourite.yaml
+  tags:
+    - Me/Favourites
+  responses:
+    "204":
+      $ref: ../../../../../components/responses/204.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml

+ 2 - 3
src/paths/api/me/index.yaml

@@ -1,14 +1,13 @@
 get:
   operationId: GetMe
   summary: >-
-    Get information about myself.
-
+    Get information about myself. [OPTIONAL]
+  description: >-
     **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
     requires a server running!
   security: []
   tags:
     - Me
-    - Optional
   responses:
     "200":
       $ref: ../../../components/responses/api/me/index-get-200.yaml

+ 0 - 18
src/paths/api/me/personal-events.yaml

@@ -1,18 +0,0 @@
-get:
-  operationId: GetPersonalEvents
-  summary: >-
-    Get a list of personal events.
-
-    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
-    requires a server running!
-  security: []
-  tags:
-    - Me
-    - Optional
-  responses:
-    "200":
-      $ref: ../../../components/responses/api/me/personal-events-get-200.yaml
-    "401":
-      $ref: ../../../components/responses/401.yaml
-    "404":
-      $ref: ../../../components/responses/404.yaml

+ 40 - 0
src/paths/api/me/personal-events/index.yaml

@@ -0,0 +1,40 @@
+get:
+  operationId: GetPersonalEvents
+  summary: >-
+    Get a list of personal events. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  tags:
+    - Me/Personal Event
+  responses:
+    "200":
+      $ref: ../../../../components/responses/api/me/personal-events/index-get-200.yaml
+    "401":
+      $ref: ../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../components/responses/404.yaml
+post:
+  operationId: PostPersonalEvents
+  summary: >-
+    Create a new personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  tags:
+    - Me/Personal Event
+  requestBody:
+    required: true
+    content:
+      application/json:
+        schema:
+          $ref: "../../../../components/schemas/api/personal-event.yaml"
+  responses:
+    "200":
+      $ref: ../../../../components/responses/api/me/personal-events/index-post-200.yaml
+    "401":
+      $ref: ../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../components/responses/404.yaml

+ 65 - 0
src/paths/api/me/personal-events/{event}/index.yaml

@@ -0,0 +1,65 @@
+get:
+  operationId: GetPersonalEvent
+  summary: >-
+    Get a single personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-event.yaml
+  tags:
+    - Me/Personal Event
+  responses:
+    "200":
+      $ref: ../../../../../components/responses/api/me/personal-events/{event}/index-get-200.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml
+
+put:
+  operationId: PutPersonalEvent
+  summary: >-
+    Update a personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-event.yaml
+  tags:
+    - Me/Personal Event
+  requestBody:
+    required: true
+    content:
+      application/json:
+        schema:
+          $ref: "../../../../../components/schemas/api/personal-event.yaml"
+  responses:
+    "200":
+      $ref: ../../../../../components/responses/api/me/personal-events/{event}/index-put-200.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml
+
+delete:
+  operationId: DeletePersonalEvent
+  summary: >-
+    Delete a personal event. [OPTIONAL]
+  description: >-
+    **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
+    requires a server running!
+  security: []
+  parameters:
+    - $ref: ../../../../../components/parameters/me-event.yaml
+  tags:
+    - Me/Personal Event
+  responses:
+    "204":
+      $ref: ../../../../../components/responses/204.yaml
+    "401":
+      $ref: ../../../../../components/responses/401.yaml
+    "404":
+      $ref: ../../../../../components/responses/404.yaml