This commit is contained in:
2025-12-03 10:30:08 +09:00
commit 58ab7caff3
12 changed files with 1214 additions and 0 deletions

9
api/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
# MacOS
.DS_Store
# Default TypeSpec output
tsp-output/
dist/
# Dependency directories
node_modules/

44
api/main.tsp Normal file
View File

@@ -0,0 +1,44 @@
import "@typespec/http";
using Http;
@service(#{ title: "Widget Service" })
namespace DemoService;
model Widget {
id: string;
weight: int32;
color: "red" | "blue";
}
model WidgetList {
items: Widget[];
}
@error
model Error {
code: int32;
message: string;
}
model AnalyzeResult {
id: string;
analysis: string;
}
@route("/widgets")
@tag("Widgets")
interface Widgets {
/** List widgets */
@get list(): WidgetList | Error;
/** Read widgets */
@get read(@path id: string): Widget | Error;
/** Create a widget */
@post create(@body body: Widget): Widget | Error;
/** Update a widget */
@patch update(@path id: string, @body body: MergePatchUpdate<Widget>): Widget | Error;
/** Delete a widget */
@delete delete(@path id: string): void | Error;
/** Analyze a widget */
@route("{id}/analyze") @post analyze(@path id: string): AnalyzeResult | Error;
}

13
api/package.json Normal file
View File

@@ -0,0 +1,13 @@
{
"name": "api",
"version": "0.1.0",
"type": "module",
"private": true,
"dependencies": {
"@typespec/compiler": "latest",
"@typespec/http": "latest",
"@typespec/rest": "latest",
"@typespec/openapi": "latest",
"@typespec/openapi3": "latest"
}
}

1051
api/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

7
api/tspconfig.yaml Normal file
View File

@@ -0,0 +1,7 @@
emit:
- "@typespec/openapi3"
options:
"@typespec/openapi3":
emitter-output-dir: "{output-dir}/schema"
openapi-versions:
- 3.1.0