Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
e9e0fdd9
Commit
e9e0fdd9
authored
11 months ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
OpenAPI => Add corrige routes documentation
parent
369cce0d
No related branches found
No related tags found
No related merge requests found
Pipeline
#32324
failed
11 months ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/assets/OpenAPI/OpenAPI.yaml
+133
-50
133 additions, 50 deletions
ExpressAPI/assets/OpenAPI/OpenAPI.yaml
ExpressAPI/src/routes/AssignmentRoutes.ts
+12
-1
12 additions, 1 deletion
ExpressAPI/src/routes/AssignmentRoutes.ts
with
145 additions
and
51 deletions
ExpressAPI/assets/OpenAPI/OpenAPI.yaml
+
133
−
50
View file @
e9e0fdd9
...
@@ -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/{exerciseId
OrUrl
}/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/exerciseId
OrUrl
'
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/{exerciseId
OrUrl
}/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/exerciseId
OrUrl
'
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
:
exerciseId
OrUrl
:
name
:
exerciseId
name
:
exerciseId
OrUrl
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
:
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/routes/AssignmentRoutes.ts
+
12
−
1
View file @
e9e0fdd9
...
@@ -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
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment