Skip to content

Commit c633fb4

Browse files
committed
Fix schema and consistency issues from second SDK testing round
Schema fixes: - EntryInfo.type: add 'directory' to enum (was file-only) - SandboxMetadata, EnvVars: add type: object (had only additionalProperties) - TemplateLegacy: add missing 'names' and 'buildStatus' fields - connect-protocol-version: remove redundant enum (const suffices) - filesystem.EntryInfo.size: document int/string union type (int64) Response fixes: - PATCH /templates/{templateID}: return TemplateUpdateResponse (was empty) - POST /sandboxes/{sandboxID}/refreshes: add missing 500 response - GET /health 502: content-type → application/json (was connect+json) Also fix fill_empty_responses to skip $ref responses.
1 parent 187b9f2 commit c633fb4

2 files changed

Lines changed: 102 additions & 7 deletions

File tree

openapi-public.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ paths:
1818
'502': &id001
1919
description: Sandbox not found
2020
content:
21-
application/connect+json:
21+
application/json:
2222
schema:
2323
type: object
2424
required:
@@ -1261,6 +1261,8 @@ paths:
12611261
$ref: '#/components/responses/401'
12621262
'404':
12631263
$ref: '#/components/responses/404'
1264+
'500':
1265+
$ref: '#/components/responses/500'
12641266
operationId: postSandboxeRefreshes
12651267
servers:
12661268
- *id006
@@ -1575,11 +1577,10 @@ paths:
15751577
responses:
15761578
'200':
15771579
description: The template was updated successfully
1578-
content: &id007
1580+
content:
15791581
application/json:
15801582
schema:
1581-
type: object
1582-
description: Empty response
1583+
$ref: '#/components/schemas/TemplateUpdateResponse'
15831584
'400':
15841585
$ref: '#/components/responses/400'
15851586
'401':
@@ -1603,7 +1604,11 @@ paths:
16031604
responses:
16041605
'202':
16051606
description: The build has started
1606-
content: *id007
1607+
content: &id007
1608+
application/json:
1609+
schema:
1610+
type: object
1611+
description: Empty response
16071612
'401':
16081613
$ref: '#/components/responses/401'
16091614
'500':
@@ -2241,11 +2246,13 @@ components:
22412246
description: Type of the file
22422247
enum:
22432248
- file
2249+
- directory
22442250
type: object
22452251
EnvVars:
22462252
additionalProperties:
22472253
type: string
22482254
description: Environment variables for the sandbox
2255+
type: object
22492256
Metrics:
22502257
type: object
22512258
description: Resource usage metrics
@@ -2282,8 +2289,6 @@ components:
22822289
connect-protocol-version:
22832290
type: number
22842291
title: Connect-Protocol-Version
2285-
enum:
2286-
- 1
22872292
description: Define the version of the Connect protocol
22882293
const: 1
22892294
connect-timeout-header:
@@ -2327,6 +2332,8 @@ components:
23272332
- string
23282333
title: size
23292334
format: int64
2335+
description: File size in bytes. Encoded as string for values exceeding
2336+
JSON number precision (int64).
23302337
mode:
23312338
type: integer
23322339
title: mode
@@ -3039,6 +3046,7 @@ components:
30393046
additionalProperties:
30403047
type: string
30413048
description: Metadata of the sandbox
3049+
type: object
30423050
SandboxState:
30433051
type: string
30443052
description: State of the sandbox
@@ -3655,6 +3663,13 @@ components:
36553663
description: Number of times the template was built
36563664
envdVersion:
36573665
$ref: '#/components/schemas/EnvdVersion'
3666+
names:
3667+
type: array
3668+
description: Names of the template (namespace/alias format when namespaced)
3669+
items:
3670+
type: string
3671+
buildStatus:
3672+
$ref: '#/components/schemas/TemplateBuildStatus'
36583673
type: object
36593674
TemplateBuild:
36603675
required:

scripts/generate_openapi_reference.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,86 @@ def fix_spec_issues(spec: dict[str, Any]) -> None:
892892
param["description"] = schema.pop("description")
893893
fixes.append(f"{ep_path}: moved 'end' description out of schema")
894894

