Skip to content

fix: include endpoints in /worlds response and list_worlds discovery#153

Merged
Jing-yilin merged 5 commits into
mainfrom
fix/worlds-endpoint-discovery
Mar 24, 2026
Merged

fix: include endpoints in /worlds response and list_worlds discovery#153
Jing-yilin merged 5 commits into
mainfrom
fix/worlds-endpoint-discovery

Conversation

@Jing-yilin
Copy link
Copy Markdown
Contributor

The gateway /worlds endpoint omitted endpoints, causing the plugin's list_worlds tool to report 'no endpoint' for all gateway-discovered worlds.

Changes

  • gateway/server.mjs: Add endpoints field to /worlds response objects
  • src/index.ts: Parse endpoints from gateway response and store them in registryWorlds and discoveredPeers

Jing-yilin and others added 2 commits March 24, 2026 13:51
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>
Copy link
Copy Markdown
Contributor Author

@Jing-yilin Jing-yilin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Jing-yilin and others added 2 commits March 24, 2026 14:29
**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)
@Jing-yilin Jing-yilin merged commit 6994233 into main Mar 24, 2026
3 checks passed
@Jing-yilin Jing-yilin deleted the fix/worlds-endpoint-discovery branch March 24, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant