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