@@ -26,17 +26,9 @@ def view_to_thing_action_forms(rules: list, view: View):
26
26
27
27
# Get input content_type
28
28
content_type = getattr (view , "content_type" , "application/json" )
29
-
30
- # See if the action has an unusual 200 response
31
- responses = view .get_apispec ().get ("post" , {}).get ("responses" , {})
32
- response_content_type = "application/json" # Default assumed content_type
33
-
34
- for response_code in (200 , 201 ):
35
- if response_code in responses and responses [response_code ].get (
36
- "content_type"
37
- ):
38
- response_content_type = responses [response_code ].get ("content_type" )
39
- break
29
+ response_content_type = getattr (
30
+ view , "response_content_type" , "application/json"
31
+ )
40
32
41
33
for url in prop_urls :
42
34
form = {
@@ -46,7 +38,7 @@ def view_to_thing_action_forms(rules: list, view: View):
46
38
"contentType" : content_type ,
47
39
}
48
40
if response_content_type != content_type :
49
- form ["responses " ] = {"contentType" : response_content_type }
41
+ form ["response " ] = {"contentType" : response_content_type }
50
42
51
43
forms .append (form )
52
44
@@ -74,14 +66,6 @@ def view_to_thing_property_forms(rules: list, view: View):
74
66
# See if the property has an unusual 201 response
75
67
# TODO: Do this per-method
76
68
responses = view .get_apispec ().get ("get" , {}).get ("responses" , {})
77
- response_content_type = "application/json" # Default assumed content_type
78
-
79
- for response_code in (201 , 200 ):
80
- if response_code in responses and responses [response_code ].get ("content_type" ):
81
- response_content_type = responses [response_code ].get ("content_type" )
82
- break
83
-
84
- # TODO: Clean up repeated code
85
69
86
70
# HTTP readproperty requires GET method
87
71
if hasattr (view , "get" ):
@@ -91,10 +75,7 @@ def view_to_thing_property_forms(rules: list, view: View):
91
75
"htv:methodName" : "GET" ,
92
76
"href" : url ,
93
77
"contentType" : content_type ,
94
- "response" : {"contentType" : response_content_type },
95
78
}
96
- if response_content_type != content_type :
97
- form ["responses" ] = {"contentType" : response_content_type }
98
79
forms .append (form )
99
80
100
81
# HTTP writeproperty requires PUT method
@@ -105,10 +86,7 @@ def view_to_thing_property_forms(rules: list, view: View):
105
86
"htv:methodName" : "PUT" ,
106
87
"href" : url ,
107
88
"contentType" : content_type ,
108
- "response" : {"contentType" : response_content_type },
109
89
}
110
- if response_content_type != content_type :
111
- form ["responses" ] = {"contentType" : response_content_type }
112
90
forms .append (form )
113
91
114
92
# HTTP writeproperty may use POST method
@@ -119,10 +97,7 @@ def view_to_thing_property_forms(rules: list, view: View):
119
97
"htv:methodName" : "POST" ,
120
98
"href" : url ,
121
99
"contentType" : content_type ,
122
- "response" : {"contentType" : response_content_type },
123
100
}
124
- if response_content_type != content_type :
125
- form ["responses" ] = {"contentType" : response_content_type }
126
101
forms .append (form )
127
102
128
103
return forms
0 commit comments