Skip to content

refactor: clean up OpenAPI schema for proper tags, summaries, and schemas#271

Open
markokraemer wants to merge 1 commit intorivet-dev:mainfrom
markokraemer:refactor/openapi-schema-cleanup
Open

refactor: clean up OpenAPI schema for proper tags, summaries, and schemas#271
markokraemer wants to merge 1 commit intorivet-dev:mainfrom
markokraemer:refactor/openapi-schema-cleanup

Conversation

@markokraemer
Copy link

Summary

Deep cleanup of the OpenAPI spec generation so the auto-generated output is clean, navigable, and structurally correct. All changes are in the Rust source annotations; the JSON output follows automatically via the existing utoipa pipeline.

API docs with domain tags

https://github.com/markokraemer/sandbox-agent/releases/download/pr-assets-openapi/openapi-docs-video.mp4

What changed

Domain-specific tags (was: everything under a single v1 tag)

All 71 operations are now grouped into 7 domain tags: health, desktop, agents, filesystem, processes, config, acp. This makes the API reference navigable in Swagger UI, Mintlify, and SDK generators.

Summaries and descriptions for every operation (was: 22 missing)

Added /// summary + /// description doc comments to all handlers that lacked them (health, agents, filesystem, config, ACP). The generated spec now has summary and description on every single operation.

Fixed 3 broken schema $ref targets (CRITICAL)

McpCommand, McpOAuthConfigOrDisabled, and McpRemoteTransport were referenced by McpServerConfig but never registered in ApiDoc. Also added McpOAuthConfig. All $ref targets now resolve correctly, and the hacky patch-openapi-types.mjs workarounds are no longer needed.

Removed 14 orphan schemas

Query-param structs like FsPathQuery, McpConfigQuery, ProcessListQuery etc. were registered in components/schemas but utoipa inlines them as individual parameters. Removed the dead schema registrations.

Correct content types for binary endpoints

Endpoint Before After
Screenshots no content type image/png
Recording download no content type video/mp4
File download no content type application/octet-stream
SSE stream no content type text/event-stream
File upload text/plain application/octet-stream
Tar upload text/plain application/x-tar

Improved info section

  • Title: sandbox-agent -> Sandbox Agent
  • Contact: now points to sandboxagent.dev
  • License: added Apache-2.0 URL
  • Server: added description "Local development server"

Build reliability

  • build.rs now watches types.rs, desktop_types.rs, universal_events.rs, and the error crate (was only watching router.rs and lib.rs)
  • Added /// descriptions to all 14 query parameters that lacked them

Files changed

  • server/packages/sandbox-agent/src/router.rs - Tags, doc comments, content types, ServerAddon modifier
  • server/packages/sandbox-agent/src/router/types.rs - Parameter description
  • server/packages/sandbox-agent/src/desktop_types.rs - Parameter descriptions
  • server/packages/openapi-gen/build.rs - Additional rerun-if-changed watches
  • sdks/typescript/scripts/patch-openapi-types.mjs - Removed dead patches
  • docs/openapi.json - Regenerated output

Verification

  • cargo check passes
  • cargo test -p sandbox-agent --lib - 22/22 pass
  • swagger-cli validate - valid OpenAPI 3.0.3
  • openapi-typescript generates correct types without patches

…es, and schemas

- Add 7 domain-specific tags (health, desktop, agents, filesystem, processes, config, acp) replacing the single flat 'v1' tag
- Add summary + description doc comments to all 22 handlers that were missing them
- Register 4 missing schemas (McpCommand, McpRemoteTransport, McpOAuthConfig, McpOAuthConfigOrDisabled) fixing broken $ref targets
- Remove 14 orphan query-param schemas that utoipa inlines automatically
- Declare correct content types for binary endpoints (image/png, video/mp4, application/octet-stream, text/event-stream, application/x-tar)
- Fix upload request content types from text/plain to application/octet-stream and application/x-tar
- Improve info section: title, description, contact, license URL, server description
- Add parameter descriptions to all 14 previously undocumented query params
- Expand build.rs rerun-if-changed to watch types.rs, desktop_types.rs, universal_events.rs, and error crate
- Remove now-unnecessary type patches from patch-openapi-types.mjs
@markokraemer
Copy link
Author

Before:
Screenshot 2026-03-18 at 17 20 53
it was this mess

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