From 28d39ae450276d14612374ab2f39817e52ac2984 Mon Sep 17 00:00:00 2001 From: RanolP Date: Sat, 9 Mar 2024 02:06:42 +0900 Subject: [PATCH] feat: migrate /problem/level --- src/openapi.yaml | 2 - src/operations/problem/_barrel.tsp | 1 + src/operations/problem/level.tsp | 74 ++++++++++++++++++++++++++++++ src/paths/problem/level.yaml | 33 ------------- 4 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 src/operations/problem/level.tsp delete mode 100644 src/paths/problem/level.yaml diff --git a/src/openapi.yaml b/src/openapi.yaml index 1c57653..e7d8cfa 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -36,8 +36,6 @@ paths: description: "TODO" /problem/class: $ref: "./paths/problem/class.yaml#/paths/Path" - /problem/level: - $ref: "./paths/problem/level.yaml#/paths/Path" /ranking/tier: $ref: "./paths/ranking/tier.yaml#/paths/Path" /ranking/class: diff --git a/src/operations/problem/_barrel.tsp b/src/operations/problem/_barrel.tsp index 2076702..8bbb76e 100644 --- a/src/operations/problem/_barrel.tsp +++ b/src/operations/problem/_barrel.tsp @@ -1,2 +1,3 @@ import "./show.tsp"; import "./lookup.tsp"; +import "./level.tsp"; diff --git a/src/operations/problem/level.tsp b/src/operations/problem/level.tsp new file mode 100644 index 0000000..aa51ed5 --- /dev/null +++ b/src/operations/problem/level.tsp @@ -0,0 +1,74 @@ +using TypeSpec.Http; +using TypeSpec.OpenAPI; + +namespace SolvedAC; + +/** + * 난이도별 문제 수를 가져옵니다. + * + * @return + * 난이도별 문제 수 + */ +@summary("난이도별 문제 수 가져오기") +@tag("problem") +@get +@route("/problem/level") +op getProblemsCountGroupByLevel( + /** + * 응답을 받을 언어입니다. + */ + @header + `x-solvedac-language`?: Language, +): GetProblemsCountGroupByLevel.Ok; + +namespace GetProblemsCountGroupByLevel { + /** + * @example + * [ + * { "level": 0, "count": 7159 }, + * { "level": 1, "count": 154 }, + * { "level": 2, "count": 271 }, + * { "level": 3, "count": 696 }, + * { "level": 4, "count": 893 }, + * { "level": 5, "count": 782 }, + * { "level": 6, "count": 771 }, + * { "level": 7, "count": 828 }, + * { "level": 8, "count": 914 }, + * { "level": 9, "count": 959 }, + * { "level": 10, "count": 1021 }, + * { "level": 11, "count": 973 }, + * { "level": 12, "count": 1386 }, + * { "level": 13, "count": 1291 }, + * { "level": 14, "count": 1126 }, + * { "level": 15, "count": 1023 }, + * { "level": 16, "count": 1178 }, + * { "level": 17, "count": 1121 }, + * { "level": 18, "count": 1165 }, + * { "level": 19, "count": 1126 }, + * { "level": 20, "count": 891 }, + * { "level": 21, "count": 904 }, + * { "level": 22, "count": 850 }, + * { "level": 23, "count": 602 }, + * { "level": 24, "count": 440 }, + * { "level": 25, "count": 352 }, + * { "level": 26, "count": 281 }, + * { "level": 27, "count": 149 }, + * { "level": 28, "count": 93 }, + * { "level": 29, "count": 32 }, + * { "level": 30, "count": 28 } + * ] + */ + @extension(XInternal, true) + model Ok { + @statusCode status: 200; + items: LevelEntry[]; + } + model LevelEntry { + level: ProblemLevel; + + /** + * 문제 수입니다. + */ + count: uint64; + } +} diff --git a/src/paths/problem/level.yaml b/src/paths/problem/level.yaml deleted file mode 100644 index e672f59..0000000 --- a/src/paths/problem/level.yaml +++ /dev/null @@ -1,33 +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: "수준별 문제 수 가져오기" - description: "문제 개수를 문제 수준별로 가져옵니다." - tags: - - problem - operationId: getProblemLevel - - responses: - "200": - description: "서버가 반환에 성공한 경우입니다." - content: - application/json: - schema: - type: "array" - items: - type: "object" - properties: - level: - $ref: "../../schemas/problem-level.yaml#/components/schemas/ProblemLevel" - count: - type: "integer" - format: "int64" - minimum: 0 - description: "이 문제 수준인 문제 수입니다." - example: 10