Skip to content

Commit

Permalink
Modified generator to generate api deprecation warnings (#527)
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <[email protected]>
  • Loading branch information
saimedhi authored Oct 9, 2023
1 parent 2bfc409 commit e4c59e4
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 e4c59e4

Please sign in to comment.