Simulates the Xen Orchestra REST API for testing and development. At startup it loads fixtures, enriches them from the Swagger schema, then registers the OpenAPI routes under /rest/v0/ plus custom handlers for endpoints that need special logic.
Swagger UI is available at /docs/. The raw spec is at /swagger.json.
npm install
npm startThe server listens on http://localhost:3001 by default. Override with PORT. Override fixture loading with FIXTURES_DIR.
Generic Swagger CRUD is still used for most resources:
GET /rest/v0/{resource} list
GET /rest/v0/{resource}/{id} get by ID
POST /rest/v0/{resource} create
PUT /rest/v0/{resource}/{id} update
PATCH /rest/v0/{resource}/{id} update
DELETE /rest/v0/{resource}/{id} delete
Custom handlers currently exist for:
POST /rest/v0/vdisPOST /rest/v0/vifsPOST /rest/v0/vbdsPOST /rest/v0/pools/:id/actions/create_vmPOST /rest/v0/vms/:id/actions/:actionPOST /rest/v0/vbds/:id/actions/:actionPOST /rest/v0/pbds/:id/actions/:actionPOST /rest/v0/srs/:id/actions/:action- tag add/remove endpoints for taggable resources
GET /rest/v0/:resource/:id/tasks
Fixtures are loaded from src/fixtures/*.json and merged by collection name. enrichFixtures() fills in defaults from the OpenAPI schema and computed fields used by the handlers.
To add static fixtures:
- Add a JSON file in
src/fixtures/named after the collection, for examplehosts.json. - Use an array of objects, or an object whose array values will be merged by key.
- Include at least
idandtypewhere required by the resource.
When an endpoint needs custom behavior, follow the existing pattern in src/handlers/:
- Mirror the real Xen Orchestra controller types in
src/types.tsusingParameters<Xapi['METHOD_NAME']>. - Add the handler in
src/handlers/<resource>.ts. - Register it from
src/handlers/index.tsso it runs before the generic Swagger router. - Match the existing validation style:
400for missing required fields,404for missing referenced resources,201for successful creates,202for async task actions, and consistent{ error, data }payloads.
npm run docker:build
docker run -p 3001:3001 xo-api-simulator:latestOr:
docker run -p 8080:3001 -e PORT=8080 xo-api-simulator:latestThis project is licensed under the GNU Affero General Public License v3.
Copyright (C) 2026 VATES SAS