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

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;
}