Ver Fonte

feat: Add /me/plan endpoint

Issue #8
Sean Blackburn há 1 ano atrás
pai
commit
e9472f3604

+ 2 - 4
src/components/parameters/me-event.yaml

@@ -1,8 +1,6 @@
 name: event
 in: path
-description: Event
+description: Event PK
 required: true
 schema:
-  type: integer
-  format: u32
-  summary: PK of an event
+  $ref: ../schemas/common/pk.yaml

+ 2 - 4
src/components/parameters/me-favourite.yaml

@@ -1,8 +1,6 @@
 name: favourite
 in: path
-description: Favourite
+description: Favourite PK
 required: true
 schema:
-  type: integer
-  format: u32
-  summary: PK of a favourite
+  $ref: ../schemas/common/pk.yaml

+ 6 - 0
src/components/parameters/me-plan.yaml

@@ -0,0 +1,6 @@
+name: plan
+in: path
+description: Plan PK
+required: true
+schema:
+  $ref: ../schemas/common/pk.yaml

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

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

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

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

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

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

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

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

+ 2 - 2
src/components/schemas/api/personal-event.yaml

@@ -13,13 +13,13 @@ properties:
     type:
       - string
       - "null"
-    default: "null"
+    default: null
   description:
     description: Any additional information / descriptions the user might want to add
     type:
       - string
       - "null"
-    default: "null"
+    default: null
   travel_time_before:
     description: How long we need to travel to get to our private event (in seconds)
     type: integer

+ 24 - 0
src/components/schemas/api/plan.yaml

@@ -0,0 +1,24 @@
+description: A single plan of a student
+type: object
+properties:
+  pk:
+    $ref: ../common/pk.yaml
+  version_pk:
+    $ref: ../relations/term-version.yaml
+  name:
+    description: A memorable name for this plan
+    type: string
+  description:
+    description: An additional description / notes for this plan
+    type:
+      - string
+      - "null"
+    default: null
+  selected_lecture_series:
+    type: array
+    items:
+      $ref: ../relations/lecture-series.yaml
+required:
+  - version_pk
+  - name
+  - selected_lecture_series

+ 3 - 0
src/components/schemas/relations/lecture-series.yaml

@@ -0,0 +1,3 @@
+description: The lecture-series
+type: integer
+format: u32

+ 3 - 0
src/components/schemas/relations/term-version.yaml

@@ -0,0 +1,3 @@
+description: In which term/version this takes place
+type: integer
+format: u32

+ 4 - 2
src/openapi.yaml

@@ -66,5 +66,7 @@ paths:
   /me/favourites/{favourite}:
     $ref: ./paths/api/me/favourites/{favourite}/index.yaml
 
-  # /me/plans:
-  #   $ref: ./paths/api/me/plans.yaml
+  /me/plans:
+    $ref: ./paths/api/me/plans/index.yaml
+  /me/plans/{plan}:
+    $ref: ./paths/api/me/plans/{plan}/index.yaml

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

@@ -1,7 +1,7 @@
 get:
   operationId: GetFavourites
   summary: >-
-    Get a list of favourites. [OPTIONAL]
+    Get a list of personal favourites. [OPTIONAL]
   description: >-
     **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
     requires a server running!
@@ -19,7 +19,7 @@ get:
 post:
   operationId: PostFavourites
   summary: >-
-    Create a new favourite. [OPTIONAL]
+    Create a new personal favourite. [OPTIONAL]
   description: >-
     **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
     requires a server running!

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

@@ -22,7 +22,7 @@ get:
 put:
   operationId: PutFavourite
   summary: >-
-    Update a personal event. [OPTIONAL]
+    Update a personal favourite. [OPTIONAL]
   description: >-
     **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
     requires a server running!
@@ -49,7 +49,7 @@ put:
 delete:
   operationId: DeleteFavourite
   summary: >-
-    Delete a personal event. [OPTIONAL]
+    Delete a personal favourite. [OPTIONAL]
   description: >-
     **THIS IS AN OPTIONAL ENDPOINT**: This endpoint might not be implemented, as it
     requires a server running!

+ 42 - 0
src/paths/api/me/plans/index.yaml

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

+ 68 - 0
src/paths/api/me/plans/{plan}/index.yaml

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