895+
# 18. EntryInfo.type enum incomplete — missing "directory"
896+
entry_info = schemas.get("EntryInfo")
897+
if entry_info:
898+
type_prop = entry_info.get("properties", {}).get("type")
899+
if type_prop and type_prop.get("enum") == ["file"]:
900+
type_prop["enum"] = ["file", "directory"]
901+
fixes.append("EntryInfo.type: added 'directory' to enum")
902+
903+
# 19. SandboxMetadata and EnvVars lack type: object
904+
for name in ("SandboxMetadata", "EnvVars"):
905+
schema = schemas.get(name, {})
906+
if "additionalProperties" in schema and "type" not in schema:
907+
schema["type"] = "object"
908+
fixes.append(f"{name}: added type: object")
909+
910+
# 20. TemplateLegacy missing 'names' and 'buildStatus' fields
911+
tpl_legacy = schemas.get("TemplateLegacy")
912+
if tpl_legacy and "properties" in tpl_legacy:
913+
props = tpl_legacy["properties"]
914+
if "names" not in props:
915+
props["names"] = {
916+
"type": "array",
917+
"description": "Names of the template (namespace/alias format when namespaced)",
918+
"items": {"type": "string"},
919+
}
920+
fixes.append("TemplateLegacy: added 'names' property")
921+
if "buildStatus" not in props:
922+
props["buildStatus"] = {"$ref": "#/components/schemas/TemplateBuildStatus"}
923+
fixes.append("TemplateLegacy: added 'buildStatus' property")
924+
925+
# 21. connect-protocol-version: redundant enum + const
926+
cpv = schemas.get("connect-protocol-version")
927+
if cpv and "enum" in cpv and "const" in cpv:
928+
del cpv["enum"]
929+
fixes.append("connect-protocol-version: removed redundant enum (const is sufficient)")
930+
931+
# 22. filesystem.EntryInfo.size union type undocumented
932+
fs_entry = schemas.get("filesystem.EntryInfo")
933+
if fs_entry and "properties" in fs_entry:
934+
size_prop = fs_entry["properties"].get("size")
935+
if size_prop and isinstance(size_prop.get("type"), list):
936+
size_prop["description"] = (
937+
"File size in bytes. Encoded as string for values exceeding "
938+
"JSON number precision (int64)."
939+
)
940+
fixes.append("filesystem.EntryInfo.size: documented integer/string union type")
941+
942+
# 23. GET /health 502 uses application/connect+json — change to application/json
943+
if health_get:
944+
for status_code, resp in health_get.get("responses", {}).items():
945+
if not isinstance(resp, dict):
946+
continue
947+
content = resp.get("content", {})
948+
if "application/connect+json" in content and "application/json" not in content:
949+
content["application/json"] = content.pop("application/connect+json")
950+
fixes.append(f"/health {status_code}: content-type → application/json")
951+
952+
# 24. PATCH /templates/{templateID} (deprecated) returns empty object —
953+
# use TemplateUpdateResponse like v2
954+
patch_v1_path = paths.get("/templates/{templateID}", {})
955+
patch_v1 = patch_v1_path.get("patch")
956+
if patch_v1:
957+
resp_200 = patch_v1.get("responses", {}).get("200", {})
958+
# Replace the entire content dict (don't modify shared YAML anchor object)
959+
resp_200["content"] = {
960+
"application/json": {
961+
"schema": {"$ref": "#/components/schemas/TemplateUpdateResponse"}
962+
}
963+
}
964+
fixes.append("PATCH /templates/{templateID}: response → TemplateUpdateResponse")
965+
966+
# 25. POST /sandboxes/{sandboxID}/refreshes missing 500 response
967+
refreshes_path = paths.get("/sandboxes/{sandboxID}/refreshes", {})
968+
refreshes_post = refreshes_path.get("post")
969+
if refreshes_post:
970+
responses = refreshes_post.get("responses", {})
971+
if "500" not in responses:
972+
responses["500"] = {"$ref": "#/components/responses/500"}
973+
fixes.append("/sandboxes/{sandboxID}/refreshes: added 500 response")
974+
895975
if fixes:
896976
print(f"==> Fixed {len(fixes)} spec issues:")
897977
for f in fixes:

0 commit comments

Comments
 (0)