Merge "Improve support for array with prefixItems"
This commit is contained in:
2 changed files with 27 additions and 1 deletions
@@ -650,8 +650,22 @@ class JsonSchemaParser:
ignore_read_only: bool | None = False,
):
# todo: decide whether some constraints can be under items
items_schema = schema.get("items")
if not items_schema:
prefix_items = schema.get("prefixItems")
if prefix_items:
if isinstance(prefix_items, list):
if len(prefix_items) == 1:
items_schema = prefix_items[0]
else:
raise ValueError(
"prefixItems must be a single item for now"
)
else:
# is it what we really want?
items_schema = {"type": "string"}
item_type = self.parse_schema(
schema.get("items", {"type": "string"}),
items_schema,
results,
name=name,
ignore_read_only=ignore_read_only,
@@ -411,6 +411,18 @@ Some({{ val }})
{{ dst_var }}.{{ param.remote_name }}(
{{ val_var }}{{ ".iter()" if not by_ref else ".iter().cloned()" }}
);
{%- elif param.data_type.item_type.__class__.__name__ == "StringEnum" %}
{{ dst_var }}.{{ param.remote_name }}(
{{ val_var }}
.iter()
.map(|x| match x {
{%- for variant in param.data_type.item_type.variants.keys() | sort %}
{{ param.data_type.item_type.name }}::{{ variant }} => {{ sdk_mod_path[-1] }}::{{ param.data_type.item_type.name }}::{{ variant }},
{%- endfor %}
})
.collect::<Vec<_>>(),
);
{%- elif original_item_type and original_item_type.__class__.__name__ == "DictionaryInput" %}
use std::collections::BTreeMap;
{{ dst_var }}.{{ param.remote_name }}(
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.