|
|
|
|
|
by dcre
967 days ago
|
|
Yeah, basically. We do it with a function call where the argument to the function is that interface representing all the API endpoints. `makeHandlers` handles parsing path params, query params, and request body and passes them to each endpoint handler. So the runtime validation of request bodies is also generated — we generate a zod schema for each request body in the OpenAPI definition and use it to parse the actual request body that comes in. So it's not just a generated interface — there is also generated runtime behavior that is endpoint-specific. big function call https://github.com/oxidecomputer/console/blob/bd65b9da7019ad... automatic body parsing and argument passing: https://github.com/oxidecomputer/console/blob/bd65b9da7019ad... When an endpoint gets added to the spec, we can rerun the generator and get type errors in the `makeHandlers` telling us endpdoints are missing. |
|