diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-14 20:32:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-14 20:32:47 +0900 |
| commit | 9185367fcd7d95af89fac36dd892d8b064dbd94f (patch) | |
| tree | 6085f0c4ab695d0f83348f32b49b5481f1da6548 /typespec/fortee | |
| parent | 6bd35e345a4c5d74578b0f8a5c969027e7e15f02 (diff) | |
| download | phperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.tar.gz phperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.tar.zst phperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.zip | |
feat(openapi): generate OpenAPI specs from TypeSpec sources
Migrate hand-written OpenAPI YAML to TypeSpec (.tsp) source files.
TypeSpec compiles to OpenAPI 3.0 YAML, enabling type-safe API definitions.
- Add typespec/ directory with api-server and fortee definitions
- Integrate TypeSpec build into `just gen` and `just build` pipelines
- Update backend handler code to match new generated type names
(inlined error responses, separate GameType/ProblemLanguage enums)
- Regenerate frontend TypeScript types from new OpenAPI output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'typespec/fortee')
| -rw-r--r-- | typespec/fortee/main.tsp | 45 | ||||
| -rw-r--r-- | typespec/fortee/tspconfig.yaml | 8 |
2 files changed, 53 insertions, 0 deletions
diff --git a/typespec/fortee/main.tsp b/typespec/fortee/main.tsp new file mode 100644 index 0000000..03683a7 --- /dev/null +++ b/typespec/fortee/main.tsp @@ -0,0 +1,45 @@ +import "@typespec/http"; +import "@typespec/openapi"; +import "@typespec/openapi3"; + +using TypeSpec.Http; +using TypeSpec.OpenAPI; + +@service(#{ + title: "fortee API", +}) +@info(#{ + version: "0.1.0", +}) +namespace ForteeApi; + +@route("/api/user/login") +@post +@operationId("postLogin") +op postLogin( + @header contentType: "application/x-www-form-urlencoded", + @body body: { + username: string; + password: string; + }, +): { + @body body: { + loggedIn: boolean; + user?: { + username: string; + }; + }; +}; + +@route("/api/user/view/{username}") +@get +@operationId("getUser") +op getUser(@path username: string): { + @body body: { + uuid: string; + username: string; + avatar_url: string; + }; +} | { + @statusCode statusCode: 404; +}; diff --git a/typespec/fortee/tspconfig.yaml b/typespec/fortee/tspconfig.yaml new file mode 100644 index 0000000..78ba744 --- /dev/null +++ b/typespec/fortee/tspconfig.yaml @@ -0,0 +1,8 @@ +output-dir: "{project-root}/tsp-output" +emit: + - "@typespec/openapi3" +options: + "@typespec/openapi3": + openapi-versions: + - "3.0.0" + output-file: openapi.yaml |
