diff --git a/api_generator/api_generator/generators/python/python_entities.py b/api_generator/api_generator/generators/python/python_entities.py index d959dc17a..2ae9fd453 100644 --- a/api_generator/api_generator/generators/python/python_entities.py +++ b/api_generator/api_generator/generators/python/python_entities.py @@ -269,6 +269,8 @@ class PythonPropertyType(PropertyType): return True if isinstance(self, (Color, String, Url)): return True + if isinstance(self, (PythonRawArray,)): + return True if isinstance(self, Object): if isinstance(self.object, StringEnumeration): return True diff --git a/api_generator/tests/references/python/entity_with_raw_array.py b/api_generator/tests/references/python/entity_with_raw_array.py index e8241a5e0..0bc0760a0 100644 --- a/api_generator/tests/references/python/entity_with_raw_array.py +++ b/api_generator/tests/references/python/entity_with_raw_array.py @@ -11,7 +11,7 @@ class EntityWithRawArray(BaseDiv): def __init__( self, *, type: str = 'entity_with_raw_array', - array: typing.Optional[typing.Sequence[typing.Any]] = None, + array: typing.Optional[typing.Union[Expr, typing.Sequence[typing.Any]]] = None, **kwargs: typing.Any, ): super().__init__( @@ -21,7 +21,7 @@ class EntityWithRawArray(BaseDiv): ) type: str = Field(default='entity_with_raw_array') - array: typing.Sequence[typing.Any] = Field( + array: typing.Union[Expr, typing.Sequence[typing.Any]] = Field( ) diff --git a/json-builder/python/pydivkit/core/entities.py b/json-builder/python/pydivkit/core/entities.py index 3e0b4fece..dd5e3bfa8 100644 --- a/json-builder/python/pydivkit/core/entities.py +++ b/json-builder/python/pydivkit/core/entities.py @@ -187,6 +187,7 @@ BUILTIN_TYPES_TO_SCHEMA: Mapping[type, Mapping[str, Any]] = MappingProxyType( str: MappingProxyType({"type": "string"}), bytes: MappingProxyType({"type": "string"}), Expr: MappingProxyType({"type": "string", "pattern": "^@{.*}$"}), + Any: MappingProxyType({}), }, ) @@ -271,7 +272,7 @@ def _field_to_schema( elif issubclass(type_, enum.Enum): schema = _enum_to_schema(type_) - if not schema: + if schema is None: raise TypeError(f"Schema building error for unknown type {type_}") if field: