Skip to content

Commit 4e5d3d7

Browse files
committed
Replace nullable: true with OpenAPI 3.1.0 type arrays on 14 properties
1 parent dd3623f commit 4e5d3d7

2 files changed

Lines changed: 61 additions & 20 deletions

File tree

openapi-public.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,18 +3174,21 @@ components:
31743174
envdVersion:
31753175
$ref: '#/components/schemas/EnvdVersion'
31763176
envdAccessToken:
3177-
type: string
3177+
type:
3178+
- string
3179+
- 'null'
31783180
description: 'Access token for authenticating envd requests to this sandbox.
31793181
Only returned when the sandbox is created with `secure: true`. Null for
31803182
non-secure sandboxes (envd endpoints work without auth).'
3181-
nullable: true
31823183
trafficAccessToken:
3183-
type: string
3184-
nullable: true
3184+
type:
3185+
- string
3186+
- 'null'
31853187
description: Token required for accessing sandbox via proxy.
31863188
domain:
3187-
type: string
3188-
nullable: true
3189+
type:
3190+
- string
3191+
- 'null'
31893192
description: 'Deprecated: always null. Construct sandbox URLs as `https://{port}-{sandboxID}.e2b.app`.'
31903193
deprecated: true
31913194
type: object
@@ -3226,14 +3229,16 @@ components:
32263229
envdVersion:
32273230
$ref: '#/components/schemas/EnvdVersion'
32283231
envdAccessToken:
3229-
type: string
3232+
type:
3233+
- string
3234+
- 'null'
32303235
description: 'Access token for authenticating envd requests to this sandbox.
32313236
Only returned when the sandbox is created with `secure: true`. Null for
32323237
non-secure sandboxes (envd endpoints work without auth).'
3233-
nullable: true
32343238
domain:
3235-
type: string
3236-
nullable: true
3239+
type:
3240+
- string
3241+
- 'null'
32373242
description: 'Deprecated: always null. Construct sandbox URLs as `https://{port}-{sandboxID}.e2b.app`.'
32383243
deprecated: true
32393244
cpuCount:
@@ -3473,12 +3478,13 @@ components:
34733478
format: date-time
34743479
description: Time when the template was last updated
34753480
createdBy:
3476-
allOf:
3481+
oneOf:
34773482
- $ref: '#/components/schemas/TeamUser'
3478-
nullable: true
3483+
- type: 'null'
34793484
lastSpawnedAt:
3480-
type: string
3481-
nullable: true
3485+
type:
3486+
- string
3487+
- 'null'
34823488
format: date-time
34833489
description: Time when the template was last used
34843490
spawnCount:
@@ -3575,12 +3581,13 @@ components:
35753581
format: date-time
35763582
description: Time when the template was last updated
35773583
createdBy:
3578-
allOf:
3584+
oneOf:
35793585
- $ref: '#/components/schemas/TeamUser'
3580-
nullable: true
3586+
- type: 'null'
35813587
lastSpawnedAt:
3582-
type: string
3583-
nullable: true
3588+
type:
3589+
- string
3590+
- 'null'
35843591
format: date-time
35853592
description: Time when the template was last used
35863593
spawnCount:
@@ -3675,8 +3682,9 @@ components:
36753682
format: date-time
36763683
description: Time when the template was last updated
36773684
lastSpawnedAt:
3678-
type: string
3679-
nullable: true
3685+
type:
3686+
- string
3687+
- 'null'
36803688
format: date-time
36813689
description: Time when the template was last used
36823690
spawnCount:

scripts/generate_openapi_reference.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,39 @@ def _singularize(word: str) -> str:
11191119
if summary_count:
11201120
fixes.append(f"Added summary to {summary_count} platform endpoints")
11211121

1122+
# 27. Replace nullable: true with OpenAPI 3.1.0 type arrays
1123+
# In 3.1.0, nullable was removed. Use type: ["string", "null"] instead,
1124+
# or oneOf with type: 'null' for $ref properties.
1125+
nullable_fixed = 0
1126+
for schema_name, schema in schemas.items():
1127+
if "properties" not in schema:
1128+
continue
1129+
for prop_name, prop in schema["properties"].items():
1130+
if not isinstance(prop, dict) or not prop.pop("nullable", False):
1131+
continue
1132+
# allOf + nullable → oneOf: [allOf[...], type: 'null']
1133+
if "allOf" in prop:
1134+
all_of = prop.pop("allOf")
1135+
prop["oneOf"] = all_of + [{"type": "null"}]
1136+
# plain type + nullable → type: [original, "null"]
1137+
elif "type" in prop:
1138+
orig_type = prop["type"]
1139+
if isinstance(orig_type, list):
1140+
if "null" not in orig_type:
1141+
orig_type.append("null")
1142+
else:
1143+
prop["type"] = [orig_type, "null"]
1144+
# $ref + nullable → oneOf: [$ref, type: 'null']
1145+
elif "$ref" in prop:
1146+
ref = prop.pop("$ref")
1147+
prop["oneOf"] = [{"$ref": ref}, {"type": "null"}]
1148+
# additionalProperties + nullable (e.g. McpConfig)
1149+
elif "additionalProperties" in prop:
1150+
prop["type"] = ["object", "null"]
1151+
nullable_fixed += 1
1152+
if nullable_fixed:
1153+
fixes.append(f"Replaced nullable: true with 3.1.0 type arrays on {nullable_fixed} properties")
1154+
11221155
if fixes:
11231156
print(f"==> Fixed {len(fixes)} spec issues:")
11241157
for f in fixes:

0 commit comments

Comments
 (0)