Skip to content

Commit

Permalink
Modified generator to generate api deprecation warnings (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#527)

Signed-off-by: saimedhi <[email protected]>
Signed-off-by: roma2023 <[email protected]>
  • Loading branch information
saimedhi authored and roma2023 committed Dec 28, 2023
1 parent 36df6e8 commit 2f42f68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/generate-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"]})

Expand Down
4 changes: 4 additions & 0 deletions utils/templates/base
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down

0 comments on commit 2f42f68

Please sign in to comment.