← 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..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"]),
> +                            }
> +                        }
> +                    )

given this is adding only one key, I think you can just 

body.setdefault("properties", {})["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