Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from gtema/dev
Browse files Browse the repository at this point in the history
feat: diverse improvements
  • Loading branch information
gtema authored Mar 11, 2024
2 parents 88269de + e38c35f commit 290cab1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions codegenerator/rust_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def clap_macros(self):
macros.update(self.additional_clap_macros)
except Exception as ex:
logging.exception("Error getting clap_macros for %s: %s", self, ex)

macros.add('help_heading = "Body parameters"')
return f"#[arg({', '.join(sorted(macros))})]"

def clap_macros_ext(self, is_group: bool | None = None):
Expand All @@ -174,6 +176,7 @@ def clap_macros_ext(self, is_group: bool | None = None):
macros.update(self.additional_clap_macros)
except Exception as ex:
logging.exception("Error getting clap_macros for %s: %s", self, ex)
macros.add('help_heading = "Body parameters"')
return f"#[arg({', '.join(sorted(macros))})]"


Expand Down Expand Up @@ -403,8 +406,10 @@ def clap_macros(self):
# the value_name is turned back to the expected value
macros.add(f'id = "path_param_{self.local_name}"')
macros.add(f'value_name = "{self.local_name.upper()}"')
macros.add('help_heading = "Path parameters"')
elif self.location == "query":
macros.update(self.data_type.clap_macros)
macros.add('help_heading = "Query parameters"')
if hasattr(self.data_type, "enum") and self.data_type.enum:
values = ",".join(f'"{x}"' for x in sorted(self.data_type.enum))
macros.add(f"value_parser = [{values}]")
Expand Down
2 changes: 2 additions & 0 deletions codegenerator/templates/rust_cli/parameters.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{%- if type.additional_fields_type %}
/// Additional properties to be sent with the request
#[arg(long="property", value_name="key=value", value_parser=parse_key_val::<String, {{ type.additional_fields_type.type_hint }}>)]
#[arg(help_heading = "Body parameters")]
properties: Option<Vec<(String, {{ type.additional_fields_type.type_hint }})>>,
{%- endif %}

Expand All @@ -21,6 +22,7 @@
{%- else %}
#[arg(long="property", value_name="key=value", value_parser=parse_key_val_opt::<String, {{ type.value_type.item_type.type_hint }}>)]
{%- endif %}
#[arg(help_heading = "Body parameters")]
properties: Option<Vec<(String, {{ type.value_type.type_hint }})>>,

{%- endif %}
Expand Down

0 comments on commit 290cab1

Please sign in to comment.