Skip to content

docs: update openapi.yml to match CubeAPI implementation#381

Open
woshihoujinxin wants to merge 1 commit into
TencentCloud:masterfrom
woshihoujinxin:docs/update-openapi
Open

docs: update openapi.yml to match CubeAPI implementation#381
woshihoujinxin wants to merge 1 commit into
TencentCloud:masterfrom
woshihoujinxin:docs/update-openapi

Conversation

@woshihoujinxin
Copy link
Copy Markdown

Problem

The openapi.yml spec was outdated and did not reflect the actual CubeAPI endpoints, request/response schemas, and error codes.

Changes

  • Synchronize the OpenAPI spec with the actual CubeAPI implementation
  • Update endpoint paths, request bodies, response schemas, and error codes
  • Add missing endpoints and parameters

@cubesandboxbot
Copy link
Copy Markdown

cubesandboxbot Bot commented May 27, 2026

Claude finished @woshihoujinxin's task in 1m 49s —— View job


PR Review: docs: update openapi.yml to match CubeAPI implementation

openapi.yml — Overall Assessment

The OpenAPI spec restructuring looks thorough and well-organized. The diff is large (+1264/-442) but the structure is logical. Here are my observations:

✅ What's done well

  1. Section headers & organization: The use of comment banners (# ─── Health ───, # ─── Sandbox lifecycle ───, etc.) makes the file much more navigable at ~1661 lines.

  2. Extracted shared parameters: Moving sandboxID, templateID, and buildID into reusable $ref parameters (#/components/parameters/SandboxID, etc.) eliminates repetitive inlined path parameters across all endpoints.

  3. Two-server model: Adding the / (E2B-compatible) server alongside /cubeapi/v1 correctly documents the dual-surface nature of the API.

  4. Response coverage: Most endpoints now have proper 404 and 500 error responses with ApiError schemas, which was missing before.

  5. Added missing endpoints: The new spec covers templates build management, snapshots, rollback, config, store, and refresh — all missing from the old spec.

  6. OpenAPI 3.1 compliance: Using multi-type syntax (type: [string, 'null']) is correct for OpenAPI 3.1 which uses JSON Schema 2020-12 draft.

⚠️ Specific observations

Location Issue
Sandbox response (connect/create) Schema includes envdAccessToken, trafficAccessToken as nullable strings. These are security-sensitive fields — consider noting they're returned only on initial creation/connect.
/templates/{id}/builds/{bid}/logs Only has a 200 response. No 404 (build not found) or 500 error responses, unlike other endpoints.
/config, /store/meta, /store/refresh No error responses at all — only 200. If these endpoints can fail (e.g., store unavailable), they should document error responses.
SandboxState enum enum: [running, paused, pausing] — good addition of pausing state. Consider also adding unknown or error if those states are possible.

Scope of Changes Outside openapi.yml

The PR title says "update openapi.yml" but 42 other files were also modified. Consider splitting these into separate PRs or updating the PR title/description:

1. SDK model simplification (sdk/python/cubesandbox/)

Significant changes that go beyond a simple documentation update:

  • __init__.py: SDK version downgraded from 0.2.0 to 0.1.0 — this looks like a regression. The openapi.yml version was bumped from 0.1.00.2.0, but the SDK went backwards. Was this intentional?
  • _models.py: Removed to_json(), formats(), __getitem__, _repr_*_ methods, json_data alias — appears to be removing E2B compatibility layer. If this is intentional cleanup, it should be noted explicitly.
  • _template.py: Simplified TemplateBuild and TemplateInfo with fewer fields. Breaking change for downstream consumers using fields like phase, progress, error_message.

2. Example deletion (CubeAPI/examples/snapshot-rollback-clone/)

11 Python example files + README (EN/ZH) + env.py + requirements.txt were deleted. Was this because the snapshot/rollback APIs have changed and these examples are no longer accurate?

3. Test file deletions (sdk/python/tests/)

test_template_e2e.py (116 lines) was deleted and conftest.py was modified. Are there replacement tests elsewhere?

4. Documentation link cleanup (docs/)

Multiple .md → clean URL conversions in internal links (e.g., ./quickstart.md./quickstart). Looks like a correctness fix — just note this in the PR description.

5. Snapshot guide deletion (docs/guide/snapshot-rollback-clone.md)

The entire snapshot/rollback/clone guide (150 lines, in both EN and ZH) was deleted. This is user-facing documentation removal and should be called out in the PR description with a reason.

Summary

The openapi.yml restructuring is solid, but the PR scope is significantly broader than the title "update openapi.yml". Please consider:

  1. Updating the PR description to document all the SDK model changes, example deletions, and documentation changes
  2. Clarifying the SDK version reversal (0.2.00.1.0) — confirm this is intentional
  3. Adding missing error responses to /config, /store/*, and /templates/{id}/builds/{bid}/logs if those endpoints can actually fail
  4. Adding a changelog or migration note for the SDK breaking changes if downstream consumers exist

Review in progress — full analysis complete.

Synchronize the OpenAPI spec with the actual CubeAPI endpoints,
request/response schemas, and error codes.

Signed-off-by: HouJinxin <houjinxin@example.com>
@cubesandboxbot
Copy link
Copy Markdown

cubesandboxbot Bot commented May 27, 2026

Claude finished @woshihoujinxin's task in 2m 34s —— View job


PR Review: docs: update openapi.yml to match CubeAPI implementation

I've performed a detailed comparison of the updated openapi.yml against the actual CubeAPI Rust source code (CubeAPI/src/routes.rs, CubeAPI/src/handlers/*.rs, CubeAPI/src/models/mod.rs). The PR has only 1 commit modifying 1 file (openapi.yml), contrary to what the previous review suggested — no SDK changes, test deletions, or doc changes are in scope for this PR.


✅ Endpoint Coverage — All Verified

All 31 routes documented in openapi.yml match the actual router in CubeAPI/src/routes.rs:

Surface Route Method Verified
E2B + CubeAPI /health GET
E2B + CubeAPI /sandboxes GET, POST
E2B + CubeAPI /v2/sandboxes GET
E2B + CubeAPI /sandboxes/{sandboxID} GET, DELETE
E2B + CubeAPI /sandboxes/{sandboxID}/logs GET
E2B + CubeAPI /v2/sandboxes/{sandboxID}/logs GET
E2B + CubeAPI /sandboxes/{sandboxID}/timeout POST
E2B + CubeAPI /sandboxes/{sandboxID}/refreshes POST
E2B + CubeAPI /sandboxes/{sandboxID}/pause POST
E2B + CubeAPI /sandboxes/{sandboxID}/resume POST
E2B + CubeAPI /sandboxes/{sandboxID}/connect POST
E2B + CubeAPI /sandboxes/{sandboxID}/snapshots POST ✅ (long router)
E2B + CubeAPI /sandboxes/{sandboxID}/rollback POST ✅ (long router)
E2B + CubeAPI /snapshots GET
E2B + CubeAPI /templates GET, POST
E2B + CubeAPI /templates/{templateID} GET, POST, PATCH, DELETE ✅ (PATCH returns 501)
E2B + CubeAPI /templates/{templateID}/builds/{buildID} POST
E2B + CubeAPI /templates/{templateID}/builds/{buildID}/status GET
E2B + CubeAPI /templates/{templateID}/builds/{buildID}/logs GET
CubeAPI only /cluster/overview GET ✅ ($ref in routes.rs)
CubeAPI only /nodes GET
CubeAPI only /nodes/{nodeID} GET
CubeAPI only /config GET
CubeAPI only /store/meta GET
CubeAPI only /store/refresh POST

✅ Schema Verification

Key schemas checked against Rust models (CubeAPI/src/models/mod.rs):

Schema Status Notes
SandboxState [running, paused, pausing] — adds pausing (matches SandboxState::Pausing enum)
Sandbox Fields match. alias, envdAccessToken, trafficAccessToken, domain properly nullable
SandboxDetail Matches. metadata uses oneOf: [null, HashMap]
ListedSandbox Matches. diskSizeMB, metadata, volumeMounts properly nullable
NewSandbox envVars and metadata correctly use oneOf: [null, HashMap]
TemplateSummary Fields match
TemplateDetail createRequest: {} and replicas: {} match Rust's Vec<serde_json::Value>
TemplateBuildJob errorMessage correctly NOT in required (matches skip_serializing_if = "String::is_empty")
TemplateBuildStatus All fields match
ClusterOverview All 7 required fields match
NodeView quotaCpu, quotaMemMB, createConcurrentNum match Rust fields
NodeConditionView Matches
RuntimeConfig All 5 fields match CubeAPI/src/handlers/config.rs
SnapshotListItem Matches
ImageMeta / StoreMeta Matches CubeAPI/src/handlers/store.rs
SandboxLogsV2Response Matches

⚠️ Issues Found

1. Missing error responses on template build endpoints

Three template build endpoints are missing error responses (404, 500) even though their handlers return AppResult (meaning errors are possible):

  • POST /templates/{templateID}/builds/{buildID} (line 606): only has 202
  • GET /templates/{templateID}/builds/{buildID}/status (line 622): only has 200
  • GET /templates/{templateID}/builds/{buildID}/logs (line 644): only has 200

When backends fail, these would return error bodies with no schema documented. For comparison, every other endpoint with AppResult handlers includes both 404 and 500 responses.

2. Optional field semantic mismatch: skip_serializing_if vs nullable

Several Rust models use skip_serializing_if = "Option::is_none" which means the JSON key is absent when the value is None. The OpenAPI spec declares these as type: [string, 'null'] or similar, implying the key is present with null value.

Example — Sandbox response:

  • Rust: alias is absent when None
  • OpenAPI: "alias": "type: [string, 'null']" → implies "alias": null

While many consumers handle both forms, this is a spec-to-implementation mismatch. Fields affected:

  • Sandbox.alias, Sandbox.envdAccessToken, Sandbox.trafficAccessToken, Sandbox.domain
  • SandboxDetail and ListedSandbox — same nullable pattern
  • TemplateSummary.createdAt, TemplateSummary.imageInfo

Recommendation: Either:

  • Remove nullable from these fields and make them optional (just omit from response), or
  • Add nullable: true AND note that the field may be omitted.

3. PATCH /templates/{templateID} — 501 response has no content type

patch:
  ...
  responses:
    '501':
      description: Not implemented

The actual handler returns AppError::NotImplemented(...) which produces a JSON error body (ApiError). The spec should document the response body:

'501':
  description: Not implemented
  content:
    application/json:
      schema:
        $ref: '#/components/schemas/ApiError'

4. POST /sandboxes — missing 400 validation response

The handler deserializes NewSandbox which has #[validate] annotations (e.g., timeout requires min = 0). Invalid input would return a 400/422 error that is not documented.


✅ Positive Highlights

  • Two-server model (/cubeapi/v1 + /) correctly reflects the dual-surface routing in routes.rs (the build_e2b_router vs build_cubeapi_router split).
  • Extracted $ref parameters (SandboxID, TemplateID, BuildID) reduce duplication significantly compared to the old inlined path params.
  • Section banners (# ─── Health ───) make the 1661-line file navigable.
  • Response status codes match the handlers precisely — 200 for success bodies, 201 for creation, 202 for accepted jobs, 204 for no-content, and appropriate 404/409/500 errors.
  • SandboxState correctly adds pausing which matches the Rust enum variant SandboxState::Pausing.
  • OpenAPI 3.1 multi-type syntax (type: [string, 'null']) and oneOf for nullable complex types match the Rust Option<T> semantics.

Summary

The updated openapi.yml is a thorough and accurate reflection of the CubeAPI implementation. All 31 endpoints are correctly documented with proper paths, methods, status codes, and schemas. The PR scope is genuinely limited to a single file (openapi.yml). The issues noted above are minor gaps in error response documentation that would improve the spec's completeness.

woshihoujinxin pushed a commit to woshihoujinxin/CubeSandbox that referenced this pull request May 29, 2026
…tore endpoints

Closes review comments on PR TencentCloud#381:
- POST /templates/{id}/builds/{id}: add 400, 404, 500
- GET /templates/{id}/builds/{id}/status: add 404, 500
- GET /templates/{id}/builds/{id}/logs: add 404, 500
- GET /config: add 500
- GET /store/meta: add 500
- POST /store/refresh: add 500
woshihoujinxin pushed a commit to woshihoujinxin/CubeSandbox that referenced this pull request May 29, 2026
…tore endpoints

Closes review comments on PR TencentCloud#381:
- POST /templates/{id}/builds/{id}: add 400, 404, 500
- GET /templates/{id}/builds/{id}/status: add 404, 500
- GET /templates/{id}/builds/{id}/logs: add 404, 500
- GET /config: add 500
- GET /store/meta: add 500
- POST /store/refresh: add 500
woshihoujinxin pushed a commit to woshihoujinxin/CubeSandbox that referenced this pull request May 29, 2026
…tore endpoints

Closes review comments on PR TencentCloud#381:
- POST /templates/{id}/builds/{id}: add 400, 404, 500
- GET /templates/{id}/builds/{id}/status: add 404, 500
- GET /templates/{id}/builds/{id}/logs: add 404, 500
- GET /config: add 500
- GET /store/meta: add 500
- POST /store/refresh: add 500
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