These templates can be used with openapi-generator-cli to produce a working
Reticulum LXMF service and client from an OpenAPI specification. The generated
structure mirrors the EmergencyManagement example.
Install the generator with the Python CLI or run it via Docker. Using the Python package:
pip install openapi-generator-cliOr with Docker:
docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli generateopenapi-generator-cli generate \
-g python \
-i path/to/spec.yaml \
-t templates \
-o generatedThe output will contain:
models.py– dataclasses for all schemascontrollers.py– controller classes with async handlersservice.py–LXMFServicesubclass registering routesserver.py– entrypoint starting the serviceclient.py– simple client invoking the first operationdatabase.py– example async database setup
Adjust the generated code as needed for your specification.
- Set
auth_tokenon the generated service and client if your deployment requires message authentication. - Extend the generated
server.pywith the same runtime CLI options used by the Emergency Management example (--config-path,--storage-path,--display-name,--auth-token,--database-path,--database-url, and--link-keepalive-interval). The scaffolded file only sleeps for 30 seconds; update it to wait on a signal-aware shutdown event so the service keeps running until interrupted, prints its identity hashes, and retries LXMF link establishment when necessary. - Call
configure_database()with a caller-supplied override beforeinit_dbto honour environment variables such asEMERGENCY_DATABASE_URLor CLI flags. - Add additional schema dataclasses if your API defines objects outside the supplied OpenAPI spec.
- Mirror the gateway helpers if you need FastAPI adapters: load shared LXMF
client configuration from
NORTH_API_CONFIG_PATH/NORTH_API_CONFIG_JSON, expose/notifications/stream, and surface interface or link status in startup logs.