Skip to content

Commit 694a8ae

Browse files
Docs and routes fix
1 parent cce4c47 commit 694a8ae

2 files changed

Lines changed: 117 additions & 2 deletions

File tree

docs/sample.yaml

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,84 @@ paths:
309309
description: Invalid UUID
310310
"500":
311311
description: Internal server error
312+
313+
/question/round:
314+
get:
315+
summary: Get the questions in the user's current round
316+
tags:
317+
- Questions
318+
responses:
319+
"200":
320+
description: Successfully fetched questions and testcases
321+
content:
322+
application/json:
323+
schema:
324+
type: object
325+
properties:
326+
status:
327+
type: string
328+
example: success
329+
round:
330+
type: integer
331+
example: 1
332+
questions_testcases:
333+
type: array
334+
description: Array of question–testcase pairs
335+
items:
336+
type: object
337+
properties:
338+
question:
339+
$ref: "#/components/schemas/Question"
340+
testcases:
341+
type: array
342+
items:
343+
$ref: "#/components/schemas/TestCase"
344+
"400":
345+
description: Invalid round or missing/invalid JWT
346+
content:
347+
application/json:
348+
schema:
349+
type: object
350+
properties:
351+
status:
352+
type: string
353+
example: Failed
354+
message:
355+
type: string
356+
example: round number is invalid
357+
error:
358+
type: string
359+
example: "Error Getting user_id"
360+
"401":
361+
description: Unauthorized — missing or invalid token
362+
content:
363+
application/json:
364+
schema:
365+
type: object
366+
properties:
367+
error:
368+
type: string
369+
example: unauthorized
370+
"500":
371+
description: Internal server error (e.g. DB failure, missing testcases)
372+
content:
373+
application/json:
374+
schema:
375+
type: object
376+
properties:
377+
status:
378+
type: string
379+
example: Failed
380+
message:
381+
type: string
382+
example: unable to fetch the questions
383+
question_id:
384+
type: string
385+
format: uuid
386+
description: Included if fetching testcases for a question fails
387+
error:
388+
type: string
389+
example: "pq: relation \"questions\" does not exist"
312390

313391
components:
314392
schemas:
@@ -389,7 +467,7 @@ components:
389467
description: Round qualified (0 or 1)
390468
example: 1
391469
score:
392-
type: string
470+
type: integer
393471
description: User score (numeric type from Postgres)
394472
example: 100
395473
Question:
@@ -442,7 +520,43 @@ components:
442520
- sampleTestInput
443521
- sampleTestOutput
444522
- explanation
445-
523+
TestCase:
524+
type: object
525+
description: A test case for a question
526+
properties:
527+
id:
528+
type: string
529+
format: uuid
530+
description: Unique identifier for the test case
531+
expected_output:
532+
type: string
533+
description: The expected output for the given input
534+
memory:
535+
type: number
536+
format: double
537+
description: Memory limit for this test case (numeric value)
538+
input:
539+
type: string
540+
description: The input provided to the program
541+
hidden:
542+
type: boolean
543+
description: Whether the test case is hidden from the user
544+
runtime:
545+
type: number
546+
format: double
547+
description: Runtime limit for this test case (decimal value)
548+
question_id:
549+
type: string
550+
format: uuid
551+
description: ID of the question this test case belongs to
552+
required:
553+
- id
554+
- expected_output
555+
- memory
556+
- input
557+
- hidden
558+
- runtime
559+
- question_id
446560
CreateQuestionParams:
447561
type: object
448562
properties:

pkg/router/router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func RegisterRoute(e *echo.Echo) {
2222
e.GET("/question", controllers.GetAllQuestions)
2323
e.GET("/question/:id", controllers.GetQuestion)
2424
e.PUT("/question/:id", controllers.UpdateQuestion)
25+
e.GET("/question/round", controllers.GetQuestionsByRound)
2526
e.DELETE("/question/:id", controllers.DeleteQuestion, middlewares.AdminOnly)
2627
e.POST("/question/:id/bounty/activate", controllers.ActivateBounty, middlewares.AdminOnly)
2728
e.POST("/question/:id/bounty/deactivate", controllers.DeactivateBounty, middlewares.AdminOnly)

0 commit comments

Comments
 (0)