← Back to team overview

sts-sponsors team mailing list archive

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

 


Diff comments:

> diff --git a/src/maasserver/api/doc_oapi.py b/src/maasserver/api/doc_oapi.py
> index e252bbc..39ebf71 100644
> --- a/src/maasserver/api/doc_oapi.py
> +++ b/src/maasserver/api/doc_oapi.py
> @@ -214,32 +214,31 @@ def _oapi_item_from_docstring(
>          for param in ap_dict["params"]:
>              description = _prettify(param["description_stripped"])
>              name = param["name"].strip("}{")
> +            path_var = "{" in param["name"]
>              required = (
>                  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: {
> +            match http_method.lower():
> +                case "get" | "delete":
> +                    param_dict = {
> +                        "name": name,
> +                        "in": "path" if name in uri_params else "query",

"path" if path_var else "query" ?

> +                        "description": description,
> +                        "schema": {
> +                            "type": _type_to_string(param["type"]),
> +                        },
> +                        "required": required,
> +                    }
> +                    oper_obj.setdefault("parameters", []).append(param_dict)
> +                case "put" | "post":
> +                    if not path_var:
> +                        body.setdefault("properties", {})[name] = {
>                              "description": description,
>                              "type": _type_to_string(param["type"]),
>                          }
> -                    }
> -                )
> -                if required:
> -                    body.setdefault("required", []).append(name)
> +                        if required:
> +                            body.setdefault("required", []).append(name)
>  
>          for status, content in _response_pair(ap_dict):
>              response = {


-- 
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.



References