Skip to content

Commit 49fb345

Browse files
authored
Fix swagger paths (#991)
* Fix SourcecastController Swagger paths * Fix AssessmentsController Swagger paths * Fix NotificationsController Swagger paths Removes the v2 prefix that is already in the base URL. * Fix StoriesController Swagger paths Removes the v2 prefix that is already in the base URL. * Fix AdminUserController Swagger paths * Removes the v2 prefix that is already in the base URL * Fix incorrect names and paths * Fix AdminAchievementsController Swagger paths * Fix AdminStoriesController Swagger paths * Fix CoursesController Swagger paths * Removes the v2 prefix that is already in the base URL * Fix incorrect names and paths * Fix IncentivesController Swagger paths * Group incentives-related routes together * Fix AdminAssessmentsController Swagger paths Also added a FIXME for a missing corresponding Swagger path entry for a route. * Fix AdminAssetsController Swagger paths * Fix AdminCoursesController Swagger paths Also added FIXMEs for missing entries. * Fix AdminGradingController Swagger paths * Fix credo error Renamed FIXMEs to TODOs. * Update tests
1 parent e603ff3 commit 49fb345

16 files changed

+49
-52
lines changed

lib/cadet_web/admin_controllers/admin_achievements_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule CadetWeb.AdminAchievementsController do
6161
end
6262

6363
swagger_path :update do
64-
put("/admin/achievements/{uuid}")
64+
put("/courses/{course_id}/admin/achievements/{uuid}")
6565

6666
summary("Inserts or updates an achievement")
6767

@@ -87,7 +87,7 @@ defmodule CadetWeb.AdminAchievementsController do
8787
end
8888

8989
swagger_path :bulk_update do
90-
put("/admin/achievements")
90+
put("/courses/{course_id}/admin/achievements")
9191

9292
summary("Inserts or updates achievements")
9393

@@ -108,7 +108,7 @@ defmodule CadetWeb.AdminAchievementsController do
108108
end
109109

110110
swagger_path :delete do
111-
PhoenixSwagger.Path.delete("/admin/achievements/{uuid}")
111+
PhoenixSwagger.Path.delete("/courses/{course_id}/admin/achievements/{uuid}")
112112

113113
summary("Deletes an achievement")
114114
security([%{JWT: []}])

lib/cadet_web/admin_controllers/admin_assessments_controller.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ defmodule CadetWeb.AdminAssessmentsController do
127127
end
128128

129129
swagger_path :index do
130-
get("/admin/users/{courseRegId}/assessments")
130+
get("/courses/{course_id}/admin/users/{courseRegId}/assessments")
131131

132132
summary("Fetches assessment overviews of a user")
133133

@@ -143,7 +143,7 @@ defmodule CadetWeb.AdminAssessmentsController do
143143
end
144144

145145
swagger_path :create do
146-
post("/admin/assessments")
146+
post("/courses/{course_id}/admin/assessments")
147147

148148
summary("Creates a new assessment or updates an existing assessment")
149149

@@ -162,7 +162,7 @@ defmodule CadetWeb.AdminAssessmentsController do
162162
end
163163

164164
swagger_path :delete do
165-
PhoenixSwagger.Path.delete("/admin/assessments/{assessmentId}")
165+
PhoenixSwagger.Path.delete("/courses/{course_id}/admin/assessments/{assessmentId}")
166166

167167
summary("Deletes an assessment")
168168

@@ -177,7 +177,7 @@ defmodule CadetWeb.AdminAssessmentsController do
177177
end
178178

179179
swagger_path :update do
180-
post("/admin/assessments/{assessmentId}")
180+
post("/courses/{course_id}/admin/assessments/{assessmentId}")
181181

182182
summary("Updates an assessment")
183183

lib/cadet_web/admin_controllers/admin_assets_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule CadetWeb.AdminAssetsController do
7171
end
7272

7373
swagger_path :index do
74-
get("/admin/assets/{folderName}")
74+
get("/courses/{course_id}/admin/assets/{folderName}")
7575

7676
summary("Get a list of all assets in a folder")
7777

@@ -89,7 +89,7 @@ defmodule CadetWeb.AdminAssetsController do
8989
end
9090

9191
swagger_path :delete do
92-
PhoenixSwagger.Path.delete("/admin/assets/{folderName}/{fileName}")
92+
PhoenixSwagger.Path.delete("/courses/{course_id}/admin/assets/{folderName}/{fileName}")
9393

9494
summary("Delete a file from an asset folder")
9595

@@ -108,7 +108,7 @@ defmodule CadetWeb.AdminAssetsController do
108108
end
109109

110110
swagger_path :upload do
111-
post("/admin/assets/{folderName}/{fileName}")
111+
post("/courses/{course_id}/admin/assets/{folderName}/{fileName}")
112112

113113
summary("Upload a file to an asset folder")
114114

lib/cadet_web/admin_controllers/admin_courses_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ defmodule CadetWeb.AdminCoursesController do
9191
end
9292

9393
swagger_path :update_course_config do
94-
put("/v2/courses/{course_id}/admin/config")
94+
put("/courses/{course_id}/admin/config")
9595

9696
summary("Updates the course configuration for the specified course")
9797

@@ -117,7 +117,7 @@ defmodule CadetWeb.AdminCoursesController do
117117
end
118118

119119
swagger_path :update_assessment_configs do
120-
put("/v2/courses/{course_id}/admin/config/assessment_configs")
120+
put("/courses/{course_id}/admin/config/assessment_configs")
121121

122122
summary("Updates the assessment configuration for the specified course")
123123

lib/cadet_web/admin_controllers/admin_grading_controller.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ defmodule CadetWeb.AdminGradingController do
118118
end
119119

120120
swagger_path :index do
121-
get("/admin/grading")
121+
get("/courses/{course_id}/admin/grading")
122122

123123
summary("Get a list of all submissions with current user as the grader")
124124

@@ -141,7 +141,7 @@ defmodule CadetWeb.AdminGradingController do
141141
end
142142

143143
swagger_path :unsubmit do
144-
post("/admin/grading/{submissionId}/unsubmit")
144+
post("/courses/{course_id}/admin/grading/{submissionId}/unsubmit")
145145
summary("Unsubmit submission. Can only be done by the Avenger of a student")
146146
security([%{JWT: []}])
147147

@@ -156,7 +156,7 @@ defmodule CadetWeb.AdminGradingController do
156156
end
157157

158158
swagger_path :autograde_submission do
159-
post("/admin/grading/{submissionId}/autograde")
159+
post("/courses/{course_id}/admin/grading/{submissionId}/autograde")
160160
summary("Force re-autograding of an entire submission")
161161
security([%{JWT: []}])
162162

@@ -171,7 +171,7 @@ defmodule CadetWeb.AdminGradingController do
171171
end
172172

173173
swagger_path :autograde_answer do
174-
post("/admin/grading/{submissionId}/{questionId}/autograde")
174+
post("/courses/{course_id}/admin/grading/{submissionId}/{questionId}/autograde")
175175
summary("Force re-autograding of a question in a submission")
176176
security([%{JWT: []}])
177177

@@ -187,7 +187,7 @@ defmodule CadetWeb.AdminGradingController do
187187
end
188188

189189
swagger_path :show do
190-
get("/admin/grading/{submissionId}")
190+
get("/courses/{course_id}/admin/grading/{submissionId}")
191191

192192
summary("Get information about a specific submission to be graded")
193193

@@ -206,7 +206,7 @@ defmodule CadetWeb.AdminGradingController do
206206
end
207207

208208
swagger_path :update do
209-
post("/admin/grading/{submissionId}/{questionId}")
209+
post("/courses/{course_id}/admin/grading/{submissionId}/{questionId}")
210210

211211
summary("Update marks given to the answer of a particular question in a submission")
212212

@@ -228,7 +228,7 @@ defmodule CadetWeb.AdminGradingController do
228228
end
229229

230230
swagger_path :grading_summary do
231-
get("/admin/grading/summary")
231+
get("/courses/{course_id}/admin/grading/summary")
232232

233233
summary("Receives a summary of grading items done by this grader")
234234

lib/cadet_web/admin_controllers/admin_stories_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ defmodule CadetWeb.AdminStoriesController do
5353
end
5454

5555
swagger_path :create do
56-
post("/v2{course_id}/stories")
56+
post("/courses/{course_id}/admin/stories")
5757

5858
summary("Creates a new story")
5959

@@ -65,7 +65,7 @@ defmodule CadetWeb.AdminStoriesController do
6565
end
6666

6767
swagger_path :delete do
68-
PhoenixSwagger.Path.delete("/v2/courses/{course_id}/stories/{storyId}")
68+
PhoenixSwagger.Path.delete("/courses/{course_id}/admin/stories/{storyId}")
6969

7070
summary("Delete a story from database by id")
7171

@@ -81,7 +81,7 @@ defmodule CadetWeb.AdminStoriesController do
8181
end
8282

8383
swagger_path :update do
84-
post("/v2/courses/{course_id}/stories/{storyId}")
84+
post("/courses/{course_id}/admin/stories/{storyId}")
8585

8686
summary("Update details regarding a story")
8787

lib/cadet_web/admin_controllers/admin_user_controller.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ defmodule CadetWeb.AdminUserController do
179179
end
180180

181181
swagger_path :index do
182-
get("/v2/courses/{course_id}/admin/users")
182+
get("/courses/{course_id}/admin/users")
183183

184184
summary("Returns a list of users in the course owned by the admin")
185185

@@ -190,7 +190,7 @@ defmodule CadetWeb.AdminUserController do
190190
end
191191

192192
swagger_path :combined_total_xp do
193-
get("/v2/courses/{course_id}/admin/users/{course_reg_id}/total_xp")
193+
get("/courses/{course_id}/admin/users/{course_reg_id}/total_xp")
194194

195195
summary("Get the specified user's total XP from achievements and assessments")
196196

@@ -206,8 +206,8 @@ defmodule CadetWeb.AdminUserController do
206206
response(401, "Unauthorised")
207207
end
208208

209-
swagger_path :add_users do
210-
put("/v2/courses/{course_id}/admin/users")
209+
swagger_path :upsert_users_and_groups do
210+
put("/courses/{course_id}/admin/users")
211211

212212
summary("Adds the list of usernames and roles to the course")
213213
security([%{JWT: []}])
@@ -228,7 +228,7 @@ defmodule CadetWeb.AdminUserController do
228228
end
229229

230230
swagger_path :update_role do
231-
put("/v2/courses/{course_id}/admin/users/role")
231+
put("/courses/{course_id}/admin/users/{course_reg_id}/role")
232232

233233
summary("Updates the role of the given user in the the course")
234234
security([%{JWT: []}])
@@ -257,7 +257,7 @@ defmodule CadetWeb.AdminUserController do
257257
end
258258

259259
swagger_path :delete_user do
260-
delete("/v2/courses/{course_id}/admin/users")
260+
delete("/courses/{course_id}/admin/users/{course_reg_id}")
261261

262262
summary("Deletes a user from a course")
263263
consumes("application/json")

lib/cadet_web/controllers/assessments_controller.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ defmodule CadetWeb.AssessmentsController do
6464
end
6565

6666
swagger_path :submit do
67-
post("/assessments/{assessmentId}/submit")
67+
post("/courses/{course_id}/assessments/{assessmentId}/submit")
6868
summary("Finalise submission for an assessment")
6969
security([%{JWT: []}])
7070

@@ -84,7 +84,7 @@ defmodule CadetWeb.AssessmentsController do
8484
end
8585

8686
swagger_path :index do
87-
get("/assessments")
87+
get("/courses/{course_id}/assessments")
8888

8989
summary("Get a list of all assessments")
9090

@@ -97,7 +97,7 @@ defmodule CadetWeb.AssessmentsController do
9797
end
9898

9999
swagger_path :show do
100-
get("/assessments/{assessmentId}")
100+
get("/courses/{course_id}/assessments/{assessmentId}")
101101

102102
summary("Get information about one particular assessment")
103103

@@ -116,7 +116,7 @@ defmodule CadetWeb.AssessmentsController do
116116
end
117117

118118
swagger_path :unlock do
119-
post("/assessments/{assessmentId}/unlock")
119+
post("/courses/{course_id}/assessments/{assessmentId}/unlock")
120120

121121
summary("Unlocks a password-protected assessment and returns its information")
122122

lib/cadet_web/controllers/courses_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule CadetWeb.CoursesController do
4141
end
4242

4343
swagger_path :create do
44-
post("/v2/config/create")
44+
post("/config/create")
4545

4646
summary("Creates a new course")
4747

@@ -65,8 +65,8 @@ defmodule CadetWeb.CoursesController do
6565
end
6666
end
6767

68-
swagger_path :get_course_config do
69-
get("/v2/courses/{course_id}/config")
68+
swagger_path :index do
69+
get("/courses/{course_id}/config")
7070

7171
summary("Retrieves the course configuration of the specified course")
7272

lib/cadet_web/controllers/incentives_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule CadetWeb.IncentivesController do
3939
end
4040

4141
swagger_path :index_achievements do
42-
get("/achievements")
42+
get("/courses/{course_id}/achievements")
4343

4444
summary("Gets achievements")
4545
security([%{JWT: []}])
@@ -49,7 +49,7 @@ defmodule CadetWeb.IncentivesController do
4949
end
5050

5151
swagger_path :index_goals do
52-
get("/self/goals")
52+
get("/courses/{course_id}/self/goals")
5353

5454
summary("Gets goals, including user's progress")
5555
security([%{JWT: []}])
@@ -59,7 +59,7 @@ defmodule CadetWeb.IncentivesController do
5959
end
6060

6161
swagger_path :update_progress do
62-
post("/self/goals/{uuid}/progress")
62+
post("/courses/{course_id}/self/goals/{uuid}/progress")
6363

6464
summary("Inserts or updates own goal progress of specifed goal")
6565
security([%{JWT: []}])

0 commit comments

Comments
 (0)