File tree Expand file tree Collapse file tree 2 files changed +46
-20
lines changed
swagger_coverage_py/results_writers Expand file tree Collapse file tree 2 files changed +46
-20
lines changed Original file line number Diff line number Diff line change 55
66setup (
77 name = "swagger-coverage" ,
8- version = "2.2.12 " ,
8+ version = "2.2.13 " ,
99 author = "Jamal Zeinalov" ,
1010 author_email = "jamal.zeynalov@gmail.com" ,
1111 description = 'Python adapter for "swagger-coverage" tool' ,
Original file line number Diff line number Diff line change @@ -42,27 +42,53 @@ def _get_body_params(self):
4242 "bool" : "boolean" ,
4343 "list" : "array" ,
4444 }
45- properties = {}
46- for k , v in request_body .items ():
47- value_type = types .get (type (v ).__name__ , "object" )
48- if value_type == "string" :
49- value = urllib .parse .unquote (str (v ))
50- else :
51- value = v
52-
53- properties [k ] = {k : value , "type" : value_type }
54-
55- request_body : dict = {
56- "content" : {
57- "application/json" : {
58- "schema" : {
59- "type" : "object" ,
60- "properties" : properties
61- },
62- "example" : json .loads (self ._response .request .body )
45+ if isinstance (request_body , dict ):
46+ properties = {}
47+ for k , v in request_body .items ():
48+ value_type = types .get (type (v ).__name__ , "object" )
49+ if value_type == "string" :
50+ value = urllib .parse .unquote (str (v ))
51+ else :
52+ value = v
53+ properties [k ] = {k : value , "type" : value_type }
54+
55+ request_body : dict = {
56+ "content" : {
57+ "application/json" : {
58+ "schema" : {
59+ "type" : "object" ,
60+ "properties" : properties
61+ },
62+ "example" : json .loads (self ._response .request .body )
63+ }
64+ }
65+ }
66+ elif isinstance (request_body , list ):
67+ items_type = types .get (type (request_body [0 ]).__name__ , "object" )
68+ request_body : dict = {
69+ "content" : {
70+ "application/json" : {
71+ "schema" : {
72+ "type" : "array" ,
73+ "items" : {
74+ "type" : items_type
75+ },
76+ },
77+ "example" : json .loads (self ._response .request .body )
78+ }
79+ }
80+ }
81+ else :
82+ request_body : dict = {
83+ "content" : {
84+ "application/json" : {
85+ "schema" : {
86+ "type" : "string" ,
87+ },
88+ "example" : urllib .parse .unquote (str (self ._response .request .body ))
89+ }
6390 }
6491 }
65- }
6692 else :
6793 request_body = None
6894
You can’t perform that action at this time.
0 commit comments