Bläddra i källkod

feat: Add a courses endpoint

Sean Blackburn 1 år sedan
förälder
incheckning
9ec7e55790

+ 8 - 0
src/components/parameters/course.yaml

@@ -0,0 +1,8 @@
+name: course
+in: path
+description: Course PK
+required: true
+schema:
+  type: integer
+  format: u32
+  summary: PK of the course to fetch

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

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

+ 8 - 0
src/components/responses/api/courses/{course}/index-get-200.yaml

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

+ 14 - 0
src/components/schemas/api/course.yaml

@@ -0,0 +1,14 @@
+description: Single course entry
+type: object
+properties:
+  pk:
+    $ref: ../common/pk.yaml
+  school:
+    description: Name of the school
+    type: string
+  name:
+    description: Name of the course
+    type: string
+required:
+  - school
+  - name

+ 6 - 0
src/openapi.yaml

@@ -25,6 +25,12 @@ paths:
   /api/lecturers:
     $ref: ./paths/api/lecturers/index.yaml
 
+  # Courses
+  /api/courses:
+    $ref: ./paths/api/courses/index.yaml
+  /api/courses/{course}:
+    $ref: ./paths/api/courses/{course}/index.yaml
+
   # Modules
   /api/modules:
     $ref: ./paths/api/modules/index.yaml

+ 10 - 0
src/paths/api/courses/index.yaml

@@ -0,0 +1,10 @@
+get:
+  operationId: GetCourses
+  summary: >-
+    A list of all courses
+  security: []
+  tags:
+    - Courses
+  responses:
+    "200":
+      $ref: ../../../components/responses/api/courses/index-get-200.yaml

+ 12 - 0
src/paths/api/courses/{course}/index.yaml

@@ -0,0 +1,12 @@
+get:
+  operationId: GetCourse
+  summary: >-
+    Get a single course
+  security: []
+  parameters:
+    - $ref: ../../../../components/parameters/course.yaml
+  tags:
+    - Courses
+  responses:
+    "200":
+      $ref: ../../../../components/responses/api/courses/{course}/index-get-200.yaml