structurize 3.8.0__tar.gz → 3.9.1__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.8.0/structurize.egg-info → structurize-3.9.1}/PKG-INFO +1 -1
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/_version.py +3 -3
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotogo.py +49 -15
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotojava.py +243 -37
- structurize-3.9.1/avrotize/avrotojs.py +375 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotopython.py +58 -8
- structurize-3.9.1/avrotize/avrotorust.py +2482 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotots.py +86 -11
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/commands.json +181 -12
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/common.py +43 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/constants.py +5 -0
- structurize-3.9.1/avrotize/rust_xml.py +21 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretogo.py +34 -7
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretojava.py +276 -15
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretojs.py +123 -17
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretopython.py +65 -7
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretorust.py +214 -12
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretots.py +90 -5
- {structurize-3.8.0 → structurize-3.9.1/structurize.egg-info}/PKG-INFO +1 -1
- {structurize-3.8.0 → structurize-3.9.1}/structurize.egg-info/SOURCES.txt +11 -0
- structurize-3.8.0/avrotize/avrotojs.py +0 -254
- structurize-3.8.0/avrotize/avrotorust.py +0 -486
- {structurize-3.8.0 → structurize-3.9.1}/.gitignore +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/LICENSE +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/MANIFEST.in +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/README.md +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/__init__.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/__main__.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/asn1toavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotize.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoasn1.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotocapnproto.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotocpp.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotocsharp.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotocsv.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotocue.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotodatapackage.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotodb.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoflatbuffers.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotographql.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoiceberg.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotojsons.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotojstruct.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotojtd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotokusto.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotomd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotools.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoparquet.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoproto.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoraml.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotosmithy.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotosurreal.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotothrift.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrototsml.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrotoxsd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/avrovalidator.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/capnprototoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/cddltostructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/choice_inference.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/csvtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/cuetoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/cuetostructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/datapackagetoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/dependencies/cpp/vcpkg/vcpkg.json +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/dependencies/typescript/node22/package.json +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/dependency_resolver.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/dependency_version.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/flatbufferstoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/flatbufferstojstruct.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jsonstoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jsonstostructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jsontoschema.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jstructtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jstructtoflatbuffers.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jstructtoraml.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jstructtosmithy.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jtdtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/jtdtostructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/kstructtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/kustotoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/kustotojstruct.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/mcp_server.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/openapitostructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/parquettoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/proto2parser.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/proto3parser.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/prototoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/ramltoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/ramltojstruct.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/schema_inference.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/smithytoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/smithytojstruct.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/sqltoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretoasn1.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretocddl.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretocpp.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretocsharp.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretocsv.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretocue.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretodatapackage.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretodb.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretographql.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretoiceberg.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretojsons.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretojtd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretokusto.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretomd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretoparquet.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretoproto.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretotsml.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/structuretoxsd.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/surrealtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/thriftstructure.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/thrifttoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/tmslvalidate.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/validate.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/xmltoschema.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/avrotize/xsdtoavro.py +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/build.ps1 +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/build.sh +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/pyproject.toml +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/setup.cfg +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/structurize.egg-info/dependency_links.txt +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/structurize.egg-info/entry_points.txt +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/structurize.egg-info/requires.txt +0 -0
- {structurize-3.8.0 → structurize-3.9.1}/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.
|
|
3
|
+
Version: 3.9.1
|
|
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.
|
|
22
|
-
__version_tuple__ = version_tuple = (3,
|
|
21
|
+
__version__ = version = '3.9.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (3, 9, 1)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'gd2cba4eb3'
|
|
@@ -1,7 +1,8 @@
|
|
|
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, is_any_value_type, pascal,
|
|
4
|
+
from avrotize.common import (get_longest_namespace_prefix, is_generic_avro_type, is_any_value_type, pascal,
|
|
5
|
+
render_template, format_go_files, xml_wire_name, xml_enum_wire_value)
|
|
5
6
|
|
|
6
7
|
INDENT = ' '
|
|
7
8
|
|
|
@@ -26,6 +27,7 @@ class AvroToGo:
|
|
|
26
27
|
self.referenced_packages_stack: List[Dict[str, Set[str]]] = []
|
|
27
28
|
self.avro_annotation = False
|
|
28
29
|
self.json_annotation = False
|
|
30
|
+
self.xml_annotation = False
|
|
29
31
|
self.longest_common_prefix = ''
|
|
30
32
|
self.package_site = 'github.com'
|
|
31
33
|
self.package_username = 'username'
|
|
@@ -126,9 +128,8 @@ class AvroToGo:
|
|
|
126
128
|
return f"[]{item_type}"
|
|
127
129
|
elif avro_type['type'] == 'map':
|
|
128
130
|
values_type = self.convert_avro_type_to_go(field_name, avro_type['values'], nullable=True, parent_namespace=parent_namespace)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return f"map[string]{values_type}"
|
|
131
|
+
map_type = f"map[string]{values_type}"
|
|
132
|
+
return f"XMLMap[{values_type}]" if self.xml_annotation else map_type
|
|
132
133
|
elif 'logicalType' in avro_type:
|
|
133
134
|
if avro_type['logicalType'] == 'date':
|
|
134
135
|
return 'time.Time'
|
|
@@ -171,11 +172,20 @@ class AvroToGo:
|
|
|
171
172
|
self.generated_types_avro_namespace[avro_fullname] = "struct"
|
|
172
173
|
self.generated_types_go_package[go_struct_name] = "struct"
|
|
173
174
|
|
|
174
|
-
fields = [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
fields = []
|
|
176
|
+
for field in avro_schema.get('fields', []):
|
|
177
|
+
field_type = self.convert_avro_type_to_go(field['name'], field['type'], parent_namespace=namespace)
|
|
178
|
+
raw_type = field['type']
|
|
179
|
+
fields.append({
|
|
180
|
+
'name': pascal(field['name']),
|
|
181
|
+
'type': field_type,
|
|
182
|
+
'original_name': field['name'],
|
|
183
|
+
'xml_name': xml_wire_name(field['name'], field),
|
|
184
|
+
'xml_kind': field.get('xmlkind', 'element'),
|
|
185
|
+
'xml_required': not (isinstance(raw_type, list) and 'null' in raw_type) and not (isinstance(raw_type, dict) and raw_type.get('type') in ('array', 'map')),
|
|
186
|
+
'xml_repeated': isinstance(raw_type, dict) and raw_type.get('type') == 'array',
|
|
187
|
+
'xml_ambiguous': field_type.lstrip('*') == 'interface{}',
|
|
188
|
+
})
|
|
179
189
|
|
|
180
190
|
# Collect imports from field types
|
|
181
191
|
go_types = [f['type'] for f in fields]
|
|
@@ -187,6 +197,10 @@ class AvroToGo:
|
|
|
187
197
|
'fields': fields,
|
|
188
198
|
'avro_schema': json.dumps(avro_schema),
|
|
189
199
|
'json_annotation': self.json_annotation,
|
|
200
|
+
'xml_annotation': self.xml_annotation,
|
|
201
|
+
'xml_name': xml_wire_name(avro_schema['name'], avro_schema),
|
|
202
|
+
'xml_namespace': avro_schema.get('xmlns', ''),
|
|
203
|
+
'needs_xml_name': bool(avro_schema.get('xmlns')) or xml_wire_name(avro_schema['name'], avro_schema) != go_struct_name,
|
|
190
204
|
'avro_annotation': self.avro_annotation,
|
|
191
205
|
'json_match_predicates': [self.get_is_json_match_clause(f['name'], f['type']) for f in fields],
|
|
192
206
|
'base_package': self.base_package,
|
|
@@ -223,9 +237,14 @@ class AvroToGo:
|
|
|
223
237
|
context = {
|
|
224
238
|
'doc': avro_schema.get('doc', ''),
|
|
225
239
|
'struct_name': enum_name,
|
|
226
|
-
'symbols':
|
|
240
|
+
'symbols': [
|
|
241
|
+
{'name': symbol, 'xml_value': xml_enum_wire_value(symbol, avro_schema)}
|
|
242
|
+
for symbol in avro_schema.get('symbols', [])
|
|
243
|
+
],
|
|
227
244
|
'imports': imports,
|
|
228
245
|
'base_package': self.base_package,
|
|
246
|
+
'xml_annotation': self.xml_annotation,
|
|
247
|
+
'string_enum': self.avro_annotation,
|
|
229
248
|
'referenced_packages': self.referenced_packages.keys()
|
|
230
249
|
}
|
|
231
250
|
|
|
@@ -238,9 +257,10 @@ class AvroToGo:
|
|
|
238
257
|
self.enums.append({
|
|
239
258
|
'name': enum_name,
|
|
240
259
|
'symbols': avro_schema.get('symbols', []),
|
|
260
|
+
'string_enum': self.avro_annotation,
|
|
241
261
|
})
|
|
242
262
|
|
|
243
|
-
self.generate_unit_test('enum', enum_name,
|
|
263
|
+
self.generate_unit_test('enum', enum_name, avro_schema.get('symbols', []))
|
|
244
264
|
|
|
245
265
|
return enum_name
|
|
246
266
|
|
|
@@ -256,6 +276,7 @@ class AvroToGo:
|
|
|
256
276
|
'union_class_name': union_class_name,
|
|
257
277
|
'union_types': union_types,
|
|
258
278
|
'json_annotation': self.json_annotation,
|
|
279
|
+
'xml_annotation': self.xml_annotation,
|
|
259
280
|
'avro_annotation': self.avro_annotation,
|
|
260
281
|
'get_is_json_match_clause': self.get_is_json_match_clause,
|
|
261
282
|
'base_package': self.base_package,
|
|
@@ -303,14 +324,14 @@ class AvroToGo:
|
|
|
303
324
|
return f"if _, ok := node[\"{field_name}\"].([]byte); !ok {{ return false }}"
|
|
304
325
|
elif field_type == 'interface{}':
|
|
305
326
|
return f"if _, ok := node[\"{field_name}\"].(interface{{}}); !ok {{ return false }}"
|
|
306
|
-
elif field_type.startswith('map[string]'):
|
|
327
|
+
elif field_type.startswith('map[string]') or field_type.startswith('XMLMap['):
|
|
307
328
|
return f"if _, ok := node[\"{field_name}\"].(map[string]interface{{}}); !ok {{ return false }}"
|
|
308
329
|
elif field_type.startswith('[]'):
|
|
309
330
|
return f"if _, ok := node[\"{field_name}\"].([]interface{{}}); !ok {{ return false }}"
|
|
310
331
|
elif field_type in self.generated_types_go_package:
|
|
311
332
|
return f"if _, ok := node[\"{field_name}\"].({field_type}); !ok {{ return false }}"
|
|
312
333
|
else:
|
|
313
|
-
return f"if _, ok := node[\"{field_name}\"].(map[string
|
|
334
|
+
return f"if _, ok := node[\"{field_name}\"].(map[string]interface{{}}); !ok {{ return false }}"
|
|
314
335
|
|
|
315
336
|
def get_imports_for_definition(self, types: List[str]) -> Set[str]:
|
|
316
337
|
"""Collects necessary imports for the Go definition based on the Go types"""
|
|
@@ -402,6 +423,7 @@ class AvroToGo:
|
|
|
402
423
|
'package_site': self.package_site,
|
|
403
424
|
'package_username': self.package_username,
|
|
404
425
|
'json_annotation': self.json_annotation,
|
|
426
|
+
'xml_annotation': self.xml_annotation,
|
|
405
427
|
'avro_annotation': self.avro_annotation
|
|
406
428
|
}
|
|
407
429
|
|
|
@@ -427,8 +449,16 @@ class AvroToGo:
|
|
|
427
449
|
self.write_go_mod_file()
|
|
428
450
|
self.write_modname_go_file()
|
|
429
451
|
self.generate_helpers()
|
|
452
|
+
self.write_xml_helpers()
|
|
430
453
|
format_go_files(self.output_dir)
|
|
431
454
|
|
|
455
|
+
def write_xml_helpers(self) -> None:
|
|
456
|
+
"""Write generic XML support for map fields."""
|
|
457
|
+
if not self.xml_annotation:
|
|
458
|
+
return
|
|
459
|
+
helper_path = os.path.join(self.output_dir, 'pkg', self.base_package, 'xml_helpers.go')
|
|
460
|
+
render_template('avrotogo/xml_helpers.jinja', helper_path, base_package=self.base_package)
|
|
461
|
+
|
|
432
462
|
def write_go_mod_file(self):
|
|
433
463
|
"""Writes the go.mod file for the Go project"""
|
|
434
464
|
go_mod_content = ""
|
|
@@ -463,7 +493,7 @@ class AvroToGo:
|
|
|
463
493
|
self.convert_schema(schema, output_dir)
|
|
464
494
|
|
|
465
495
|
|
|
466
|
-
def convert_avro_to_go(avro_schema_path, go_file_path, package_name='', avro_annotation=False, json_annotation=False, package_site='github.com', package_username='username'):
|
|
496
|
+
def convert_avro_to_go(avro_schema_path, go_file_path, package_name='', avro_annotation=False, json_annotation=False, xml_annotation=False, package_site='github.com', package_username='username'):
|
|
467
497
|
"""Converts Avro schema to Go structs
|
|
468
498
|
|
|
469
499
|
Args:
|
|
@@ -472,6 +502,7 @@ def convert_avro_to_go(avro_schema_path, go_file_path, package_name='', avro_ann
|
|
|
472
502
|
package_name (str): Base package name
|
|
473
503
|
avro_annotation (bool): Include Avro annotations
|
|
474
504
|
json_annotation (bool): Include JSON annotations
|
|
505
|
+
xml_annotation (bool): Include XML annotations and serialization
|
|
475
506
|
"""
|
|
476
507
|
if not package_name:
|
|
477
508
|
package_name = os.path.splitext(os.path.basename(avro_schema_path))[0]
|
|
@@ -479,12 +510,13 @@ def convert_avro_to_go(avro_schema_path, go_file_path, package_name='', avro_ann
|
|
|
479
510
|
avrotogo = AvroToGo(package_name)
|
|
480
511
|
avrotogo.avro_annotation = avro_annotation
|
|
481
512
|
avrotogo.json_annotation = json_annotation
|
|
513
|
+
avrotogo.xml_annotation = xml_annotation
|
|
482
514
|
avrotogo.package_site = package_site if package_site else 'github.com'
|
|
483
515
|
avrotogo.package_username = package_username if package_username else 'username'
|
|
484
516
|
avrotogo.convert(avro_schema_path, go_file_path)
|
|
485
517
|
|
|
486
518
|
|
|
487
|
-
def convert_avro_schema_to_go(avro_schema: JsonNode, output_dir: str, package_name='', avro_annotation=False, json_annotation=False, package_site='github.com', package_username='username'):
|
|
519
|
+
def convert_avro_schema_to_go(avro_schema: JsonNode, output_dir: str, package_name='', avro_annotation=False, json_annotation=False, xml_annotation=False, package_site='github.com', package_username='username'):
|
|
488
520
|
"""Converts Avro schema to Go structs
|
|
489
521
|
|
|
490
522
|
Args:
|
|
@@ -493,10 +525,12 @@ def convert_avro_schema_to_go(avro_schema: JsonNode, output_dir: str, package_na
|
|
|
493
525
|
package_name (str): Base package name
|
|
494
526
|
avro_annotation (bool): Include Avro annotations
|
|
495
527
|
json_annotation (bool): Include JSON annotations
|
|
528
|
+
xml_annotation (bool): Include XML annotations and serialization
|
|
496
529
|
"""
|
|
497
530
|
avrotogo = AvroToGo(package_name)
|
|
498
531
|
avrotogo.avro_annotation = avro_annotation
|
|
499
532
|
avrotogo.json_annotation = json_annotation
|
|
533
|
+
avrotogo.xml_annotation = xml_annotation
|
|
500
534
|
avrotogo.package_site = package_site if package_site else 'github.com'
|
|
501
535
|
avrotogo.package_username = package_username if package_username else 'username'
|
|
502
536
|
avrotogo.convert_schema(avro_schema, output_dir)
|