fix: include endpoints in /worlds response and list_worlds discovery#153
Conversation
The gateway /worlds endpoint omitted endpoints, causing OpenClaw's list_worlds tool to report 'no endpoint' for all gateway-discovered worlds. Now both the gateway response and plugin discovery store endpoints properly. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Jing-yilin
left a comment
There was a problem hiding this comment.
Codex Review
[Medium] /worlds OpenAPI schema still omits endpoints
The handler now returns an endpoints array, but WorldSummary in gateway/openapi.yaml still only declares worldId, agentId, name, reachable, and lastSeen. Any client or validator generated from the published schema will keep treating that field as absent, so the API contract this PR is changing remains out of sync. Please add endpoints to WorldSummary as part of this fix.
Refs: gateway/server.mjs:379, gateway/openapi.yaml:340
[Low] The new regression test never exercises the broken gateway route
The regression came from GET /worlds, but the added test only stubs the gateway response inside the plugin harness. If gateway/server.mjs drops endpoints again, this test will still pass because it never hits the real route. Adding a small createGatewayApp() assertion around GET /worlds would pin the actual contract this PR is fixing.
Refs: gateway/server.mjs:369, test/index-lifecycle.test.mjs:328
Reviewed by Codex
**Stacked on #153** Replace the hand-maintained `gateway/openapi.yaml` with `@fastify/swagger` auto-generation from route schemas. ## Changes - Register `@fastify/swagger` + `@fastify/swagger-ui` in the gateway - Extract reusable JSON Schema definitions into `gateway/schemas.mjs` - Add inline `schema` to all 10 gateway routes (health, agents, worlds, world/:id, agent.json, peer/ping, peer/peers, peer/announce, peer/heartbeat, peer/message) - Serve Swagger UI at `GET /docs` and JSON spec at `GET /docs/json` - Delete `gateway/openapi.yaml` (no longer needed) - Update Dockerfile to include `schemas.mjs` ## Benefits - Schema changes are made alongside route code -- can never go out of sync - Fastify validates responses against the schema at runtime (catches type bugs) - `/docs` provides interactive API explorer for development - Previously failing 6 gateway tests now pass (response serialization through schemas fixes Fastify inject issues)
The gateway
/worldsendpoint omittedendpoints, causing the plugin'slist_worldstool to report 'no endpoint' for all gateway-discovered worlds.Changes
endpointsfield to/worldsresponse objectsendpointsfrom gateway response and store them inregistryWorldsanddiscoveredPeers