Merge ~lloydwaltersj/maas:fix-json-response into maas:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Jack Lloyd-Walters
Approved revision: 41bade65709cdc59b50bb2977437c3ee0a7ed93d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas:fix-json-response
Merge into: maas:master
Diff against target: 135 lines (+20/-11)
5 files modified
src/maasserver/api/doc_oapi.py (+9/-0)
src/maasserver/api/nodes.py (+1/-1)
src/maasserver/api/rackcontrollers.py (+2/-2)
src/maasserver/api/resourcepools.py (+4/-4)
src/maasserver/api/zones.py (+4/-4)
Reviewer Review Type Date Requested Status
Alexsander de Souza Approve
MAAS Lander Approve
Review via email: mp+428480@code.launchpad.net

Commit message

Update api JSON responses declared as plain text

Description of the change

we had a few JSON payloads decalred as plaintext when they shouldn't have been

To post a comment you must log in.
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

need to add the BSON mime type to _oapi_item_from_docstring()

review: Needs Fixing
b7eafdd... by Jack Lloyd-Walters

add BSON to oapi_item_from_docstring

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-json-response lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/341/consoleText
COMMIT: 6136074c7480049342c1e8483256ea17e3e1ab61

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-json-response lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/342/consoleText
COMMIT: b7eafddb0e891c31ef9409558c79949552e05dcf

review: Needs Fixing
41bade6... by Jack Lloyd-Walters

stop BSON error with rest api

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-json-response lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/345/consoleText
COMMIT: 41bade65709cdc59b50bb2977437c3ee0a7ed93d

review: Needs Fixing
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote :

jenkins: !test

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-json-response lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 41bade65709cdc59b50bb2977437c3ee0a7ed93d

review: Approve
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/doc_oapi.py b/src/maasserver/api/doc_oapi.py
2index d747499..8d49f52 100644
3--- a/src/maasserver/api/doc_oapi.py
4+++ b/src/maasserver/api/doc_oapi.py
5@@ -268,6 +268,15 @@ def _oapi_item_from_docstring(function, http_method, uri_params):
6 },
7 },
8 }
9+ case "bson":
10+ response["content"] = {
11+ "application/bson": {
12+ "schema": {
13+ "type": "object",
14+ "additionalProperties": True,
15+ },
16+ },
17+ }
18
19 status_code = status["name"]
20 if not status_code.isdigit():
21diff --git a/src/maasserver/api/nodes.py b/src/maasserver/api/nodes.py
22index f7152c0..3ff069c 100644
23--- a/src/maasserver/api/nodes.py
24+++ b/src/maasserver/api/nodes.py
25@@ -535,7 +535,7 @@ class NodeHandler(OperationsHandler):
26
27 @success (http-status-code) "200" 200
28
29- @success (content) "success-content" A BSON object represented here in
30+ @success (json) "success-content" A BSON object represented here in
31 ASCII using ``bsondump example.bson``.
32 @success-example "success-content" [exkey=details] placeholder text
33
34diff --git a/src/maasserver/api/rackcontrollers.py b/src/maasserver/api/rackcontrollers.py
35index 71710fb..2dce645 100644
36--- a/src/maasserver/api/rackcontrollers.py
37+++ b/src/maasserver/api/rackcontrollers.py
38@@ -157,7 +157,7 @@ class RackControllerHandler(NodeHandler, PowerMixin):
39 controller. If not given the default domain is used.
40
41 @success (http-status-code) "200" 200
42- @success (content) "success-json" A JSON object containing the updated
43+ @success (json) "success-json" A JSON object containing the updated
44 rack-controller object.
45 @success-example "success-json" [exkey=update] placeholder
46
47@@ -280,7 +280,7 @@ class RackControllersHandler(NodesHandler, PowersMixin):
48 @description Queries all rack controllers for power information.
49
50 @success (http-status-code) "200" 200
51- @success (content) "success-json" A JSON object containing a dictionary
52+ @success (json) "success-json" A JSON object containing a dictionary
53 with system_ids as keys and power parameters as values.
54 @success-example "success-json" [exkey=power-params-multi] placeholder
55 """
56diff --git a/src/maasserver/api/resourcepools.py b/src/maasserver/api/resourcepools.py
57index a28c6fd..2b37f3f 100644
58--- a/src/maasserver/api/resourcepools.py
59+++ b/src/maasserver/api/resourcepools.py
60@@ -45,7 +45,7 @@ class ResourcePoolHandler(ModelOperationsHandler):
61 @param-example "{id}" mypool
62
63 @success (http-status-code) "server_success" 200
64- @success (content) "content_success" A JSON object containing
65+ @success (json) "content_success" A JSON object containing
66 resource pool information
67 @success-example "content_success"
68 {
69@@ -80,7 +80,7 @@ class ResourcePoolHandler(ModelOperationsHandler):
70 description.
71
72 @success (http-status-code) "serversuccess" 200
73- @success (content) "contentsuccess" A JSON object containing details
74+ @success (json) "contentsuccess" A JSON object containing details
75 about your new resource pool.
76 @success-example "contentsuccess"
77 {
78@@ -147,7 +147,7 @@ class ResourcePoolsHandler(ModelCollectionOperationsHandler):
79 of my new resource pool.
80
81 @success (http-status-code) "serversuccess" 200
82- @success (content) "contentsuccess" A JSON object containing details
83+ @success (json) "contentsuccess" A JSON object containing details
84 about your new resource pool.
85 @success-example "contentsuccess"
86 {
87@@ -170,7 +170,7 @@ class ResourcePoolsHandler(ModelCollectionOperationsHandler):
88 Note that there is always at least one resource pool: default.
89
90 @success (http-status-code) "serversuccess" 200
91- @success (content) "contentsuccess" A JSON object containing a
92+ @success (json) "contentsuccess" A JSON object containing a
93 list of resource pools.
94 @success-example "contentsuccess"
95 [
96diff --git a/src/maasserver/api/zones.py b/src/maasserver/api/zones.py
97index 698caab..a3fafae 100644
98--- a/src/maasserver/api/zones.py
99+++ b/src/maasserver/api/zones.py
100@@ -50,7 +50,7 @@ class ZoneHandler(ModelOperationsHandler):
101 @param-example "{name}" myzone
102
103 @success (http-status-code) "server_success" 200
104- @success (content) "content_success" A JSON object containing zone
105+ @success (json) "content_success" A JSON object containing zone
106 information
107 @success-example "content_success"
108 {
109@@ -82,7 +82,7 @@ class ZoneHandler(ModelOperationsHandler):
110 @param-example "description" An updated zone description.
111
112 @success (http-status-code) "serversuccess" 200
113- @success (content) "contentsuccess" A JSON object containing details
114+ @success (json) "contentsuccess" A JSON object containing details
115 about your new zone.
116 @success-example "contentsuccess"
117 {
118@@ -138,7 +138,7 @@ class ZonesHandler(ModelCollectionOperationsHandler):
119 new zone.
120
121 @success (http-status-code) "serversuccess" 204
122- @success (content) "contentsuccess" A JSON object containing details
123+ @success (json) "contentsuccess" A JSON object containing details
124 about your new zone.
125 @success-example "contentsuccess"
126 {
127@@ -160,7 +160,7 @@ class ZonesHandler(ModelCollectionOperationsHandler):
128 at least one zone: default.
129
130 @success (http-status-code) "serversuccess" 200
131- @success (content) "contentsuccess" A JSON object containing a list
132+ @success (json) "contentsuccess" A JSON object containing a list
133 of zones.
134 @success-example "contentsuccess"
135 [

Subscribers

People subscribed via source and target branches