diff --git a/codegenerator/model.py b/codegenerator/model.py index bb9464b..65c7e89 100644 --- a/codegenerator/model.py +++ b/codegenerator/model.py @@ -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, diff --git a/codegenerator/templates/rust_macros.j2 b/codegenerator/templates/rust_macros.j2 index 8707272..f6e7f7e 100644 --- a/codegenerator/templates/rust_macros.j2 +++ b/codegenerator/templates/rust_macros.j2 @@ -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::>(), + ); + {%- elif original_item_type and original_item_type.__class__.__name__ == "DictionaryInput" %} use std::collections::BTreeMap; {{ dst_var }}.{{ param.remote_name }}(

AltStyle によって変換されたページ (->オリジナル) /