avrotize 2.20.5__tar.gz → 2.21.0__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.
- {avrotize-2.20.5 → avrotize-2.21.0}/PKG-INFO +1 -1
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/_version.py +3 -3
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp.py +2 -2
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo/go_helpers.jinja +5 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo/go_test.jinja +6 -2
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo.py +9 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/test_class.jinja +3 -6
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython.py +20 -1
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/class_core.ts.jinja +13 -1
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/package.json.jinja +4 -1
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/test_class.ts.jinja +3 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots.py +82 -22
- {avrotize-2.20.5 → avrotize-2.21.0}/LICENSE +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/README.md +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/__init__.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/__main__.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/asn1toavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotize.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp/CMakeLists.txt.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp/build.bat.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp/build.sh.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp/dataclass_body.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp/vcpkg.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocpp.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/README.md.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/class_test.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/dataclass_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/enum_test.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/project.csproj.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/project.sln.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/run_coverage.ps1.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/run_coverage.sh.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp/testproject.csproj.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsharp.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotocsv.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotodatapackage.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotodb.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo/go_enum.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo/go_helpers.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo/go_struct.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo/go_test.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo/go_union.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotogo.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotographql.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotoiceberg.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojava/class_test.java.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojava/enum_test.java.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojava/testproject.pom.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojava.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojs.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojsons.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotojstruct.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotokusto.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotomd/README.md.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotomd.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotools.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotoparquet.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotoproto.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython/dataclass_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython/enum_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython/pyproject_toml.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython/test_class.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython/test_enum.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotopython.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotorust/dataclass_enum.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotorust/dataclass_struct.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotorust/dataclass_union.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotorust.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/class_core.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/class_test.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/enum_core.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/gitignore.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/index.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/package.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots/tsconfig.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotots.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/avrotoxsd.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/cddltostructure.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/commands.json +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/common.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/constants.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/csvtoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/datapackagetoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/cpp/vcpkg/vcpkg.json +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/cs/net90/dependencies.csproj +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/go/go121/go.mod +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/java/jdk21/pom.xml +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/python/py312/requirements.txt +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/rust/stable/Cargo.toml +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependencies/typescript/node22/package.json +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependency_resolver.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/dependency_version.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/generic/generic.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/jsonstoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/jsonstostructure.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/jstructtoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/kstructtoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/kustotoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/openapitostructure.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/parquettoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/proto2parser.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/proto3parser.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/any.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/api.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/duration.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/field_mask.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/struct.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/timestamp.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/type.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/prototypes/wrappers.avsc +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocddl.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp/CMakeLists.txt.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp/build.bat.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp/build.sh.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp/dataclass_body.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp/vcpkg.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocpp.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/class_test.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/dataclass_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/enum_test.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/json_structure_converters.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/program.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/project.csproj.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/project.sln.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/testproject.csproj.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/tuple_converter.cs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsv.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretodatapackage.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretodb.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo/go_enum.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo/go_interface.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretogo/go_struct.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretographql.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretoiceberg.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/choice_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/class_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/enum_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/equals_hashcode.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/pom.xml.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava/tuple_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojava.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/class_core.js.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/enum_core.js.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/package.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/test_class.js.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/test_enum.js.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs/test_runner.js.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojs.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretojsons.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretokusto.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretomd/README.md.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretomd.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretoproto.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/dataclass_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/enum_core.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/map_alias.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/pyproject_toml.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretopython/test_enum.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretorust/dataclass_enum.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretorust/dataclass_struct.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretorust/dataclass_union.rs.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretorust.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/enum_core.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/gitignore.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/index.ts.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretots/tsconfig.json.jinja +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretoxsd.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/avrotize/xsdtoavro.py +0 -0
- {avrotize-2.20.5 → avrotize-2.21.0}/pyproject.toml +0 -0
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '2.
|
|
32
|
-
__version_tuple__ = version_tuple = (2,
|
|
31
|
+
__version__ = version = '2.21.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 21, 0)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g1df522119'
|
|
@@ -2072,8 +2072,8 @@ class StructureToCSharp:
|
|
|
2072
2072
|
if enum_values:
|
|
2073
2073
|
for value in enum_values:
|
|
2074
2074
|
if isinstance(value, str):
|
|
2075
|
-
# Convert to PascalCase enum member name
|
|
2076
|
-
symbol_name =
|
|
2075
|
+
# Convert to PascalCase enum member name - must match generate_enum logic
|
|
2076
|
+
symbol_name = pascal(str(value).replace('-', '_').replace(' ', '_'))
|
|
2077
2077
|
symbols.append(symbol_name)
|
|
2078
2078
|
else:
|
|
2079
2079
|
# For numeric enums, use Value1, Value2, etc.
|
|
@@ -2,16 +2,16 @@ package {{ base_package }}
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"testing"
|
|
5
|
-
{%- if json_annotation %}
|
|
5
|
+
{%- if json_annotation and kind == 'struct' %}
|
|
6
6
|
"encoding/json"
|
|
7
7
|
{%- endif %}
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
func Test{{ struct_name }}(t *testing.T) {
|
|
11
11
|
{%- if kind == 'struct' %}
|
|
12
|
+
{%- if json_annotation %}
|
|
12
13
|
instance := CreateInstance{{ struct_name }}()
|
|
13
14
|
|
|
14
|
-
{%- if json_annotation %}
|
|
15
15
|
// Test JSON marshaling
|
|
16
16
|
data, err := json.Marshal(&instance)
|
|
17
17
|
if err != nil {
|
|
@@ -56,6 +56,10 @@ func Test{{ struct_name }}(t *testing.T) {
|
|
|
56
56
|
if fromDataGzip == nil {
|
|
57
57
|
t.Fatal("FromData with gzip returned nil")
|
|
58
58
|
}
|
|
59
|
+
{%- else %}
|
|
60
|
+
// Basic instance creation test (no JSON serialization without json annotation)
|
|
61
|
+
instance := CreateInstance{{ struct_name }}()
|
|
62
|
+
_ = instance // Verify instance creation works
|
|
59
63
|
{%- endif %}
|
|
60
64
|
{%- elif kind == 'enum' %}
|
|
61
65
|
// Test enum values
|
|
@@ -523,6 +523,10 @@ class StructureToGo:
|
|
|
523
523
|
v = f'float64({random.uniform(-100, 100)})'
|
|
524
524
|
elif go_type == '[]byte':
|
|
525
525
|
v = '[]byte("' + ''.join(random.choices(string.ascii_letters + string.digits, k=10)) + '")'
|
|
526
|
+
elif go_type == 'time.Time':
|
|
527
|
+
v = 'time.Now()'
|
|
528
|
+
elif go_type == 'time.Duration':
|
|
529
|
+
v = 'time.Hour'
|
|
526
530
|
elif go_type.startswith('[]'):
|
|
527
531
|
inner_type = go_type[2:]
|
|
528
532
|
v = f'{go_type}{{{self.random_value(inner_type)}}}'
|
|
@@ -549,10 +553,15 @@ class StructureToGo:
|
|
|
549
553
|
'enums': self.enums,
|
|
550
554
|
'base_package': self.base_package,
|
|
551
555
|
}
|
|
556
|
+
needs_time_import = False
|
|
552
557
|
for struct in context['structs']:
|
|
553
558
|
for field in struct['fields']:
|
|
554
559
|
if 'value' not in field:
|
|
555
560
|
field['value'] = self.random_value(field['type'])
|
|
561
|
+
# Check if time package is needed
|
|
562
|
+
if 'time.Time' in field['type'] or 'time.Duration' in field['type']:
|
|
563
|
+
needs_time_import = True
|
|
564
|
+
context['needs_time_import'] = needs_time_import
|
|
556
565
|
helpers_file_name = os.path.join(self.output_dir, 'pkg', self.base_package, f"{self.base_package}_helpers.go")
|
|
557
566
|
render_template('structuretogo/go_helpers.jinja', helpers_file_name, **context)
|
|
558
567
|
|
|
@@ -11,12 +11,9 @@ sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), '../src
|
|
|
11
11
|
from {{ package_name | lower }} import {{ class_name }}
|
|
12
12
|
|
|
13
13
|
{%- for import_type in import_types if import_type not in ['decimal.Decimal', 'datetime.datetime', 'datetime.date', 'datetime.time', 'datetime.timedelta', 'uuid.UUID'] %}
|
|
14
|
-
{%- set import_type_name =
|
|
15
|
-
{%- set import_package_name = '
|
|
16
|
-
|
|
17
|
-
{%- if import_type.startswith('.') %}
|
|
18
|
-
from .{{ import_package_name }} import {{ import_type_name }}
|
|
19
|
-
{%- else %}
|
|
14
|
+
{%- set import_type_name = import_type.split('.')[-1] %}
|
|
15
|
+
{%- set import_package_name = '.'.join(import_type.split('.')[:-1]) | lower %}
|
|
16
|
+
{%- if import_package_name %}
|
|
20
17
|
from {{ import_package_name }} import {{ import_type_name }}
|
|
21
18
|
{%- endif -%}
|
|
22
19
|
{%- endfor %}
|
|
@@ -39,6 +39,7 @@ class StructureToPython:
|
|
|
39
39
|
self.schema_doc: JsonNode = None
|
|
40
40
|
self.generated_types: Dict[str, str] = {}
|
|
41
41
|
self.generated_structure_types: Dict[str, Dict[str, Union[str, Dict, List]]] = {}
|
|
42
|
+
self.generated_enum_symbols: Dict[str, List[str]] = {}
|
|
42
43
|
self.type_dict: Dict[str, Dict] = {}
|
|
43
44
|
self.definitions: Dict[str, Any] = {}
|
|
44
45
|
self.schema_registry: Dict[str, Dict] = {}
|
|
@@ -445,6 +446,7 @@ class StructureToPython:
|
|
|
445
446
|
self.generate_test_enum(namespace, class_name, symbols)
|
|
446
447
|
|
|
447
448
|
self.generated_types[python_qualified_name] = 'enum'
|
|
449
|
+
self.generated_enum_symbols[python_qualified_name] = symbols
|
|
448
450
|
return python_qualified_name
|
|
449
451
|
|
|
450
452
|
def generate_choice(self, structure_schema: Dict, parent_namespace: str,
|
|
@@ -596,7 +598,24 @@ class StructureToPython:
|
|
|
596
598
|
elif field_type.startswith('typing.Union['):
|
|
597
599
|
field_type = resolve(field_type)
|
|
598
600
|
return generate_value(field_type)
|
|
599
|
-
|
|
601
|
+
if field_type in test_values:
|
|
602
|
+
return test_values[field_type]
|
|
603
|
+
# Check if this is an enum type - use first symbol value
|
|
604
|
+
# Look up by fully qualified name or by short name (class name only)
|
|
605
|
+
enum_symbols = None
|
|
606
|
+
if field_type in self.generated_enum_symbols:
|
|
607
|
+
enum_symbols = self.generated_enum_symbols[field_type]
|
|
608
|
+
else:
|
|
609
|
+
# Try to find by short name (the field type might be just the class name)
|
|
610
|
+
for qualified_name, symbols in self.generated_enum_symbols.items():
|
|
611
|
+
if qualified_name.endswith('.' + field_type) or qualified_name == field_type:
|
|
612
|
+
enum_symbols = symbols
|
|
613
|
+
break
|
|
614
|
+
if enum_symbols:
|
|
615
|
+
return f"{field_type.split('.')[-1]}.{enum_symbols[0]}"
|
|
616
|
+
# For complex types, use None since fields are typically optional
|
|
617
|
+
# This avoids needing to construct nested objects with required args
|
|
618
|
+
return 'None'
|
|
600
619
|
|
|
601
620
|
return generate_value(field_type)
|
|
602
621
|
|
|
@@ -19,7 +19,7 @@ export {% if is_abstract %}abstract {% endif %}class {{ class_name }}{% if base_
|
|
|
19
19
|
/** {{ field.docstring }} */
|
|
20
20
|
{%- if typedjson_annotation %}
|
|
21
21
|
{%- set field_type = field.type_no_null %}
|
|
22
|
-
@jsonMember({{ field_type if not field.is_primitive else 'String' if field_type == 'Date' else field_type | capitalize }})
|
|
22
|
+
@jsonMember({{ 'String' if field.is_enum else (field_type if not field.is_primitive else 'String' if field_type == 'Date' else field_type | capitalize) }})
|
|
23
23
|
{%- endif %}
|
|
24
24
|
public {{ field.name }}{% if field.is_optional %}?{% endif %}: {{ field.type_no_null }};
|
|
25
25
|
{%- endfor %}
|
|
@@ -63,4 +63,16 @@ export {% if is_abstract %}abstract {% endif %}class {{ class_name }}{% if base_
|
|
|
63
63
|
return result;
|
|
64
64
|
}
|
|
65
65
|
{%- endif %}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates an instance of {{ class_name }} with sample data for testing.
|
|
69
|
+
* @returns A new {{ class_name }} instance with sample values.
|
|
70
|
+
*/
|
|
71
|
+
public static createInstance(): {{ class_name }} {
|
|
72
|
+
return new {{ class_name }}(
|
|
73
|
+
{%- for field in required_fields %}
|
|
74
|
+
{{ field.test_value }}{% if not loop.last %},{% endif %} // {{ field.name }}
|
|
75
|
+
{%- endfor %}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
66
78
|
}
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { {{ class_name }} } from '../src/{{ relative_path }}';
|
|
6
|
+
{%- for enum_type, enum_path in enum_imports.items() %}
|
|
7
|
+
import { {{ enum_type }} } from '{{ enum_path }}';
|
|
8
|
+
{%- endfor %}
|
|
6
9
|
|
|
7
10
|
describe('{{ class_name }}', () => {
|
|
8
11
|
it('should create an instance with required fields', () => {
|
|
@@ -332,15 +332,25 @@ class StructureToTypeScript:
|
|
|
332
332
|
class_name, prop_name, prop_schema, namespace, import_types)
|
|
333
333
|
is_required = prop_name in required_props
|
|
334
334
|
is_optional = not is_required
|
|
335
|
+
field_type_no_null = self.strip_nullable(field_type)
|
|
336
|
+
|
|
337
|
+
# Check if the field type is an enum
|
|
338
|
+
is_enum = False
|
|
339
|
+
for import_type in import_types:
|
|
340
|
+
if import_type.endswith('.' + field_type_no_null) or import_type == field_type_no_null:
|
|
341
|
+
if import_type in self.generated_types and self.generated_types[import_type] == 'enum':
|
|
342
|
+
is_enum = True
|
|
343
|
+
break
|
|
335
344
|
|
|
336
345
|
fields.append({
|
|
337
346
|
'name': self.safe_name(prop_name),
|
|
338
347
|
'original_name': prop_name,
|
|
339
348
|
'type': field_type,
|
|
340
|
-
'type_no_null':
|
|
349
|
+
'type_no_null': field_type_no_null,
|
|
341
350
|
'is_required': is_required,
|
|
342
351
|
'is_optional': is_optional,
|
|
343
|
-
'is_primitive': self.is_typescript_primitive(
|
|
352
|
+
'is_primitive': self.is_typescript_primitive(field_type_no_null.replace('[]', '')),
|
|
353
|
+
'is_enum': is_enum,
|
|
344
354
|
'docstring': prop_schema.get('description', '') if isinstance(prop_schema, dict) else ''
|
|
345
355
|
})
|
|
346
356
|
|
|
@@ -359,6 +369,11 @@ class StructureToTypeScript:
|
|
|
359
369
|
relative_import_path = f'./{relative_import_path}'
|
|
360
370
|
imports_with_paths[import_type_name] = relative_import_path + '.js'
|
|
361
371
|
|
|
372
|
+
# Prepare required fields with test values for createInstance()
|
|
373
|
+
required_fields = [f for f in fields if f.get('is_required', not f.get('is_optional', False))]
|
|
374
|
+
for field in required_fields:
|
|
375
|
+
field['test_value'] = self.generate_test_value(field)
|
|
376
|
+
|
|
362
377
|
# Generate class definition using template
|
|
363
378
|
class_definition = process_template(
|
|
364
379
|
"structuretots/class_core.ts.jinja",
|
|
@@ -368,6 +383,7 @@ class StructureToTypeScript:
|
|
|
368
383
|
is_abstract=is_abstract,
|
|
369
384
|
docstring=structure_schema.get('description', '').strip() if 'description' in structure_schema else f'A {class_name} class.',
|
|
370
385
|
fields=fields,
|
|
386
|
+
required_fields=required_fields,
|
|
371
387
|
imports=imports_with_paths,
|
|
372
388
|
typedjson_annotation=self.typedjson_annotation,
|
|
373
389
|
)
|
|
@@ -522,17 +538,36 @@ class StructureToTypeScript:
|
|
|
522
538
|
if field_type.startswith('{ [key: string]:'):
|
|
523
539
|
return '{}'
|
|
524
540
|
|
|
525
|
-
#
|
|
526
|
-
|
|
541
|
+
# Handle enums - use first value with Object.values()
|
|
542
|
+
if field.get('is_enum', False):
|
|
543
|
+
return f'Object.values({field_type})[0] as {field_type}'
|
|
544
|
+
|
|
545
|
+
# Return test value for primitives, or call createInstance() for complex types (classes)
|
|
546
|
+
return test_values.get(field_type, f'{field_type}.createInstance()')
|
|
527
547
|
|
|
528
548
|
def generate_test_class(self, namespace: str, class_name: str, fields: List[Dict[str, Any]]) -> None:
|
|
529
549
|
"""Generates a unit test class for a TypeScript class"""
|
|
530
550
|
# Get only required fields for the test
|
|
531
551
|
required_fields = [f for f in fields if f['is_required']]
|
|
532
552
|
|
|
553
|
+
# Collect enum imports needed for test file
|
|
554
|
+
enum_imports: Dict[str, str] = {}
|
|
555
|
+
|
|
533
556
|
# Generate test values for required fields
|
|
534
557
|
for field in required_fields:
|
|
535
558
|
field['test_value'] = self.generate_test_value(field)
|
|
559
|
+
# Check if this field is an enum and needs an import
|
|
560
|
+
if field.get('is_enum', False):
|
|
561
|
+
enum_type = field['type_no_null']
|
|
562
|
+
# Find the enum in generated_types to get its full path
|
|
563
|
+
for qualified_name, type_kind in self.generated_types.items():
|
|
564
|
+
if type_kind == 'enum' and qualified_name.endswith('.' + enum_type):
|
|
565
|
+
# Build import path - lowercase namespace like write_to_file does
|
|
566
|
+
parts = qualified_name.split('.')
|
|
567
|
+
enum_namespace = '.'.join(parts[:-1]).lower()
|
|
568
|
+
enum_import_path = enum_namespace.replace('.', '/') + '/' + enum_type
|
|
569
|
+
enum_imports[enum_type] = f'../src/{enum_import_path}'
|
|
570
|
+
break
|
|
536
571
|
|
|
537
572
|
# Determine relative path from test directory to src
|
|
538
573
|
namespace_path = namespace.replace('.', '/') if namespace else ''
|
|
@@ -545,7 +580,8 @@ class StructureToTypeScript:
|
|
|
545
580
|
"structuretots/test_class.ts.jinja",
|
|
546
581
|
class_name=class_name,
|
|
547
582
|
required_fields=required_fields,
|
|
548
|
-
relative_path=relative_path
|
|
583
|
+
relative_path=relative_path,
|
|
584
|
+
enum_imports=enum_imports
|
|
549
585
|
)
|
|
550
586
|
|
|
551
587
|
# Write test file
|
|
@@ -589,17 +625,30 @@ class StructureToTypeScript:
|
|
|
589
625
|
f.write(gitignore)
|
|
590
626
|
|
|
591
627
|
def generate_index(self) -> None:
|
|
592
|
-
""" Generates index.ts that exports all generated types """
|
|
628
|
+
""" Generates index.ts that exports all generated types with aliased exports """
|
|
593
629
|
exports = []
|
|
594
630
|
for qualified_name, type_kind in self.generated_types.items():
|
|
595
|
-
|
|
596
|
-
|
|
631
|
+
# Split the qualified_name into parts
|
|
632
|
+
parts = qualified_name.split('.')
|
|
633
|
+
type_name = parts[-1] # The actual type name
|
|
634
|
+
namespace = '.'.join(parts[:-1]) # The namespace excluding the type
|
|
635
|
+
|
|
636
|
+
# Construct the relative path to the .js file
|
|
597
637
|
if namespace:
|
|
598
638
|
# Lowercase the namespace to match the directory structure created by write_to_file
|
|
599
639
|
relative_path = namespace.lower().replace('.', '/') + '/' + type_name
|
|
600
640
|
else:
|
|
601
641
|
relative_path = type_name
|
|
602
|
-
|
|
642
|
+
|
|
643
|
+
if not relative_path.startswith('./'):
|
|
644
|
+
relative_path = './' + relative_path
|
|
645
|
+
|
|
646
|
+
# Construct the alias name by joining all parts with underscores (PascalCase)
|
|
647
|
+
alias_parts = [pascal(part) for part in parts]
|
|
648
|
+
alias_name = '_'.join(alias_parts)
|
|
649
|
+
|
|
650
|
+
# Generate the export statement with alias (like avrotots does)
|
|
651
|
+
exports.append(f"export {{ {type_name} as {alias_name} }} from '{relative_path}.js';")
|
|
603
652
|
|
|
604
653
|
index_content = '\n'.join(exports) + '\n' if exports else ''
|
|
605
654
|
|
|
@@ -619,23 +668,34 @@ class StructureToTypeScript:
|
|
|
619
668
|
self.convert_schema(schema, output_dir, package_name)
|
|
620
669
|
|
|
621
670
|
def convert_schema(self, schema: JsonNode, output_dir: str, package_name: str = '') -> None:
|
|
622
|
-
""" Converts a JSON Structure schema to TypeScript classes """
|
|
671
|
+
""" Converts a JSON Structure schema (or list of schemas) to TypeScript classes """
|
|
672
|
+
# Normalize to list
|
|
673
|
+
if not isinstance(schema, list):
|
|
674
|
+
schema = [schema]
|
|
675
|
+
|
|
623
676
|
self.output_dir = output_dir
|
|
624
677
|
self.schema_doc = schema
|
|
625
678
|
|
|
626
|
-
# Register schema IDs
|
|
627
|
-
|
|
679
|
+
# Register schema IDs for all schemas
|
|
680
|
+
for s in schema:
|
|
681
|
+
if isinstance(s, dict):
|
|
682
|
+
self.register_schema_ids(s)
|
|
628
683
|
|
|
629
|
-
# Process
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
684
|
+
# Process each schema
|
|
685
|
+
for s in schema:
|
|
686
|
+
if not isinstance(s, dict):
|
|
687
|
+
continue
|
|
688
|
+
|
|
689
|
+
# Process definitions
|
|
690
|
+
if 'definitions' in s:
|
|
691
|
+
for def_name, def_schema in s['definitions'].items():
|
|
692
|
+
if isinstance(def_schema, dict):
|
|
693
|
+
self.generate_class_or_choice(def_schema, '', write_file=True, explicit_name=def_name)
|
|
694
|
+
|
|
695
|
+
# Process root schema if it's an object or choice
|
|
696
|
+
if 'type' in s:
|
|
697
|
+
root_namespace = s.get('namespace', '')
|
|
698
|
+
self.generate_class_or_choice(s, root_namespace, write_file=True)
|
|
639
699
|
|
|
640
700
|
# Generate project files
|
|
641
701
|
self.generate_package_json(package_name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{avrotize-2.20.5 → avrotize-2.21.0}/avrotize/structuretocsharp/json_structure_converters.cs.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|