Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified generator to generate default value for parameters in description #519

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Modified generator to generate 'options' and 'default value' for para…
…meters in description

Signed-off-by: saimedhi <saimedhi@amazon.com>
  • Loading branch information
saimedhi committed Oct 2, 2023
commit b4ea39f71f5265a44c994d026bdba80152577c83
7 changes: 7 additions & 0 deletions utils/generate-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ def read_modules():

for m in params:
A = dict(type=m["schema"]["type"], description=m["description"])

if "default" in m["schema"]:
A.update({"default": m["schema"]["default"]})

if "enum" in m["schema"]:
A.update({"type": "enum"})
A.update({"options": m["schema"]["enum"]})
Expand All @@ -508,6 +512,9 @@ def read_modules():
if "description" in n:
B.update({"description": n["description"]})

if "x-enum-options" in n["schema"]:
B.update({"options": n["schema"]["x-enum-options"]})

deprecated_new = {}
if "deprecated" in n:
B.update({"deprecated": n["deprecated"]})
Expand Down
3 changes: 2 additions & 1 deletion utils/templates/base
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

{% for p, info in api.params %}
{% filter wordwrap(72, wrapstring="\n ") %}
:arg {{ p }}{% if info.deprecated %} (Deprecated: {{ info['deprecation_message'][:-1] }}){% endif %}: {{ info.description }}{% if info.options %} Valid choices: {{ info.options|join(", ") }}{% endif %}{% if info.default %} Default: {{ info.default }}{% endif %}
:arg {{ p }}{% if info.deprecated %} (Deprecated: {{ info['deprecation_message'][:-1] }}){% endif %}: {{ info.description }}{% if info.options %} Valid choices: {{ info.options|join(", ") }}{% endif %}
{% if info.default is defined %}{% if info.default is not none %}{% if info.default is sameas(false) %} (default: false){% else %} (default: {{ info.default }}){% endif %}{% endif %}{% endif %}
{% endfilter %}

{% endfor %}
Expand Down
Loading