@@ -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