Skip to content
Snippets Groups Projects
Commit e9e0fdd9 authored by michael.minelli's avatar michael.minelli
Browse files

OpenAPI => Add corrige routes documentation

parent 369cce0d
No related branches found
No related tags found
No related merge requests found
Pipeline #32324 failed
...@@ -73,17 +73,7 @@ paths: ...@@ -73,17 +73,7 @@ paths:
- refreshToken - refreshToken
responses: responses:
'200': '200':
description: OK $ref: '#/components/responses/OK'
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/DojoBackendResponse'
- type: object
properties:
data:
type: object
nullable: true
'404': '404':
$ref: '#/components/responses/NOT_FOUND' $ref: '#/components/responses/NOT_FOUND'
default: default:
...@@ -306,17 +296,7 @@ paths: ...@@ -306,17 +296,7 @@ paths:
- $ref: '#/components/parameters/assignmentNameOrUrl' - $ref: '#/components/parameters/assignmentNameOrUrl'
responses: responses:
'200': '200':
description: OK $ref: '#/components/responses/OK'
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/DojoBackendResponse'
- type: object
properties:
data:
type: object
nullable: true
'401': '401':
$ref: '#/components/responses/UNAUTHORIZED' $ref: '#/components/responses/UNAUTHORIZED'
'404': '404':
...@@ -336,17 +316,93 @@ paths: ...@@ -336,17 +316,93 @@ paths:
- $ref: '#/components/parameters/assignmentNameOrUrl' - $ref: '#/components/parameters/assignmentNameOrUrl'
responses: responses:
'200': '200':
description: OK $ref: '#/components/responses/OK'
content: '401':
application/json: $ref: '#/components/responses/UNAUTHORIZED'
schema: '404':
allOf: $ref: '#/components/responses/NOT_FOUND'
- $ref: '#/components/schemas/DojoBackendResponse' default:
- type: object $ref: '#/components/responses/ERROR'
properties: /assignments/{assignmentNameOrUrl}/corrections:
data: post:
type: object tags:
nullable: true - Assignment
summary: Link a exercise to an assignment as a correction
description: |
**🔒 Security needs:** TeachingStaff of the assignment or Admin role
security:
- Clients_Token: [ ]
parameters:
- $ref: '#/components/parameters/assignmentNameOrUrl'
requestBody:
content:
multipart/form-data:
schema:
allOf:
- type: object
properties:
exerciseIdOrUrl:
type: string
format: uuidv4
description: The id of the exercise to link
- $ref: '#/components/schemas/CorrectionsRequestBody'
required:
- exerciseIdOrUrl
responses:
'200':
$ref: '#/components/responses/OK'
'400':
$ref: '#/components/responses/BAD_REQUEST'
'401':
$ref: '#/components/responses/UNAUTHORIZED'
'404':
$ref: '#/components/responses/NOT_FOUND'
default:
$ref: '#/components/responses/ERROR'
/assignments/{assignmentNameOrUrl}/corrections/{exerciseIdOrUrl}:
patch:
tags:
- Assignment
summary: Update the correction link (f.e. commit SHA, description, etc.)
description: |
**🔒 Security needs:** TeachingStaff of the assignment or Admin role
security:
- Clients_Token: [ ]
parameters:
- $ref: '#/components/parameters/assignmentNameOrUrl'
- $ref: '#/components/parameters/exerciseIdOrUrl'
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CorrectionsRequestBody'
responses:
'200':
$ref: '#/components/responses/OK'
'400':
$ref: '#/components/responses/BAD_REQUEST'
'401':
$ref: '#/components/responses/UNAUTHORIZED'
'404':
$ref: '#/components/responses/NOT_FOUND'
default:
$ref: '#/components/responses/ERROR'
delete:
tags:
- Assignment
summary: Unlink a correction from an assignment
description: |
**🔒 Security needs:** TeachingStaff of the assignment or Admin role
security:
- Clients_Token: [ ]
parameters:
- $ref: '#/components/parameters/assignmentNameOrUrl'
- $ref: '#/components/parameters/exerciseIdOrUrl'
responses:
'200':
$ref: '#/components/responses/OK'
'400':
$ref: '#/components/responses/BAD_REQUEST'
'401': '401':
$ref: '#/components/responses/UNAUTHORIZED' $ref: '#/components/responses/UNAUTHORIZED'
'404': '404':
...@@ -415,7 +471,7 @@ paths: ...@@ -415,7 +471,7 @@ paths:
$ref: '#/components/schemas/User' $ref: '#/components/schemas/User'
default: default:
$ref: '#/components/responses/ERROR' $ref: '#/components/responses/ERROR'
/exercises/{exerciseId}/assignment: /exercises/{exerciseIdOrUrl}/assignment:
get: get:
tags: tags:
- Exercise - Exercise
...@@ -424,7 +480,7 @@ paths: ...@@ -424,7 +480,7 @@ paths:
security: security:
- ExerciseChecker_Secret: [ ] - ExerciseChecker_Secret: [ ]
parameters: parameters:
- $ref: '#/components/parameters/exerciseId' - $ref: '#/components/parameters/exerciseIdOrUrl'
responses: responses:
'200': '200':
description: OK description: OK
...@@ -456,7 +512,7 @@ paths: ...@@ -456,7 +512,7 @@ paths:
$ref: '#/components/responses/NOT_FOUND' $ref: '#/components/responses/NOT_FOUND'
default: default:
$ref: '#/components/responses/ERROR' $ref: '#/components/responses/ERROR'
/exercises/{exerciseId}/results: /exercises/{exerciseIdOrUrl}/results:
post: post:
tags: tags:
- Exercise - Exercise
...@@ -464,7 +520,7 @@ paths: ...@@ -464,7 +520,7 @@ paths:
security: security:
- ExerciseChecker_Secret: [ ] - ExerciseChecker_Secret: [ ]
parameters: parameters:
- $ref: '#/components/parameters/exerciseId' - $ref: '#/components/parameters/exerciseIdOrUrl'
requestBody: requestBody:
content: content:
multipart/form-data: multipart/form-data:
...@@ -504,17 +560,7 @@ paths: ...@@ -504,17 +560,7 @@ paths:
- archiveBase64 - archiveBase64
responses: responses:
'200': '200':
description: OK $ref: '#/components/responses/OK'
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/DojoBackendResponse'
- type: object
properties:
data:
type: object
nullable: true
'401': '401':
$ref: '#/components/responses/UNAUTHORIZED' $ref: '#/components/responses/UNAUTHORIZED'
'404': '404':
...@@ -548,8 +594,8 @@ components: ...@@ -548,8 +594,8 @@ components:
required: true required: true
schema: schema:
type: string type: string
exerciseId: exerciseIdOrUrl:
name: exerciseId name: exerciseIdOrUrl
description: The id of an exercise. description: The id of an exercise.
in: path in: path
required: true required: true
...@@ -557,6 +603,19 @@ components: ...@@ -557,6 +603,19 @@ components:
type: string type: string
format: uuidv4 format: uuidv4
schemas: schemas:
CorrectionsRequestBody:
type: object
properties:
description:
type: string
description: Short (max. 80 characters) description of the correction
commit:
type: string
format: Commit SHA
description: Long or short commit id (if not set, take the last commit)
externalDocs:
description: Commit SHA
url: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits
DojoBackendResponse: DojoBackendResponse:
type: object type: object
properties: properties:
...@@ -848,6 +907,30 @@ components: ...@@ -848,6 +907,30 @@ components:
sessionToken: JWT token (for content, see schema named 'SessionTokenJWT') sessionToken: JWT token (for content, see schema named 'SessionTokenJWT')
data: null data: null
responses: responses:
OK:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/DojoBackendResponse'
example:
timestamp: '1992-09-30T19:00:00.000Z'
code: 200
description: OK
sessionToken: JWT token (for content, see schema named 'SessionTokenJWT')
data: null
BAD_REQUEST:
description: BAD_REQUEST
content:
application/json:
schema:
$ref: '#/components/schemas/DojoBackendResponse'
example:
timestamp: '1992-09-30T19:00:00.000Z'
code: 400
description: BAD_REQUEST
sessionToken: JWT token (for content, see schema named 'SessionTokenJWT')
data: null
UNAUTHORIZED: UNAUTHORIZED:
description: UNAUTHORIZED description: UNAUTHORIZED
content: content:
......
...@@ -59,6 +59,17 @@ class AssignmentRoutes implements RoutesManager { ...@@ -59,6 +59,17 @@ class AssignmentRoutes implements RoutesManager {
} }
}; };
private readonly assignmentUpdateCorrigeValidator: ExpressValidator.Schema = {
commit : {
trim : true,
notEmpty: false
},
description: {
trim : true,
notEmpty: false
}
};
registerOnBackend(backend: Express) { registerOnBackend(backend: Express) {
backend.get('/assignments/:assignmentNameOrUrl', SecurityMiddleware.check(true), this.getAssignment.bind(this) as RequestHandler); backend.get('/assignments/:assignmentNameOrUrl', SecurityMiddleware.check(true), this.getAssignment.bind(this) as RequestHandler);
backend.post('/assignments', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), ParamsValidatorMiddleware.validate(this.assignmentValidator), this.createAssignment.bind(this) as RequestHandler); backend.post('/assignments', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), ParamsValidatorMiddleware.validate(this.assignmentValidator), this.createAssignment.bind(this) as RequestHandler);
...@@ -67,7 +78,7 @@ class AssignmentRoutes implements RoutesManager { ...@@ -67,7 +78,7 @@ class AssignmentRoutes implements RoutesManager {
backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(false).bind(this) as RequestHandler); backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.changeAssignmentPublishedStatus(false).bind(this) as RequestHandler);
backend.post('/assignments/:assignmentNameOrUrl/corrections', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), ParamsValidatorMiddleware.validate(this.assignmentAddCorrigeValidator), this.linkUpdateAssignmentCorrection(false).bind(this) as RequestHandler); backend.post('/assignments/:assignmentNameOrUrl/corrections', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), ParamsValidatorMiddleware.validate(this.assignmentAddCorrigeValidator), this.linkUpdateAssignmentCorrection(false).bind(this) as RequestHandler);
backend.patch('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.linkUpdateAssignmentCorrection(true).bind(this) as RequestHandler); backend.patch('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), ParamsValidatorMiddleware.validate(this.assignmentUpdateCorrigeValidator), this.linkUpdateAssignmentCorrection(true).bind(this) as RequestHandler);
backend.delete('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.unlinkAssignmentCorrection.bind(this) as RequestHandler); backend.delete('/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.unlinkAssignmentCorrection.bind(this) as RequestHandler);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment