OpenAPI-generated client libraries for the ros2_medkit gateway.
| Path | Description |
|---|---|
spec/openapi.yaml |
OpenAPI 3.1.0 spec snapshot from gateway runtime |
clients/typescript/ |
TypeScript client (@selfpatch/ros2-medkit-client-ts) |
clients/python/ |
Python client (ros2-medkit-client) |
scripts/export-spec.sh |
Export spec from a running gateway |
scripts/generate.sh |
Generate client code from the spec |
Current spec is from gateway v0.4.0 - see SPEC_VERSION for exact version.
# Start the gateway first (default: http://localhost:8080)
./scripts/export-spec.sh
# Or specify a custom URL
GATEWAY_URL=http://192.168.1.10:8080 ./scripts/export-spec.sh./scripts/generate.shnpx @stoplight/spectral-cli@6.14.2 lint spec/openapi.yamlConfigure npm to use GitHub Packages for the @selfpatch scope:
echo "@selfpatch:registry=https://npm.pkg.github.com" >> .npmrcInstall the package:
npm install @selfpatch/ros2-medkit-client-tsimport { createMedkitClient } from '@selfpatch/ros2-medkit-client-ts';
// Create a client (URL is normalized - adds http:// and /api/v1 if missing)
const client = createMedkitClient({ baseUrl: 'localhost:8080' });
// CRUD operations - fully typed from the OpenAPI spec
const { data, error } = await client.GET('/apps');
if (error) {
console.error(error.code, error.message); // MedkitError
}
// SSE streaming - faults, triggers, subscriptions
for await (const event of client.streams.faults()) {
console.log(event.data);
}
// With authentication
const authedClient = createMedkitClient({
baseUrl: 'localhost:8080',
auth: { token: 'your-jwt-token' },
});See clients/typescript/ for the full source and API.
pip install ros2-medkit-client --index-url https://pypi.pkg.github.com/selfpatch/simple/from ros2_medkit_client import MedkitClient, MedkitError
from ros2_medkit_client.api.discovery import list_apps
async with MedkitClient(base_url="localhost:8080") as client:
# Option 1: call() bridges errors into MedkitError exceptions
apps = await client.call(list_apps.asyncio)
# Option 2: raw generated API (returns SuccessType | GenericError | None)
result = await list_apps.asyncio(client=client.http)
# SSE streaming
async for event in client.streams.faults():
print(event.data)
# Error handling with call()
try:
apps = await client.call(list_apps.asyncio)
except MedkitError as e:
print(e.code, e.message)See clients/python/ for the full source and API.
Apache 2.0 - see LICENSE.