From 2f42f68252fdeaf26623a15d2f966d5e9336b0bd Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:47:26 -0700 Subject: [PATCH] Modified generator to generate api deprecation warnings (#527) Signed-off-by: saimedhi Signed-off-by: roma2023 --- utils/generate-api.py | 4 ++++ utils/templates/base | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/utils/generate-api.py b/utils/generate-api.py index cfe12af4..2cb93eb5 100644 --- a/utils/generate-api.py +++ b/utils/generate-api.py @@ -263,6 +263,7 @@ def __init__(self, namespace, name, definition, is_pyi=False): self.description = "" self.doc_url = "" self.stability = self._def.get("stability", "stable") + self.deprecation_message = self._def.get("deprecation_message") if isinstance(definition["documentation"], str): self.doc_url = definition["documentation"] @@ -560,6 +561,9 @@ def read_modules(): documentation = {"description": z["description"]} api.update({"documentation": documentation}) + if "deprecation_message" not in api and "x-deprecation-message" in z: + api.update({"deprecation_message": z["x-deprecation-message"]}) + if "params" not in api and "params" in z: api.update({"params": z["params"]}) diff --git a/utils/templates/base b/utils/templates/base index 9b58b6c2..47bb5956 100644 --- a/utils/templates/base +++ b/utils/templates/base @@ -28,6 +28,10 @@ {% endfor %} {% endif %} """ + {% if api.deprecation_message %} + from warnings import warn + warn("Deprecated: {{ api.deprecation_message }}") + {% endif %} {% include "substitutions" %} {% include "required" %} {% if api.body.serialize == "bulk" %}