Last active
June 20, 2024 14:59
-
-
Save up1/fab65907e5a7ffd46df068da7c2147bf to your computer and use it in GitHub Desktop.
TypeSpec 2024
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ติดตั้ง library | |
$npm install -g @typespec/compiler | |
// สร้าง project | |
$tsp init | |
TypeSpec compiler v0.57.0 | |
? Please select a template › - Use arrow-keys. Return to submit. | |
❯ Empty project min compiler ver: 0.57.0 - Create an empty project. | |
Generic REST API min compiler ver: 0.57.0 | |
TypeSpec Library (With TypeScript) min compiler ver: 0.57.0 | |
TypeSpec Emitter (With TypeScript) min compiler ver: 0.57.0 | |
$tsp install | |
// Compile typespec | |
$tsp compile . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@typespec/http"; | |
import "@typespec/rest"; | |
import "@typespec/openapi3"; | |
using TypeSpec.Http; | |
model User { | |
firstname: string; | |
lastname: string; | |
age: int32; | |
} | |
@route("/users") | |
interface Users { | |
list(@query filter: string): User[]; | |
create(@body user: User): User; | |
read(@path id: string): User; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment