@@ -70,19 +70,28 @@ def to_openapi_query_parameters(self, servic, spec):
7070 "required" : prop in json_schema .get ("required" , []),
7171 "allowEmptyValue" : spec .get ("nullable" , False ),
7272 "default" : spec .get ("default" ),
73+ "schema" : {},
7374 }
74- if spec .get ("schema" ):
75- params ["schema" ] = spec .get ("schema" )
76- else :
77- params ["schema" ] = {"type" : spec ["type" ]}
78- if spec .get ("items" ):
79- params ["schema" ]["items" ] = spec .get ("items" )
75+ if "anyOf" in spec :
76+ params ["schema" ]["anyOf" ] = spec ["anyOf" ]
77+ elif "oneOf" in spec :
78+ params ["schema" ]["oneOf" ] = spec ["oneOf" ]
79+ elif "type" in spec :
80+ params ["schema" ]["type" ] = spec ["type" ]
81+ if spec .get ("nullable" , False ):
82+ if "type" in params ["schema" ]:
83+ params ["schema" ]["type" ] = ["null" , params ["schema" ]["type" ]]
84+ elif "anyOf" in params ["schema" ]:
85+ params ["schema" ]["anyOf" ].append ({"type" : "null" })
86+ elif "oneOf" in params ["schema" ]:
87+ params ["schema" ]["oneOf" ].append ({"type" : "null" })
88+
8089 if "enum" in spec :
8190 params ["schema" ]["enum" ] = spec ["enum" ]
8291
8392 parameters .append (params )
8493
85- if spec [ "type" ] == "array" :
94+ if spec . get ( "type" ) == "array" :
8695 # To correctly handle array into the url query string,
8796 # the name must ends with []
8897 params ["name" ] = params ["name" ] + "[]"
0 commit comments