Merge ~lloydwaltersj/maas:fix-broken-oapi-param-names into maas:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Jack Lloyd-Walters
Approved revision: 8c7091939380f65768da6310d689ca7212857fa8
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas:fix-broken-oapi-param-names
Merge into: maas:master
Diff against target: 39 lines (+11/-3)
1 file modified
src/maasserver/api/doc_oapi.py (+11/-3)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+438279@code.launchpad.net

Commit message

fix LP:2009140, OpenApi parameter names erroneously stripped of trailing '}'

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/2057/consoleText
COMMIT: 9f11adbcb6307054be03f1f1928e801c931420c5

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

UNIT TESTS
-b fix-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

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

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

jenkins: !test

Revision history for this message
Alberto Donato (ack) wrote :

+1

small nit inline

review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

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

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-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 3ce2d282c36063991e8ea2abb14cbe2eb26396c0

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

LANDING
-b fix-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas-tester/2062/consoleText

Revision history for this message
Adam Collard (adam-collard) wrote :

jenkins: !test

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

UNIT TESTS
-b fix-broken-oapi-param-names lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 8c7091939380f65768da6310d689ca7212857fa8

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 b7e3a9d..fba7926 100644
3--- a/src/maasserver/api/doc_oapi.py
4+++ b/src/maasserver/api/doc_oapi.py
5@@ -22,6 +22,11 @@ from maasserver.djangosettings import settings
6 from maasserver.models.config import Config
7 from maasserver.utils import build_absolute_uri
8
9+# LP 2009140: Match a par of brackets enclosing a string, return only the string within the brackets.
10+# Functions as a more context aware equivalent to string.strip("}{")
11+# ie: '{param}' returns 'param', 'param_{test}' is unnafected
12+PARAM_RE = re.compile(r"(?<=\{)\.+(?<=\})")
13+
14
15 def landing_page(request):
16 """Render a landing page with pointers for the MAAS API.
17@@ -213,8 +218,11 @@ def _oapi_item_from_docstring(
18 oper_obj["deprecated"] = True
19 for param in ap_dict["params"]:
20 description = _prettify(param["description_stripped"])
21- name = param["name"].strip("}{")
22- path_var = name in uri_params
23+ # LP 2009140
24+ stripped_name = PARAM_RE.match(param["name"])
25+ name = (
26+ param["name"] if not stripped_name else stripped_name.group()
27+ )
28 required = (
29 param["options"]["required"].lower() == "true"
30 or name != param["name"]
31@@ -223,7 +231,7 @@ def _oapi_item_from_docstring(
32 if name != param["name"]:
33 param_dict = {
34 "name": name,
35- "in": "path" if path_var else "query",
36+ "in": "path" if name in uri_params else "query",
37 "description": description,
38 "schema": {
39 "type": _type_to_string(param["type"]),

Subscribers

People subscribed via source and target branches