← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~lloydwaltersj/maas:oapi-include-more-methods into maas:master

 

Jack Lloyd-Walters has proposed merging ~lloydwaltersj/maas:oapi-include-more-methods into maas:master.

Commit message:
Modify OpenApi method generation to capture all method types

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~lloydwaltersj/maas/+git/maas/+merge/438116
-- 
Your team MAAS Maintainers is requested to review the proposed merge of ~lloydwaltersj/maas:oapi-include-more-methods into maas:master.
diff --git a/src/maasserver/api/doc_oapi.py b/src/maasserver/api/doc_oapi.py
index e252bbc..1ae81d5 100644
--- a/src/maasserver/api/doc_oapi.py
+++ b/src/maasserver/api/doc_oapi.py
@@ -218,28 +218,29 @@ def _oapi_item_from_docstring(
                 param["options"]["required"].lower() == "true"
                 or name != param["name"]
             )
-            if param["name"][0] == "{":
-                param_dict = {
-                    "name": name,
-                    "in": "path" if name in uri_params else "query",
-                    "description": description,
-                    "schema": {
-                        "type": _type_to_string(param["type"]),
-                    },
-                    "required": required,
-                }
-                oper_obj.setdefault("parameters", []).append(param_dict)
-            elif http_method.lower() in ("put", "post"):
-                body.setdefault("properties", {}).update(
-                    {
-                        name: {
-                            "description": description,
+            match http_method.lower():
+                case "get" | "delete":
+                    param_dict = {
+                        "name": name,
+                        "in": "path" if name in uri_params else "query",
+                        "description": description,
+                        "schema": {
                             "type": _type_to_string(param["type"]),
-                        }
+                        },
+                        "required": required,
                     }
-                )
-                if required:
-                    body.setdefault("required", []).append(name)
+                    oper_obj.setdefault("parameters", []).append(param_dict)
+                case "put" | "post":
+                    body.setdefault("properties", {}).update(
+                        {
+                            name: {
+                                "description": description,
+                                "type": _type_to_string(param["type"]),
+                            }
+                        }
+                    )
+                    if required:
+                        body.setdefault("required", []).append(name)
 
         for status, content in _response_pair(ap_dict):
             response = {

Follow ups