diff --git a/src/models/RivalUser.tsp b/src/models/RivalUser.tsp new file mode 100644 index 0000000..9c37d45 --- /dev/null +++ b/src/models/RivalUser.tsp @@ -0,0 +1,17 @@ +namespace SolvedAC; + +model RivalUser is User { + /** + * 라이벌 여부입니다. + * + * @example false + */ + isRival: boolean; + + /** + * 역라이벌 여부입니다. + * + * @example false + */ + isReverseRival: boolean; +} diff --git a/src/models/UserWithSocial.tsp b/src/models/SocialUser.tsp similarity index 94% rename from src/models/UserWithSocial.tsp rename to src/models/SocialUser.tsp index 85316f4..ebee0c2 100644 --- a/src/models/UserWithSocial.tsp +++ b/src/models/SocialUser.tsp @@ -3,7 +3,7 @@ namespace SolvedAC; /** * solved.ac 사용자 정보입니다. */ -model UserWithSocial is User { +model SocialUser is User { /** * 라이벌 여부입니다. * diff --git a/src/models/User.tsp b/src/models/User.tsp index 984a691..0607518 100644 --- a/src/models/User.tsp +++ b/src/models/User.tsp @@ -207,7 +207,9 @@ model User { proUntil: offsetDateTime; /** - * 사용자의 문제 풀이 레이팅 순위입니다. + * 사용자의 순위입니다. + * 이 값은 요청하는 엔드포인트의 정렬 기준에 따라 다를 수 있습니다. + * 예) /ranking/* 엔드포인트에서는 해당 랭킹의 순위, /show 엔드포인트에서는 문제풀이 레이팅 순위 * * @example 130 */ diff --git a/src/models/_barrel.tsp b/src/models/_barrel.tsp index bdfe463..ce0c553 100644 --- a/src/models/_barrel.tsp +++ b/src/models/_barrel.tsp @@ -15,5 +15,6 @@ import "./ProblemTagAlias.tsp"; import "./ProblemTag.tsp"; import "./PaginatedList.tsp"; import "./User.tsp"; +import "./RivalUser.tsp"; +import "./SocialUser.tsp"; import "./ArenaTier.tsp"; -import "./UserWithSocial.tsp"; diff --git a/src/openapi.yaml b/src/openapi.yaml index b4f4449..86fbecf 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -38,8 +38,6 @@ paths: $ref: "./paths/problem/class.yaml#/paths/Path" /ranking/tier: $ref: "./paths/ranking/tier.yaml#/paths/Path" - /ranking/class: - $ref: "./paths/ranking/class.yaml#/paths/Path" /ranking/streak: $ref: "./paths/ranking/streak.yaml#/paths/Path" /ranking/rival: diff --git a/src/operations/ranking/_barrel.tsp b/src/operations/ranking/_barrel.tsp index cc6e6b2..9ee5b50 100644 --- a/src/operations/ranking/_barrel.tsp +++ b/src/operations/ranking/_barrel.tsp @@ -1 +1,2 @@ import "./contribution.tsp"; +import "./class.tsp"; diff --git a/src/operations/ranking/class.tsp b/src/operations/ranking/class.tsp new file mode 100644 index 0000000..4f55338 --- /dev/null +++ b/src/operations/ranking/class.tsp @@ -0,0 +1,35 @@ +using TypeSpec.Http; +using TypeSpec.OpenAPI; + +namespace SolvedAC; + +/** + * CLASS가 높은 사용자가 먼저 오도록 정렬한 사용자 목록을 가져옵니다. + * + * @return + * 페이지네이션 가능한 사용자 목록을 반환합니다. + */ +@summary("CLASS 순으로 정렬해 사용자 목록 가져오기") +@tag("ranking") +@get +@route("/ranking/class") +op getRankingByClass( + /** + * 응답을 받을 언어입니다. + */ + @header + `x-solvedac-language`?: Language, + + /** + * 페이지 + */ + @query + page?: uint32, +): GetRankingByClass.Ok; + +namespace GetRankingByClass { + @extension(XInternal, true) + model Ok is PaginatedList { + @statusCode status: 200; + } +} diff --git a/src/operations/ranking/contribution.tsp b/src/operations/ranking/contribution.tsp index 0490a35..75373e5 100644 --- a/src/operations/ranking/contribution.tsp +++ b/src/operations/ranking/contribution.tsp @@ -29,7 +29,7 @@ op getRankingByContribution( namespace GetRankingByContribution { @extension(XInternal, true) - model Ok is PaginatedList { + model Ok is PaginatedList { @statusCode status: 200; } } diff --git a/src/operations/user/show.tsp b/src/operations/user/show.tsp index 789a5e5..dabef9b 100644 --- a/src/operations/user/show.tsp +++ b/src/operations/user/show.tsp @@ -32,7 +32,7 @@ op getUserByHandle( namespace GetUserByHandle { @extension(XInternal, true) - model Ok is UserWithSocial { + model Ok is SocialUser { @statusCode status: 200; } } diff --git a/src/paths/ranking/class.yaml b/src/paths/ranking/class.yaml deleted file mode 100644 index 142eaff..0000000 --- a/src/paths/ranking/class.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# yaml-language-server: $schema=https://spec.openapis.org/oas/3.1/schema/2021-05-20 ---- -# for the intellisense -openapi: "3.1.0" -info: { title: "", version: "" } - -paths: - Path: - get: - summary: "CLASS 순위 가져오기" - description: "사용자 CLASS에 따른 순위를 가져옵니다." - tags: - - ranking - operationId: getRankingByClass - - parameters: - - name: "page" - in: "query" - description: "페이지" - schema: - type: "number" - - responses: - "200": - description: "서버가 반환에 성공한 경우입니다." - content: - application/json: - schema: - type: "object" - properties: - count: - description: "순위가 배정된 사용자의 수입니다." - type: "integer" - format: "int64" - example: 40266 - items: - description: "CLASS 순위로 정렬된 사용자 목록입니다." - type: "array" - items: - $ref: "../../schemas/user.yaml#/components/schemas/User"