@@ -26,9 +26,13 @@ def find_ref(schema: dict, ref: str) -> dict:
2626
2727def get_type (props : dict , name : str ) -> str :
2828 prop_type = props ["type" ]
29- if prop_type == "array" :
29+ if isinstance (prop_type , list ):
30+ prop_type = " or " .join (prop_type )
31+ elif prop_type == "array" :
3032 try :
3133 array_type = props ["items" ]["type" ]
34+ if isinstance (array_type , list ):
35+ array_type = " or " .join (array_type )
3236 except KeyError :
3337 errprint ("warning: array property without items: {}" .format (name ))
3438 array_type = "unknown"
@@ -48,7 +52,9 @@ def render_flat(schema: dict):
4852 if not ref :
4953 raise Exception ("$ref not found: {}" .format (props ["$ref" ]))
5054 props = ref
51- if props ["type" ] in ["string" , "integer" , "boolean" , "number" ]:
55+ if isinstance (props ["type" ], list ):
56+ print ("{}: {}" .format ("." .join (path + [name ]), " or " .join (props ["type" ])))
57+ elif props ["type" ] in ["string" , "integer" , "boolean" , "number" ]:
5258 # End of the line...
5359 print ("{}: {}" .format ("." .join (path + [name ]), props ["type" ]))
5460 elif props ["type" ] == "object" :
@@ -63,9 +69,12 @@ def render_flat(schema: dict):
6369 )
6470 elif props ["type" ] == "array" :
6571 if "items" in props and "type" in props ["items" ]:
72+ item_type = props ["items" ]["type" ]
73+ if isinstance (item_type , list ):
74+ item_type = " or " .join (item_type )
6675 print (
6776 "{}: {}[]" .format (
68- "." .join (path + [name ]), props [ "items" ][ "type" ]
77+ "." .join (path + [name ]), item_type
6978 )
7079 )
7180 if "properties" in props ["items" ]:
@@ -110,14 +119,17 @@ def render_rst(schema: dict):
110119 {"name" : name , "type" : prop_type , "description" : description }
111120 )
112121
113- if props ["type" ] == "object" and "properties" in props :
122+ if not isinstance ( props [ "type" ], list ) and props ["type" ] == "object" and "properties" in props :
114123 stack .insert (0 , (props , path + [name ], "object" ))
115124 elif (
116- props ["type" ] == "array"
125+ not isinstance (props ["type" ], list )
126+ and props ["type" ] == "array"
117127 and "items" in props
118128 and "properties" in props ["items" ]
119129 ):
120130 array_type = props ["items" ]["type" ]
131+ if isinstance (array_type , list ):
132+ array_type = " or " .join (array_type )
121133 stack .insert (
122134 0 ,
123135 (
0 commit comments