Skip to content

Cheat sheet

Verb

FeatureExample
Get operation@get op read(): void
Put operation@put op set(): void
Post operation@post op add(): void
Patch operation@patch op patch(): void
Delete operation@delete op delete(): void
Head operation@head op read(): void

Routing

FeatureExample
Fixed route@route("/pets") op list(): Pet[]
Route with path parameter@route("/pets/{petId}") op getPet(petId: string): Pet
Route with multiple path parameter@route("/stores/{storeId}/pets/{petId}/") op getPet(storeId: string, petId: string): Pet

Data types

FeatureExample
Request headerop read(@header traceparent: string): Pet
Response headerop read(): {@header eTag: string, ...Pet}
Query parameterop list(@query filter: string): Pet[]
Explicit body parameterop add(@body pet: Pet): void
Implicit body parameterop add(...Pet): void
Status codeop read(): {@statusCode _: 200, ...Pet}

Server

FeatureExample
Single@server("https://example.com", "Example 1 endpoint")
Multiple@server("https://example1.com", "E1") @server("https://example2.com", "E2")
Parameterized@server("https://{region}.example.com", "Region scoped endpoint", {region: string})

Authentication

Details: Authentication

FeatureExample
Basic auth@useAuth(BasicAuth)
Bearer auth@useAuth(BearerAuth)
API key auth@useAuth(ApiKeyAuth<"header", "Api-Key">)
OAuth2 key auth@useAuth(OAuth2Flow<[MyScope]>)