From f719bfecd8dca9c7af4e5d536c2148d91df36077 Mon Sep 17 00:00:00 2001 From: saimedhi Date: Mon, 9 Oct 2023 09:42:12 -0700 Subject: [PATCH] Modified generator to generate api deprecation warnings Signed-off-by: saimedhi --- 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" %}