OpenAPI Clients
In your moduledefiniton.yml:
openApiClients:
myclient:
spec: openapi/myclient/testservice.yml
the spec may be either a YAML or a JSON file.
Use wh apply config to generate/update the TypeScript definitionts used by createOpenAPIClient
To access the client use createOpenAPIClient:
const service = createOpenAPIClient<"mymodule:myclient">("https://www.example.com/myclient/v1/");
Testing OpenAPI services using the dlient
If you're writing tests for a local service you can use getDirectOpenAPIFetch to create a client that doesn't use HTTP but directly calls into the service.
This will generally be faster and give more useful stacktraces/logging as no process boundary is crossed to invoke your service.
using serviceFetch = await getDirectOpenAPIFetch("mymodule:myclient");
const service = createOpenAPIClient<"mymodule:myclient">(serviceFetch);