Skip to content

Commit c90a646

Browse files
author
Joel Collins
committed
FIx OpenAPI formatting
1 parent db0992d commit c90a646

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

src/labthings/view/__init__.py

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,28 @@ def get_apispec(cls):
181181
}
182182
},
183183
"responses": {
184+
# Responses like images must be added as 200 responses with cls.responses = {200: {...}}
184185
200: {
185-
# Allow customising 200 (immediate response) content type
186-
"content_type": cls.response_content_type,
187186
"description": "Action completed immediately",
188-
**(
189-
# If an action JSON schema is defined, set the response schema
190-
{"schema": action_json_schema}
191-
if (action_json_schema)
192-
else {}
193-
),
187+
# Allow customising 200 (immediate response) content type
188+
"content": {
189+
cls.response_content_type: (
190+
{"schema": action_json_schema}
191+
if action_json_schema
192+
else {}
193+
)
194+
},
194195
},
195-
# Our POST 201 MUST be application/json
196-
# Responses like images must be added as 200 responses with cls.responses = {200: {...}}
197196
201: {
198-
"content_type": "application/json",
199197
"description": "Action started",
200-
**(
201-
{"schema": action_json_schema}
202-
if action_json_schema
203-
else {}
204-
),
198+
# Our POST 201 MUST be application/json
199+
"content": {
200+
"application/json": (
201+
{"schema": action_json_schema}
202+
if action_json_schema
203+
else {}
204+
)
205+
},
205206
},
206207
},
207208
},
@@ -210,12 +211,14 @@ def get_apispec(cls):
210211
# Our GET 200 MUST be application/json
211212
200: {
212213
"content_type": "application/json",
213-
"description": "Action started",
214-
**(
215-
{"schema": queue_json_schema}
216-
if queue_json_schema
217-
else {}
218-
),
214+
"description": "Action queue",
215+
"content": {
216+
"application/json": (
217+
{"schema": queue_json_schema}
218+
if queue_json_schema
219+
else {}
220+
)
221+
},
219222
}
220223
},
221224
},
@@ -304,13 +307,14 @@ def get_apispec(cls):
304307
},
305308
"responses": {
306309
200: {
307-
"content_type": cls.content_type,
310+
"content": {
311+
cls.content_type: (
312+
{"schema": class_json_schema}
313+
if class_json_schema
314+
else {}
315+
)
316+
},
308317
"description": "Write property",
309-
**(
310-
{"schema": class_json_schema}
311-
if class_json_schema
312-
else {}
313-
),
314318
}
315319
},
316320
},
@@ -323,13 +327,14 @@ def get_apispec(cls):
323327
{
324328
"responses": {
325329
200: {
326-
"content_type": "application/json",
330+
"content": {
331+
cls.content_type: (
332+
{"schema": class_json_schema}
333+
if class_json_schema
334+
else {}
335+
)
336+
},
327337
"description": "Read property",
328-
**(
329-
{"schema": class_json_schema}
330-
if class_json_schema
331-
else {}
332-
),
333338
}
334339
},
335340
},

0 commit comments

Comments
 (0)