@@ -307,6 +307,47 @@ def func(document, query_args):
307307 "query_args" : {"arg1" : "test" },
308308 }
309309
310+ @pytest .mark .parametrize ("openapi_version" , ("2.0" , "3.0.2" ))
311+ def test_blueprint_dict_arguments (self , app , schemas , openapi_version ):
312+ app .config ["OPENAPI_VERSION" ] = openapi_version
313+ api = Api (app )
314+ blp = Blueprint ("test" , __name__ , url_prefix = "/test" )
315+ client = app .test_client ()
316+
317+ @blp .route ("/" , methods = ("POST" ,))
318+ @blp .arguments (schemas .DictSchema )
319+ def func (document ):
320+ return {"document" : document }
321+
322+ api .register_blueprint (blp )
323+ spec = api .spec .to_dict ()
324+
325+ # Check parameters are documented
326+ if openapi_version == "2.0" :
327+ parameters = spec ["paths" ]["/test/" ]["post" ]["parameters" ]
328+ assert len (parameters ) == 1
329+ assert parameters [0 ]["in" ] == "body"
330+ assert "schema" in parameters [0 ]
331+ else :
332+ assert (
333+ "schema"
334+ in spec ["paths" ]["/test/" ]["post" ]["requestBody" ]["content" ][
335+ "application/json"
336+ ]
337+ )
338+
339+ # Check parameters are passed as arguments to view function
340+ item_data = {"field" : 12 }
341+ response = client .post (
342+ "/test/" ,
343+ data = json .dumps (item_data ),
344+ content_type = "application/json" ,
345+ )
346+ assert response .status_code == 200
347+ assert response .json == {
348+ "document" : {"db_field" : 12 },
349+ }
350+
310351 @pytest .mark .parametrize ("openapi_version" , ("2.0" , "3.0.2" ))
311352 def test_blueprint_arguments_files_multipart (self , app , schemas , openapi_version ):
312353 app .config ["OPENAPI_VERSION" ] = openapi_version
0 commit comments