structurize 3.5.8__tar.gz → 3.5.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {structurize-3.5.8/structurize.egg-info → structurize-3.5.10}/PKG-INFO +1 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/_version.py +3 -3
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotocpp.py +6 -3
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotogo.py +4 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotojava.py +8 -4
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotojs.py +4 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotojsons.py +5 -2
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotojstruct.py +4 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotoproto.py +6 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotopython.py +4 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotorust.py +17 -4
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotots.py +4 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotoxsd.py +3 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/common.py +318 -29
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/jsonstoavro.py +3 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/jstructtoavro.py +17 -10
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretocpp.py +53 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretogo.py +11 -1
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretojava.py +10 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretopython.py +10 -2
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretorust.py +10 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretots.py +13 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/xsdtoavro.py +2 -1
- {structurize-3.5.8 → structurize-3.5.10/structurize.egg-info}/PKG-INFO +1 -1
- {structurize-3.5.8 → structurize-3.5.10}/.gitignore +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/LICENSE +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/MANIFEST.in +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/README.md +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/__init__.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/__main__.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/asn1toavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotize.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotocsharp.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotocsv.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotodatapackage.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotodb.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotographql.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotoiceberg.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotokusto.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotomd.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotools.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrotoparquet.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrototsml.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/avrovalidator.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/cddltostructure.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/choice_inference.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/commands.json +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/constants.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/csvtoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/datapackagetoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/dependencies/cpp/vcpkg/vcpkg.json +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/dependencies/typescript/node22/package.json +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/dependency_resolver.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/dependency_version.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/jsonstostructure.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/jsontoschema.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/kstructtoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/kustotoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/kustotojstruct.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/mcp_server.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/openapitostructure.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/parquettoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/proto2parser.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/proto3parser.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/prototoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/schema_inference.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/sqltoavro.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretocddl.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretocsharp.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretocsv.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretodatapackage.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretodb.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretographql.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretoiceberg.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretojs.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretojsons.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretokusto.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretomd.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretoproto.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretotsml.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/structuretoxsd.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/tmslvalidate.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/validate.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/avrotize/xmltoschema.py +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/build.ps1 +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/build.sh +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/pyproject.toml +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/setup.cfg +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/structurize.egg-info/SOURCES.txt +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/structurize.egg-info/dependency_links.txt +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/structurize.egg-info/entry_points.txt +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/structurize.egg-info/requires.txt +0 -0
- {structurize-3.5.8 → structurize-3.5.10}/structurize.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: structurize
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.10
|
|
4
4
|
Summary: Tools to convert from and to JSON Structure from various other schema languages.
|
|
5
5
|
Author-email: Clemens Vasters <clemensv@microsoft.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '3.5.
|
|
22
|
-
__version_tuple__ = version_tuple = (3, 5,
|
|
21
|
+
__version__ = version = '3.5.10'
|
|
22
|
+
__version_tuple__ = version_tuple = (3, 5, 10)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g974039ac5'
|
|
@@ -5,7 +5,7 @@ import json
|
|
|
5
5
|
import os
|
|
6
6
|
from typing import Dict, List, Union
|
|
7
7
|
|
|
8
|
-
from avrotize.common import is_generic_avro_type, pascal, process_template
|
|
8
|
+
from avrotize.common import is_generic_avro_type, is_any_value_type, pascal, process_template
|
|
9
9
|
|
|
10
10
|
INDENT = ' '
|
|
11
11
|
|
|
@@ -45,6 +45,9 @@ class AvroToCpp:
|
|
|
45
45
|
|
|
46
46
|
def map_primitive_to_cpp(self, avro_type: str, is_optional: bool) -> str:
|
|
47
47
|
"""Maps Avro primitive types to C++ types"""
|
|
48
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
49
|
+
if is_any_value_type(avro_type):
|
|
50
|
+
return 'std::optional<nlohmann::json>' if is_optional else 'nlohmann::json'
|
|
48
51
|
optional_mapping = {
|
|
49
52
|
'null': 'std::optional<std::monostate>',
|
|
50
53
|
'boolean': 'std::optional<bool>',
|
|
@@ -53,7 +56,7 @@ class AvroToCpp:
|
|
|
53
56
|
'float': 'std::optional<float>',
|
|
54
57
|
'double': 'std::optional<double>',
|
|
55
58
|
'bytes': 'std::optional<std::vector<uint8_t>>',
|
|
56
|
-
'string': 'std::optional<std::string>'
|
|
59
|
+
'string': 'std::optional<std::string>',
|
|
57
60
|
}
|
|
58
61
|
required_mapping = {
|
|
59
62
|
'null': 'std::monostate',
|
|
@@ -63,7 +66,7 @@ class AvroToCpp:
|
|
|
63
66
|
'float': 'float',
|
|
64
67
|
'double': 'double',
|
|
65
68
|
'bytes': 'std::vector<uint8_t>',
|
|
66
|
-
'string': 'std::string'
|
|
69
|
+
'string': 'std::string',
|
|
67
70
|
}
|
|
68
71
|
if '.' in avro_type:
|
|
69
72
|
type_name = avro_type.split('.')[-1]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
from typing import Dict, List, Union, Set
|
|
4
|
-
from avrotize.common import get_longest_namespace_prefix, is_generic_avro_type, pascal, render_template
|
|
4
|
+
from avrotize.common import get_longest_namespace_prefix, is_generic_avro_type, is_any_value_type, pascal, render_template
|
|
5
5
|
|
|
6
6
|
INDENT = ' '
|
|
7
7
|
|
|
@@ -55,6 +55,9 @@ class AvroToGo:
|
|
|
55
55
|
|
|
56
56
|
def map_primitive_to_go(self, avro_type: str, is_optional: bool) -> str:
|
|
57
57
|
"""Maps Avro primitive types to Go types"""
|
|
58
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
59
|
+
if is_any_value_type(avro_type):
|
|
60
|
+
return 'interface{}'
|
|
58
61
|
optional_mapping = {
|
|
59
62
|
'null': 'interface{}',
|
|
60
63
|
'boolean': '*bool',
|
|
@@ -7,7 +7,7 @@ from typing import Dict, List, Tuple, Union
|
|
|
7
7
|
from avrotize.constants import (AVRO_VERSION, JACKSON_ANNOTATIONS_VERSION, JACKSON_VERSION,
|
|
8
8
|
JDK_VERSION, JUNIT_VERSION, MAVEN_COMPILER_VERSION, MAVEN_SUREFIRE_VERSION)
|
|
9
9
|
|
|
10
|
-
from avrotize.common import pascal, camel, is_generic_avro_type, inline_avro_references, build_flat_type_dict
|
|
10
|
+
from avrotize.common import pascal, camel, is_generic_avro_type, is_any_value_type, inline_avro_references, build_flat_type_dict
|
|
11
11
|
|
|
12
12
|
INDENT = ' '
|
|
13
13
|
POM_CONTENT = """<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -296,6 +296,9 @@ class AvroToJava:
|
|
|
296
296
|
|
|
297
297
|
def map_primitive_to_java(self, avro_type: str, is_optional: bool) -> JavaType:
|
|
298
298
|
"""Maps Avro primitive types to Java types"""
|
|
299
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
300
|
+
if is_any_value_type(avro_type):
|
|
301
|
+
return AvroToJava.JavaType('Object')
|
|
299
302
|
optional_mapping = {
|
|
300
303
|
'null': 'Void',
|
|
301
304
|
'boolean': 'Boolean',
|
|
@@ -1314,9 +1317,10 @@ class AvroToJava:
|
|
|
1314
1317
|
|
|
1315
1318
|
union_variable_name = self.safe_identifier(union_variable_name, class_name)
|
|
1316
1319
|
|
|
1317
|
-
# Constructor for each type
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
+
# Constructor for each type (skip Object to avoid duplicate with the generic Object constructor)
|
|
1321
|
+
if union_type.type_name != 'Object':
|
|
1322
|
+
class_definition_ctors += \
|
|
1323
|
+
f"{INDENT*1}public {union_class_name}({union_type.type_name} {union_variable_name}) {{\n{INDENT*2}this._{camel(union_variable_name)} = {union_variable_name};\n{INDENT*1}}}\n"
|
|
1320
1324
|
|
|
1321
1325
|
# Declarations
|
|
1322
1326
|
class_definition_decls += \
|
|
@@ -5,6 +5,7 @@ import os
|
|
|
5
5
|
from typing import Any, Dict, List, Set, Union
|
|
6
6
|
|
|
7
7
|
from avrotize.common import pascal
|
|
8
|
+
from avrotize.common import is_any_value_type
|
|
8
9
|
|
|
9
10
|
INDENT = ' ' * 4
|
|
10
11
|
|
|
@@ -34,6 +35,9 @@ class AvroToJavaScript:
|
|
|
34
35
|
|
|
35
36
|
def map_primitive_to_javascript(self, avro_type: str) -> str:
|
|
36
37
|
""" Map Avro primitive type to TypeScript type """
|
|
38
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
39
|
+
if is_any_value_type(avro_type):
|
|
40
|
+
return 'any'
|
|
37
41
|
mapping = {
|
|
38
42
|
'null': 'null',
|
|
39
43
|
'boolean': 'boolean',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import json
|
|
3
3
|
from typing import Dict, Any, Union, List
|
|
4
|
-
from avrotize.common import build_tree_hash_list, group_by_hash, is_generic_json_type, NodeHashReference
|
|
4
|
+
from avrotize.common import build_tree_hash_list, group_by_hash, is_any_value_type, is_generic_json_type, NodeHashReference
|
|
5
5
|
from functools import reduce
|
|
6
6
|
import jsonpath_ng
|
|
7
7
|
|
|
@@ -141,8 +141,11 @@ class AvroToJsonSchemaConverter:
|
|
|
141
141
|
'double': {'type': 'number', 'format': 'double'},
|
|
142
142
|
'bytes': {'type': 'string', 'contentEncoding': 'base64'},
|
|
143
143
|
'string': {'type': 'string'},
|
|
144
|
-
'fixed': {'type': 'string'} # Could specify length in a format or a separate attribute
|
|
144
|
+
'fixed': {'type': 'string'}, # Could specify length in a format or a separate attribute
|
|
145
145
|
}
|
|
146
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
147
|
+
if isinstance(avro_type, str) and is_any_value_type(avro_type):
|
|
148
|
+
return {}
|
|
146
149
|
type_ref = mapping.get(avro_type, '') # Defaulting to string type for any unknown types
|
|
147
150
|
if not type_ref:
|
|
148
151
|
raise ValueError(f"Avro schema contains unexpected type {avro_type}")
|
|
@@ -2,6 +2,8 @@ import json
|
|
|
2
2
|
import uuid
|
|
3
3
|
from typing import Any, Dict, List, Union
|
|
4
4
|
|
|
5
|
+
from avrotize.common import is_any_value_type
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
class AvroToJsonStructure:
|
|
7
9
|
"""
|
|
@@ -220,6 +222,8 @@ class AvroToJsonStructure:
|
|
|
220
222
|
|
|
221
223
|
# ------------------ STRING (primitive or reference) --------------
|
|
222
224
|
if isinstance(avro_type_schema, str):
|
|
225
|
+
if is_any_value_type(avro_type_schema):
|
|
226
|
+
return {"type": "any"}
|
|
223
227
|
if avro_type_schema in self.get_primitive_types():
|
|
224
228
|
return {"type": self.get_primitive_types()[avro_type_schema]}
|
|
225
229
|
# Named type reference
|
|
@@ -4,6 +4,8 @@ import argparse
|
|
|
4
4
|
import os
|
|
5
5
|
from typing import Literal, NamedTuple, Dict, Any, List
|
|
6
6
|
|
|
7
|
+
from avrotize.common import is_any_value_type
|
|
8
|
+
|
|
7
9
|
indent = ' '
|
|
8
10
|
|
|
9
11
|
Comment = NamedTuple('Comment', [('content', str), ('tags', Dict[str, Any])])
|
|
@@ -39,6 +41,10 @@ class AvroToProto:
|
|
|
39
41
|
'bytes': 'bytes',
|
|
40
42
|
'string': 'string',
|
|
41
43
|
}
|
|
44
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
45
|
+
if isinstance(avro_type, str) and is_any_value_type(avro_type):
|
|
46
|
+
dependencies.append('google/protobuf/any.proto')
|
|
47
|
+
return 'google.protobuf.Any'
|
|
42
48
|
# logical types require special handling
|
|
43
49
|
if isinstance(avro_type, dict) and 'logicalType' in avro_type:
|
|
44
50
|
logical_type = avro_type['logicalType']
|
|
@@ -8,7 +8,7 @@ import os
|
|
|
8
8
|
import re
|
|
9
9
|
import random
|
|
10
10
|
from typing import Dict, List, Set, Tuple, Union, Any
|
|
11
|
-
from avrotize.common import fullname, get_typing_args_from_string, is_generic_avro_type, pascal, process_template, build_flat_type_dict, inline_avro_references, is_type_with_alternate, strip_alternate_type
|
|
11
|
+
from avrotize.common import fullname, get_typing_args_from_string, is_generic_avro_type, is_any_value_type, pascal, process_template, build_flat_type_dict, inline_avro_references, is_type_with_alternate, strip_alternate_type
|
|
12
12
|
|
|
13
13
|
INDENT = ' '
|
|
14
14
|
|
|
@@ -145,6 +145,9 @@ class AvroToPython:
|
|
|
145
145
|
}
|
|
146
146
|
if is_generic_avro_type(avro_type):
|
|
147
147
|
return True, 'typing.Any'
|
|
148
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
149
|
+
if isinstance(avro_type, str) and is_any_value_type(avro_type):
|
|
150
|
+
return True, 'typing.Any'
|
|
148
151
|
mapped = mapping.get(avro_type, None)
|
|
149
152
|
if mapped:
|
|
150
153
|
return True, mapped
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
from typing import Dict, List, Union
|
|
4
|
-
from avrotize.common import is_generic_avro_type, render_template, pascal, camel, snake
|
|
4
|
+
from avrotize.common import is_generic_avro_type, is_any_value_type, render_template, pascal, camel, snake
|
|
5
5
|
|
|
6
6
|
INDENT = ' '
|
|
7
7
|
|
|
@@ -44,6 +44,9 @@ class AvroToRust:
|
|
|
44
44
|
|
|
45
45
|
def map_primitive_to_rust(self, avro_fullname: str, is_optional: bool) -> str:
|
|
46
46
|
"""Maps Avro primitive types to Rust types"""
|
|
47
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
48
|
+
if is_any_value_type(avro_fullname):
|
|
49
|
+
return 'Option<serde_json::Value>' if is_optional else 'serde_json::Value'
|
|
47
50
|
optional_mapping = {
|
|
48
51
|
'null': 'None',
|
|
49
52
|
'boolean': 'Option<bool>',
|
|
@@ -279,15 +282,25 @@ class AvroToRust:
|
|
|
279
282
|
|
|
280
283
|
# Track seen predicates to identify structurally identical variants
|
|
281
284
|
seen_predicates: set = set()
|
|
285
|
+
# Track seen variant names to deduplicate
|
|
286
|
+
seen_names: dict = {}
|
|
282
287
|
union_fields = []
|
|
283
288
|
for i, t in enumerate(union_types):
|
|
284
289
|
predicate = self.get_is_json_match_clause(field_name, t, for_union=True)
|
|
285
290
|
# Mark if this is the first variant with this predicate structure
|
|
286
|
-
# Subsequent variants with same predicate can't be distinguished during JSON deserialization
|
|
287
291
|
is_first_with_predicate = predicate not in seen_predicates
|
|
288
292
|
seen_predicates.add(predicate)
|
|
293
|
+
|
|
294
|
+
# Deduplicate variant names
|
|
295
|
+
variant_name = pascal(t.rsplit('::',1)[-1])
|
|
296
|
+
if variant_name in seen_names:
|
|
297
|
+
seen_names[variant_name] += 1
|
|
298
|
+
variant_name = f"{variant_name}{seen_names[variant_name]}"
|
|
299
|
+
else:
|
|
300
|
+
seen_names[variant_name] = 1
|
|
301
|
+
|
|
289
302
|
union_fields.append({
|
|
290
|
-
'name':
|
|
303
|
+
'name': variant_name,
|
|
291
304
|
'type': t,
|
|
292
305
|
'random_value': self.generate_random_value(t),
|
|
293
306
|
'default_value': 'Default::default()',
|
|
@@ -379,7 +392,7 @@ class AvroToRust:
|
|
|
379
392
|
dependencies = []
|
|
380
393
|
if self.serde_annotation or self.avro_annotation:
|
|
381
394
|
dependencies.append('serde = { version = "1.0", features = ["derive"] }')
|
|
382
|
-
|
|
395
|
+
dependencies.append('serde_json = "1.0"')
|
|
383
396
|
dependencies.append('chrono = { version = "0.4", features = ["serde"] }')
|
|
384
397
|
dependencies.append('uuid = { version = "1.11", features = ["serde", "v4"] }')
|
|
385
398
|
if self.avro_annotation or self.serde_annotation:
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
from typing import Dict, List, Set, Union
|
|
6
6
|
|
|
7
|
-
from avrotize.common import build_flat_type_dict, fullname, inline_avro_references, is_generic_avro_type, is_type_with_alternate, pascal, process_template, strip_alternate_type
|
|
7
|
+
from avrotize.common import build_flat_type_dict, fullname, inline_avro_references, is_generic_avro_type, is_any_value_type, is_type_with_alternate, pascal, process_template, strip_alternate_type
|
|
8
8
|
from numpy import full
|
|
9
9
|
|
|
10
10
|
|
|
@@ -38,6 +38,9 @@ class AvroToTypeScript:
|
|
|
38
38
|
|
|
39
39
|
def map_primitive_to_typescript(self, avro_type: str) -> str:
|
|
40
40
|
"""Map Avro primitive type to TypeScript type."""
|
|
41
|
+
# Handle AnyValue (extensible any type) regardless of namespace qualification
|
|
42
|
+
if is_any_value_type(avro_type):
|
|
43
|
+
return 'any'
|
|
41
44
|
mapping = {
|
|
42
45
|
'null': 'null',
|
|
43
46
|
'boolean': 'boolean',
|
|
@@ -5,7 +5,7 @@ import xml.etree.ElementTree as ET
|
|
|
5
5
|
from xml.etree.ElementTree import Element, SubElement, tostring
|
|
6
6
|
from xml.dom import minidom
|
|
7
7
|
|
|
8
|
-
from avrotize.common import is_generic_avro_type
|
|
8
|
+
from avrotize.common import is_generic_avro_type, is_any_value_type
|
|
9
9
|
|
|
10
10
|
class AvroToXSD:
|
|
11
11
|
def __init__(self, target_namespace: str = ''):
|
|
@@ -83,6 +83,8 @@ class AvroToXSD:
|
|
|
83
83
|
if isinstance(avro_type, dict) and 'logicalType' in avro_type and 'type' in avro_type:
|
|
84
84
|
return avro_type['type'] in {'int', 'long', 'float', 'double', 'bytes', 'string'}
|
|
85
85
|
elif isinstance(avro_type, str):
|
|
86
|
+
if is_any_value_type(avro_type):
|
|
87
|
+
return True
|
|
86
88
|
return avro_type in {'null', 'boolean', 'int', 'long', 'float', 'double', 'bytes', 'string'}
|
|
87
89
|
else:
|
|
88
90
|
return False
|