Skip to content

Publish SwarmCommon.yaml so the served OpenAPI spec can be dereferenced - #841

Open
crtahlin wants to merge 1 commit into
masterfrom
fix/serve-swarmcommon-spec
Open

Publish SwarmCommon.yaml so the served OpenAPI spec can be dereferenced#841
crtahlin wants to merge 1 commit into
masterfrom
fix/serve-swarmcommon-spec

Conversation

@crtahlin

Copy link
Copy Markdown
Collaborator

https://docs.ethswarm.org/openapi.yaml returns HTTP 200 but cannot be dereferenced by any OpenAPI client. This makes it usable.

Why

The prebuild step copies openapi/Swarm.yamlstatic/openapi.yaml, but not its sibling openapi/SwarmCommon.yaml, which holds 99 schemas, 23 parameters, 7 headers and 8 responses. All 446 $refs in the published spec point at that one file, and it is not published, so every one of them dangles.

What that means in practice for anyone pointing a tool at the URL:

Tool Today After
openapi-generator / swagger-codegen fails, or emits endpoints with no types generates a working Bee client in any of ~50 languages
Postman / Insomnia import endpoints appear with no parameters, bodies or schemas full import
Swagger UI / Redocly pointed at the URL will not render renders
Agent framework binding tools from a spec endpoints with no parameter definitions usable tool definitions

The consequence worth caring about is not "the file is malformed" but that the spec never states swarm-postage-batch-id is a required header. Someone generating a client gets code that compiles, calls the API, and receives a 400 with no indication why.

The Redoc page at /api/ is unaffected, which is why this went unnoticed: redocusaurus resolves the refs at build time from the openapi/ directory where both files sit together. The human page renders correctly while the published file — the one machines fetch — is broken and still returns 200.

What changed

  1. package.json — the prebuild copy step also publishes SwarmCommon.yaml, and .well-known/agent.json as a copy of agent-card.json so clients probing the spec-canonical A2A filename find the card instead of a 404.
  2. .gitignore — both new outputs are generated, not committed, so openapi/ and agent-card.json remain the single sources of truth and cannot drift.
  3. scripts/validate-openapi-spec.mjs (new) — resolves every $ref in the published spec and exits non-zero if any fails. Deliberately stricter than validate-llms-txt.mjs, which is warning-only: a spec no client can dereference is broken output rather than a documentation warning. Without this the regression returns silently, since the broken file still serves 200.

All refs resolve because they are bare relative references (SwarmCommon.yaml#/…) and both files land at the site root.

Verified both directions

Run Result
Copy only Swarm.yaml (current behaviour) exit 1 — 446 unresolvable refs, each listed with its location
New prebuild copy step exit 0 — all $refs resolve

Outputs: openapi.yaml 87,639 b, SwarmCommon.yaml 37,475 b, agent.json byte-identical to agent-card.json.

Caveats

  • I have not measured how many people or tools actually fetch this spec, and I cannot. So I cannot claim a number of users unblocked. What is certain is that the endpoint is broken today, the fix is two lines plus a test, and it costs nothing at build time — so while the audience is unknown, publishing a spec that works cannot hurt.
  • /openapi.json is deliberately not included. Under this approach it would be a JSON file whose refs still point into a .yaml, which needs ref-rewriting — effectively bundling. Better handled by a @redocly/cli bundle step later; tracked in ethersphere/DevRel#904.
  • A full docusaurus build was not run locally (it needs network for the awesome-swarm and cheatsheet fetches). The validator was exercised directly against both states instead. Worth watching CI, since this PR adds a step that can fail the build.

Addresses ethersphere/DevRel#904.

Description generated with help of AI.

The prebuild step copies openapi/Swarm.yaml to static/openapi.yaml but not
its sibling openapi/SwarmCommon.yaml, which holds every schema, parameter,
header and response. All 446 $refs in the published spec point at that one
file, so the spec served from docs.ethswarm.org/openapi.yaml cannot be
dereferenced by any OpenAPI client: 99 schemas, 23 parameters, 7 headers
and 8 responses are unreachable.

The Redoc page at /api/ is unaffected because redocusaurus resolves the
refs at build time from the openapi/ directory, where both files sit
together. That is why the failure is invisible: the human page renders and
the published file still returns HTTP 200.

Also publishes .well-known/agent.json as a copy of agent-card.json, so
clients probing the spec-canonical A2A filename find the card, and adds
scripts/validate-openapi-spec.mjs to the prebuild chain. The validator
resolves every $ref in the published spec and exits non-zero if any fails,
so this regression cannot return silently. Verified against both states:
it fails with 446 unresolvable refs before the fix and passes after.

Both generated files are gitignored, keeping openapi/ and agent-card.json
the single sources of truth.
@crtahlin
crtahlin requested a review from yjkellyjoo August 27, 2026 12:19
@netlify

netlify Bot commented Aug 27, 2026

Copy link
Copy Markdown

Deploy Preview for test-twitter-preview-testing-3 ready!

Name Link
🔨 Latest commit 2dfd966
🔍 Latest deploy log https://app.netlify.com/projects/test-twitter-preview-testing-3/deploys/6a902b6e59625b0008709685
😎 Deploy Preview https://deploy-preview-841--test-twitter-preview-testing-3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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