Client

OpenAPI

We can create typed clients from OpenAPI specs without any code generation.

However we must place our OpenAPI spec into a .d.ts declaration file like so

// spec.json.d.ts
export default {
	// ...OpenAPI spec JSON
}

To learn more about this, view the OAS docs.

We can then use @webroute/oas with @webroute/client.

import { ParseSpec } from "@webroute/oas"
import Spec from "./spec.json"
 
type AppDef = ParseSpec<typeof Spec>;
 
const client = createTypedClient<AppDef>()({
	// ...
})

On this page

No Headings