avrotize 2.20.3__tar.gz → 2.20.4__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.3 → avrotize-2.20.4}/PKG-INFO +66 -1
- {avrotize-2.20.3 → avrotize-2.20.4}/README.md +65 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/__init__.py +2 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/_version.py +3 -3
- avrotize-2.20.4/avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize-2.20.4/avrotize/avrotocsharp/class_test.cs.jinja +266 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp/dataclass_core.jinja +67 -5
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp/project.csproj.jinja +6 -0
- avrotize-2.20.4/avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize-2.20.4/avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp/testproject.csproj.jinja +4 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp.py +121 -16
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/commands.json +168 -9
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/constants.py +15 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/cs/net90/dependencies.csproj +2 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/java/jdk21/pom.xml +1 -1
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/jsonstostructure.py +234 -12
- avrotize-2.20.4/avrotize/openapitostructure.py +717 -0
- avrotize-2.20.4/avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize-2.20.4/avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize-2.20.4/avrotize/structuretojs/package.json.jinja +12 -0
- avrotize-2.20.4/avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize-2.20.4/avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize-2.20.4/avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize-2.20.4/avrotize/structuretojs.py +657 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots.py +26 -2
- avrotize-2.20.3/avrotize/avrotocsharp/class_test.cs.jinja +0 -140
- {avrotize-2.20.3 → avrotize-2.20.4}/LICENSE +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/__main__.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/asn1toavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotize.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp/CMakeLists.txt.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp/build.bat.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp/build.sh.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp/dataclass_body.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp/vcpkg.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocpp.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp/enum_test.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsharp/project.sln.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotocsv.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotodatapackage.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotodb.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo/go_enum.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo/go_helpers.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo/go_struct.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo/go_test.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo/go_union.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotogo.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotographql.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotoiceberg.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojava/class_test.java.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojava/enum_test.java.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojava/testproject.pom.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojava.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojs.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojsons.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotojstruct.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotokusto.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotomd/README.md.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotomd.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotools.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotoparquet.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotoproto.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython/dataclass_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython/enum_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython/pyproject_toml.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython/test_class.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython/test_enum.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotopython.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotorust/dataclass_enum.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotorust/dataclass_struct.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotorust/dataclass_union.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotorust.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/class_core.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/class_test.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/enum_core.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/gitignore.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/index.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/package.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots/tsconfig.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotots.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/avrotoxsd.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/cddltostructure.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/common.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/csvtoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/datapackagetoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/cpp/vcpkg/vcpkg.json +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/go/go121/go.mod +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/python/py312/requirements.txt +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/rust/stable/Cargo.toml +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependencies/typescript/node22/package.json +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependency_resolver.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/dependency_version.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/generic/generic.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/jsonstoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/jstructtoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/kstructtoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/kustotoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/parquettoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/proto2parser.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/proto3parser.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/any.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/api.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/duration.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/field_mask.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/struct.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/timestamp.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/type.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/prototypes/wrappers.avsc +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocddl.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp/CMakeLists.txt.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp/build.bat.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp/build.sh.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp/dataclass_body.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp/vcpkg.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocpp.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/class_test.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/dataclass_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/enum_test.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/json_structure_converters.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/program.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/project.csproj.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/project.sln.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/testproject.csproj.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp/tuple_converter.cs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsharp.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretocsv.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretodatapackage.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretodb.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo/go_enum.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo/go_helpers.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo/go_interface.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo/go_struct.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo/go_test.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretogo.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretographql.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretoiceberg.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/choice_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/class_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/enum_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/equals_hashcode.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/pom.xml.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava/tuple_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojava.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretojsons.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretokusto.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretomd/README.md.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretomd.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretoproto.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/dataclass_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/enum_core.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/map_alias.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/pyproject_toml.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/test_class.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython/test_enum.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretopython.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretorust/dataclass_enum.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretorust/dataclass_struct.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretorust/dataclass_union.rs.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretorust.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/class_core.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/enum_core.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/gitignore.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/index.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/package.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/test_class.ts.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretots/tsconfig.json.jinja +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/structuretoxsd.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/avrotize/xsdtoavro.py +0 -0
- {avrotize-2.20.3 → avrotize-2.20.4}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: avrotize
|
|
3
|
-
Version: 2.20.
|
|
3
|
+
Version: 2.20.4
|
|
4
4
|
Summary: Tools to convert from and to Avro Schema from various other schema languages.
|
|
5
5
|
Author-email: Clemens Vasters <clemensv@microsoft.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -111,6 +111,7 @@ Converting from Avrotize Schema:
|
|
|
111
111
|
Direct conversions (JSON Structure):
|
|
112
112
|
|
|
113
113
|
- [`avrotize s2p`](#convert-json-structure-to-protocol-buffers) - Convert JSON Structure to Protocol Buffers (.proto files).
|
|
114
|
+
- [`avrotize oas2s`](#convert-openapi-to-json-structure) - Convert OpenAPI 3.x document to JSON Structure.
|
|
114
115
|
|
|
115
116
|
Generate code from Avrotize Schema:
|
|
116
117
|
|
|
@@ -1067,6 +1068,29 @@ Conversion notes:
|
|
|
1067
1068
|
- The tool generates a complete Maven project with pom.xml including Jackson dependencies.
|
|
1068
1069
|
- Generated classes include `equals()` and `hashCode()` implementations.
|
|
1069
1070
|
|
|
1071
|
+
### Convert JSON Structure to JavaScript classes
|
|
1072
|
+
|
|
1073
|
+
```bash
|
|
1074
|
+
avrotize s2js <path_to_structure_schema_file> [--out <path_to_js_dir>] [--package <package_name>] [--avro-annotation]
|
|
1075
|
+
```
|
|
1076
|
+
|
|
1077
|
+
Parameters:
|
|
1078
|
+
|
|
1079
|
+
- `<path_to_structure_schema_file>`: The path to the JSON Structure schema file to be converted. If omitted, the file is read from stdin.
|
|
1080
|
+
- `--out`: The path to the directory to write the JavaScript classes to. Required.
|
|
1081
|
+
- `--package`: (optional) The package name for the generated classes.
|
|
1082
|
+
- `--avro-annotation`: (optional) Add Avro binary serialization support.
|
|
1083
|
+
|
|
1084
|
+
Conversion notes:
|
|
1085
|
+
|
|
1086
|
+
- The tool generates JavaScript ES6 classes from JSON Structure schemas with full type support.
|
|
1087
|
+
- JSON Structure primitive types are mapped to JavaScript types. Extended types like `date`, `time`, `datetime` are handled as Date objects or strings.
|
|
1088
|
+
- Integer types are mapped to JavaScript Number or BigInt depending on size.
|
|
1089
|
+
- Choice types are generated as union type classes with factory methods.
|
|
1090
|
+
- Tuple types are generated as arrays with fixed length.
|
|
1091
|
+
- The tool generates a complete npm package with package.json.
|
|
1092
|
+
- Generated classes include serialization/deserialization methods and optional Avro support when enabled.
|
|
1093
|
+
|
|
1070
1094
|
### Convert Avrotize Schema to Datapackage schema
|
|
1071
1095
|
|
|
1072
1096
|
```bash
|
|
@@ -1200,6 +1224,47 @@ Conversion notes:
|
|
|
1200
1224
|
- Choice types (unions) are converted to Protocol Buffers `oneof` constructs.
|
|
1201
1225
|
- Abstract types and extensions (`$extends`) are handled by generating appropriate message hierarchies.
|
|
1202
1226
|
|
|
1227
|
+
### Convert OpenAPI to JSON Structure
|
|
1228
|
+
|
|
1229
|
+
```bash
|
|
1230
|
+
avrotize oas2s <path_to_openapi_file> --out <path_to_json_structure_file> [--namespace <namespace>] [--preserve-composition] [--detect-discriminators] [--lift-inline-schemas]
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
Parameters:
|
|
1234
|
+
|
|
1235
|
+
- `<path_to_openapi_file>`: The path to the OpenAPI 3.x document (JSON or YAML). If omitted, the file is read from stdin.
|
|
1236
|
+
- `--out`: The path to the JSON Structure schema file to write the conversion result to. If omitted, the result is written to stdout.
|
|
1237
|
+
- `--namespace`: (optional) Namespace for the JSON Structure schema.
|
|
1238
|
+
- `--preserve-composition`: (optional) Preserve composition keywords (allOf, oneOf, anyOf). Default is `true`.
|
|
1239
|
+
- `--detect-discriminators`: (optional) Detect OpenAPI discriminator patterns and convert to choice types. Default is `true`.
|
|
1240
|
+
- `--lift-inline-schemas`: (optional) Lift inline schemas from paths/operations to named definitions. Default is `false`.
|
|
1241
|
+
|
|
1242
|
+
Conversion notes:
|
|
1243
|
+
|
|
1244
|
+
- The tool extracts schema definitions from `components.schemas` in the OpenAPI document and converts them to JSON Structure format.
|
|
1245
|
+
- OpenAPI-specific keywords are handled as follows:
|
|
1246
|
+
- `nullable`: Converted to type union with `null`
|
|
1247
|
+
- `readOnly`, `writeOnly`, `deprecated`: Mapped to metadata annotations
|
|
1248
|
+
- `discriminator`: Used to create choice types with proper discriminator mapping
|
|
1249
|
+
- OpenAPI `$ref` references (e.g., `#/components/schemas/Pet`) are converted to JSON Structure references (`#/definitions/Pet`).
|
|
1250
|
+
- All JSON Schema features supported by the JSON Schema converter are preserved, including:
|
|
1251
|
+
- Object structures with properties and required fields
|
|
1252
|
+
- Enumerations
|
|
1253
|
+
- Numeric and string constraints (minimum, maximum, minLength, maxLength, pattern)
|
|
1254
|
+
- Array and set types (with uniqueItems)
|
|
1255
|
+
- Map types (from additionalProperties)
|
|
1256
|
+
- Composition (allOf, oneOf, anyOf)
|
|
1257
|
+
|
|
1258
|
+
Example:
|
|
1259
|
+
|
|
1260
|
+
```bash
|
|
1261
|
+
# Convert an OpenAPI document to JSON Structure
|
|
1262
|
+
avrotize oas2s petstore.yaml --out petstore.struct.json
|
|
1263
|
+
|
|
1264
|
+
# With namespace and inline schema lifting
|
|
1265
|
+
avrotize oas2s api.json --out api.struct.json --namespace com.example.api --lift-inline-schemas
|
|
1266
|
+
```
|
|
1267
|
+
|
|
1203
1268
|
### Create the Parsing Canonical Form (PCF) of an Avrotize schema
|
|
1204
1269
|
|
|
1205
1270
|
```bash
|
|
@@ -63,6 +63,7 @@ Converting from Avrotize Schema:
|
|
|
63
63
|
Direct conversions (JSON Structure):
|
|
64
64
|
|
|
65
65
|
- [`avrotize s2p`](#convert-json-structure-to-protocol-buffers) - Convert JSON Structure to Protocol Buffers (.proto files).
|
|
66
|
+
- [`avrotize oas2s`](#convert-openapi-to-json-structure) - Convert OpenAPI 3.x document to JSON Structure.
|
|
66
67
|
|
|
67
68
|
Generate code from Avrotize Schema:
|
|
68
69
|
|
|
@@ -1019,6 +1020,29 @@ Conversion notes:
|
|
|
1019
1020
|
- The tool generates a complete Maven project with pom.xml including Jackson dependencies.
|
|
1020
1021
|
- Generated classes include `equals()` and `hashCode()` implementations.
|
|
1021
1022
|
|
|
1023
|
+
### Convert JSON Structure to JavaScript classes
|
|
1024
|
+
|
|
1025
|
+
```bash
|
|
1026
|
+
avrotize s2js <path_to_structure_schema_file> [--out <path_to_js_dir>] [--package <package_name>] [--avro-annotation]
|
|
1027
|
+
```
|
|
1028
|
+
|
|
1029
|
+
Parameters:
|
|
1030
|
+
|
|
1031
|
+
- `<path_to_structure_schema_file>`: The path to the JSON Structure schema file to be converted. If omitted, the file is read from stdin.
|
|
1032
|
+
- `--out`: The path to the directory to write the JavaScript classes to. Required.
|
|
1033
|
+
- `--package`: (optional) The package name for the generated classes.
|
|
1034
|
+
- `--avro-annotation`: (optional) Add Avro binary serialization support.
|
|
1035
|
+
|
|
1036
|
+
Conversion notes:
|
|
1037
|
+
|
|
1038
|
+
- The tool generates JavaScript ES6 classes from JSON Structure schemas with full type support.
|
|
1039
|
+
- JSON Structure primitive types are mapped to JavaScript types. Extended types like `date`, `time`, `datetime` are handled as Date objects or strings.
|
|
1040
|
+
- Integer types are mapped to JavaScript Number or BigInt depending on size.
|
|
1041
|
+
- Choice types are generated as union type classes with factory methods.
|
|
1042
|
+
- Tuple types are generated as arrays with fixed length.
|
|
1043
|
+
- The tool generates a complete npm package with package.json.
|
|
1044
|
+
- Generated classes include serialization/deserialization methods and optional Avro support when enabled.
|
|
1045
|
+
|
|
1022
1046
|
### Convert Avrotize Schema to Datapackage schema
|
|
1023
1047
|
|
|
1024
1048
|
```bash
|
|
@@ -1152,6 +1176,47 @@ Conversion notes:
|
|
|
1152
1176
|
- Choice types (unions) are converted to Protocol Buffers `oneof` constructs.
|
|
1153
1177
|
- Abstract types and extensions (`$extends`) are handled by generating appropriate message hierarchies.
|
|
1154
1178
|
|
|
1179
|
+
### Convert OpenAPI to JSON Structure
|
|
1180
|
+
|
|
1181
|
+
```bash
|
|
1182
|
+
avrotize oas2s <path_to_openapi_file> --out <path_to_json_structure_file> [--namespace <namespace>] [--preserve-composition] [--detect-discriminators] [--lift-inline-schemas]
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
Parameters:
|
|
1186
|
+
|
|
1187
|
+
- `<path_to_openapi_file>`: The path to the OpenAPI 3.x document (JSON or YAML). If omitted, the file is read from stdin.
|
|
1188
|
+
- `--out`: The path to the JSON Structure schema file to write the conversion result to. If omitted, the result is written to stdout.
|
|
1189
|
+
- `--namespace`: (optional) Namespace for the JSON Structure schema.
|
|
1190
|
+
- `--preserve-composition`: (optional) Preserve composition keywords (allOf, oneOf, anyOf). Default is `true`.
|
|
1191
|
+
- `--detect-discriminators`: (optional) Detect OpenAPI discriminator patterns and convert to choice types. Default is `true`.
|
|
1192
|
+
- `--lift-inline-schemas`: (optional) Lift inline schemas from paths/operations to named definitions. Default is `false`.
|
|
1193
|
+
|
|
1194
|
+
Conversion notes:
|
|
1195
|
+
|
|
1196
|
+
- The tool extracts schema definitions from `components.schemas` in the OpenAPI document and converts them to JSON Structure format.
|
|
1197
|
+
- OpenAPI-specific keywords are handled as follows:
|
|
1198
|
+
- `nullable`: Converted to type union with `null`
|
|
1199
|
+
- `readOnly`, `writeOnly`, `deprecated`: Mapped to metadata annotations
|
|
1200
|
+
- `discriminator`: Used to create choice types with proper discriminator mapping
|
|
1201
|
+
- OpenAPI `$ref` references (e.g., `#/components/schemas/Pet`) are converted to JSON Structure references (`#/definitions/Pet`).
|
|
1202
|
+
- All JSON Schema features supported by the JSON Schema converter are preserved, including:
|
|
1203
|
+
- Object structures with properties and required fields
|
|
1204
|
+
- Enumerations
|
|
1205
|
+
- Numeric and string constraints (minimum, maximum, minLength, maxLength, pattern)
|
|
1206
|
+
- Array and set types (with uniqueItems)
|
|
1207
|
+
- Map types (from additionalProperties)
|
|
1208
|
+
- Composition (allOf, oneOf, anyOf)
|
|
1209
|
+
|
|
1210
|
+
Example:
|
|
1211
|
+
|
|
1212
|
+
```bash
|
|
1213
|
+
# Convert an OpenAPI document to JSON Structure
|
|
1214
|
+
avrotize oas2s petstore.yaml --out petstore.struct.json
|
|
1215
|
+
|
|
1216
|
+
# With namespace and inline schema lifting
|
|
1217
|
+
avrotize oas2s api.json --out api.struct.json --namespace com.example.api --lift-inline-schemas
|
|
1218
|
+
```
|
|
1219
|
+
|
|
1155
1220
|
### Create the Parsing Canonical Form (PCF) of an Avrotize schema
|
|
1156
1221
|
|
|
1157
1222
|
```bash
|
|
@@ -56,6 +56,8 @@ _mappings = {
|
|
|
56
56
|
"convert_avro_to_rust": (f"{mod}.avrotorust", "convert_avro_to_rust"),
|
|
57
57
|
"convert_avro_schema_to_rust": (f"{mod}.avrotorust", "convert_avro_schema_to_rust"),
|
|
58
58
|
"convert_avro_to_datapackage": (f"{mod}.avrotodatapackage", "convert_avro_to_datapackage"),
|
|
59
|
+
"convert_structure_to_javascript": (f"{mod}.structuretojs", "convert_structure_to_javascript"),
|
|
60
|
+
"convert_structure_schema_to_javascript": (f"{mod}.structuretojs", "convert_structure_schema_to_javascript"),
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
_lazy_loader = LazyLoader(_mappings)
|
|
@@ -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.20.
|
|
32
|
-
__version_tuple__ = version_tuple = (2, 20,
|
|
31
|
+
__version__ = version = '2.20.4'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 20, 4)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'gadd3e447a'
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# {{ project_name }}
|
|
2
|
+
|
|
3
|
+
This is a generated C# project from an Avro schema using [avrotize](https://github.com/clemensv/avrotize).
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
{{ project_name }}/
|
|
9
|
+
├── src/ # Generated C# classes from Avro schema
|
|
10
|
+
│ └── {{ project_name | pascal }}.csproj
|
|
11
|
+
├── test/ # Generated unit tests
|
|
12
|
+
│ └── {{ project_name | pascal }}.Test.csproj
|
|
13
|
+
├── run_coverage.ps1 # PowerShell coverage script
|
|
14
|
+
├── run_coverage.sh # Bash coverage script (Linux/macOS)
|
|
15
|
+
└── {{ project_name }}.sln # Visual Studio solution file
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Building and Running
|
|
19
|
+
|
|
20
|
+
### Quick Start
|
|
21
|
+
```bash
|
|
22
|
+
# Build the project
|
|
23
|
+
dotnet build
|
|
24
|
+
|
|
25
|
+
# Run tests
|
|
26
|
+
dotnet test
|
|
27
|
+
|
|
28
|
+
# Run tests with coverage
|
|
29
|
+
dotnet test --collect:"XPlat Code Coverage"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Code Coverage
|
|
33
|
+
|
|
34
|
+
This project includes automated code coverage collection and reporting.
|
|
35
|
+
|
|
36
|
+
#### Using the Coverage Scripts
|
|
37
|
+
|
|
38
|
+
**PowerShell (Windows):**
|
|
39
|
+
```powershell
|
|
40
|
+
# Run tests with default 85% coverage threshold
|
|
41
|
+
.\run_coverage.ps1
|
|
42
|
+
|
|
43
|
+
# Set custom coverage threshold
|
|
44
|
+
.\run_coverage.ps1 -Threshold 90
|
|
45
|
+
|
|
46
|
+
# Generate HTML coverage report
|
|
47
|
+
.\run_coverage.ps1 -HtmlReport
|
|
48
|
+
|
|
49
|
+
# Generate and open HTML report in browser
|
|
50
|
+
.\run_coverage.ps1 -HtmlReport -OpenReport
|
|
51
|
+
|
|
52
|
+
# Run without failing on low coverage
|
|
53
|
+
.\run_coverage.ps1 -FailOnLowCoverage:$false
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Bash (Linux/macOS):**
|
|
57
|
+
```bash
|
|
58
|
+
# Run tests with default 85% coverage threshold
|
|
59
|
+
./run_coverage.sh
|
|
60
|
+
|
|
61
|
+
# Set custom coverage threshold
|
|
62
|
+
./run_coverage.sh --threshold 90
|
|
63
|
+
|
|
64
|
+
# Generate HTML coverage report
|
|
65
|
+
./run_coverage.sh --html-report
|
|
66
|
+
|
|
67
|
+
# Generate and open HTML report in browser
|
|
68
|
+
./run_coverage.sh --open-report
|
|
69
|
+
|
|
70
|
+
# Run without failing on low coverage
|
|
71
|
+
./run_coverage.sh --no-fail
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Coverage Configuration
|
|
75
|
+
|
|
76
|
+
The test project is configured with the following coverage settings in `test/{{ project_name | pascal }}.Test.csproj`:
|
|
77
|
+
|
|
78
|
+
- **Default Threshold**: 85% line coverage
|
|
79
|
+
- **Output Format**: Cobertura XML
|
|
80
|
+
- **Coverage Output**: `./coverage/` directory
|
|
81
|
+
- **Includes**: All `{{ project_name | pascal }}` namespace code
|
|
82
|
+
- **Excludes**: Test projects
|
|
83
|
+
|
|
84
|
+
#### Coverage Reports
|
|
85
|
+
|
|
86
|
+
Coverage reports are generated in the following formats:
|
|
87
|
+
|
|
88
|
+
1. **Cobertura XML**: `./coverage/[guid]/coverage.cobertura.xml`
|
|
89
|
+
2. **HTML Report** (when requested): `./coverage/html/index.html`
|
|
90
|
+
|
|
91
|
+
#### Continuous Integration
|
|
92
|
+
|
|
93
|
+
For CI/CD pipelines, use:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
# Example GitHub Actions step
|
|
97
|
+
- name: Run tests with coverage
|
|
98
|
+
run: |
|
|
99
|
+
dotnet test --collect:"XPlat Code Coverage" --results-directory:"./coverage"
|
|
100
|
+
|
|
101
|
+
# Or use the coverage script for threshold enforcement
|
|
102
|
+
- name: Run tests with coverage threshold
|
|
103
|
+
run: ./run_coverage.sh --threshold 85
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Generated Code Features
|
|
107
|
+
|
|
108
|
+
This project includes generated C# classes with the following features:
|
|
109
|
+
|
|
110
|
+
- **Value Equality**: Generated `Equals()` and `GetHashCode()` methods
|
|
111
|
+
- **Comprehensive Unit Tests**: Property tests, equality tests, and serialization tests
|
|
112
|
+
- **Multiple Serialization Support**: JSON, XML, and Avro serialization (if enabled)
|
|
113
|
+
- **Nullable Reference Types**: Full C# nullable reference type support
|
|
114
|
+
|
|
115
|
+
## Test Coverage Goals
|
|
116
|
+
|
|
117
|
+
The generated tests aim to provide comprehensive coverage of:
|
|
118
|
+
|
|
119
|
+
- ✅ **Property Access**: All public properties
|
|
120
|
+
- ✅ **Equality Methods**: `Equals()` and `GetHashCode()`
|
|
121
|
+
- ✅ **Constructors**: Default and parameterized constructors
|
|
122
|
+
- ✅ **Serialization**: JSON/XML/Avro serialization (when enabled)
|
|
123
|
+
- ✅ **Edge Cases**: Null handling and type conversion
|
|
124
|
+
|
|
125
|
+
### Typical Coverage Results
|
|
126
|
+
|
|
127
|
+
The generated tests typically achieve:
|
|
128
|
+
- **Line Coverage**: 95%+
|
|
129
|
+
- **Branch Coverage**: 90%+
|
|
130
|
+
|
|
131
|
+
## Customizing Coverage
|
|
132
|
+
|
|
133
|
+
To modify coverage settings, edit the `test/{{ project_name | pascal }}.Test.csproj` file:
|
|
134
|
+
|
|
135
|
+
```xml
|
|
136
|
+
<PropertyGroup>
|
|
137
|
+
<!-- Modify these values -->
|
|
138
|
+
<Threshold>85</Threshold> <!-- Minimum coverage % -->
|
|
139
|
+
<ThresholdType>line</ThresholdType> <!-- line, branch, or method -->
|
|
140
|
+
<ThresholdStat>minimum</ThresholdStat> <!-- minimum, average, or total -->
|
|
141
|
+
</PropertyGroup>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Dependencies
|
|
145
|
+
|
|
146
|
+
### Runtime
|
|
147
|
+
- .NET 9.0
|
|
148
|
+
- Newtonsoft.Json (if JSON serialization enabled)
|
|
149
|
+
- Apache.Avro (if Avro serialization enabled)
|
|
150
|
+
|
|
151
|
+
### Testing
|
|
152
|
+
- NUnit 4.3.2
|
|
153
|
+
- NUnit3TestAdapter 5.0.0
|
|
154
|
+
- Microsoft.NET.Test.Sdk 17.13.0
|
|
155
|
+
- coverlet.collector 6.0.4
|
|
156
|
+
- coverlet.msbuild 6.0.4
|
|
157
|
+
|
|
158
|
+
## Additional Tools
|
|
159
|
+
|
|
160
|
+
For enhanced coverage reporting, install ReportGenerator globally:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
dotnet tool install -g dotnet-reportgenerator-globaltool
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
This enables HTML report generation with the `-HtmlReport` option.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using NUnit.Framework;
|
|
4
|
+
|
|
5
|
+
{% if namespace %}
|
|
6
|
+
namespace {{ namespace }}
|
|
7
|
+
{
|
|
8
|
+
{% endif %}
|
|
9
|
+
{% set ind=4 if namespace else 0 %}
|
|
10
|
+
{% filter indent(width=ind, first=True) %}
|
|
11
|
+
/// <summary> Test class for {{ class_base_name }} </summary>
|
|
12
|
+
[TestFixture]
|
|
13
|
+
public class {{ test_class_name }}
|
|
14
|
+
{
|
|
15
|
+
private {{ class_base_name }} _instance;
|
|
16
|
+
|
|
17
|
+
/// <summary> Constructor </summary>
|
|
18
|
+
public {{ test_class_name }}()
|
|
19
|
+
{
|
|
20
|
+
_instance = CreateInstance();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// <summary> Create instance of {{ class_base_name }} </summary>
|
|
24
|
+
public {{ class_base_name }} CreateInstance()
|
|
25
|
+
{
|
|
26
|
+
var instance = new {{ class_base_name }}();
|
|
27
|
+
{%- for field in fields %}
|
|
28
|
+
{%- if not field.is_const %}
|
|
29
|
+
instance.{{ field.field_name }} = {{ field.test_value }};
|
|
30
|
+
{%- endif %}
|
|
31
|
+
{%- endfor %}
|
|
32
|
+
return instance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary> Testing Equals and GetHashCode - positive case </summary>
|
|
36
|
+
[Test]
|
|
37
|
+
public void TestEqualsAndHashCode_PositiveCase()
|
|
38
|
+
{
|
|
39
|
+
var instance1 = CreateInstance();
|
|
40
|
+
var instance2 = CreateInstance();
|
|
41
|
+
|
|
42
|
+
// Test equality
|
|
43
|
+
Assert.That(instance1.Equals(instance2), Is.True, "Two instances with same values should be equal");
|
|
44
|
+
Assert.That(instance1 == instance2, Is.False, "Operator == should use reference equality");
|
|
45
|
+
|
|
46
|
+
// Test hash codes
|
|
47
|
+
Assert.That(instance1.GetHashCode(), Is.EqualTo(instance2.GetHashCode()),
|
|
48
|
+
"Equal instances should have equal hash codes");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary> Testing Equals and GetHashCode - negative case </summary>
|
|
52
|
+
[Test]
|
|
53
|
+
public void TestEqualsAndHashCode_NegativeCase()
|
|
54
|
+
{
|
|
55
|
+
var instance1 = CreateInstance();
|
|
56
|
+
var instance2 = CreateInstance();
|
|
57
|
+
|
|
58
|
+
{%- set ns = {'found': false, 'is_complex_non_nullable': false} %}
|
|
59
|
+
{%- for field in fields if not field.is_const %}
|
|
60
|
+
{%- if not ns.found %}
|
|
61
|
+
{%- set _ = ns.update({'found': true}) %}
|
|
62
|
+
// Modify {{ field.field_name }} and verify inequality
|
|
63
|
+
{%- set base_type = field.field_type.rstrip('?') %}
|
|
64
|
+
{%- if base_type == "string" %}
|
|
65
|
+
instance2.{{ field.field_name }} = (instance2.{{ field.field_name }} ?? "test") + "_modified";
|
|
66
|
+
{%- elif base_type in ["int", "long", "short", "byte", "sbyte", "uint", "ulong", "ushort"] %}
|
|
67
|
+
instance2.{{ field.field_name }} = ({{ base_type }})({{ "(instance2." + field.field_name + " ?? 0)" if field.field_type.endswith("?") else "instance2." + field.field_name }} + 1);
|
|
68
|
+
{%- elif base_type in ["float", "double", "decimal"] %}
|
|
69
|
+
instance2.{{ field.field_name }} = {{ "(instance2." + field.field_name + " ?? 0)" if field.field_type.endswith("?") else "instance2." + field.field_name }} + 1.0{{ "f" if base_type == "float" else "m" if base_type == "decimal" else "" }};
|
|
70
|
+
{%- elif base_type == "bool" %}
|
|
71
|
+
instance2.{{ field.field_name }} = !{{ "(instance2." + field.field_name + " ?? false)" if field.field_type.endswith("?") else "instance2." + field.field_name }};
|
|
72
|
+
{%- elif field.field_type.endswith("?") %}
|
|
73
|
+
// For nullable complex types (including global:: types), set to null to make it different
|
|
74
|
+
instance2.{{ field.field_name }} = null;
|
|
75
|
+
{%- elif base_type.startswith("global::") and field.is_enum %}
|
|
76
|
+
// For non-nullable enum, cast to int and increment
|
|
77
|
+
instance2.{{ field.field_name }} = ({{ base_type }})((int)instance2.{{ field.field_name }} + 1);
|
|
78
|
+
{%- else %}
|
|
79
|
+
{%- set _ = ns.update({'is_complex_non_nullable': true}) %}
|
|
80
|
+
{%- endif %}
|
|
81
|
+
{%- if not ns.is_complex_non_nullable %}
|
|
82
|
+
Assert.That(instance1.Equals(instance2), Is.False,
|
|
83
|
+
"Instances with different {{ field.field_name }} should not be equal");
|
|
84
|
+
{%- endif %}
|
|
85
|
+
{%- endif %}
|
|
86
|
+
{%- endfor %}
|
|
87
|
+
{%- if ns.is_complex_non_nullable %}
|
|
88
|
+
// For non-nullable complex types (like unions), verify the positive case works correctly
|
|
89
|
+
// since we cannot create a meaningfully different value without knowing the type internals
|
|
90
|
+
Assert.Pass("Skipped negative test for complex non-nullable type - positive case validates Equals implementation");
|
|
91
|
+
{%- endif %}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
{%- for field in fields %}
|
|
95
|
+
/// <summary> Testing property {{ field.field_name }} </summary>
|
|
96
|
+
[Test]
|
|
97
|
+
public void Test{{ field.field_name | replace ('@','') | pascal }}Property()
|
|
98
|
+
{
|
|
99
|
+
var testValue = {{ field.test_value }};
|
|
100
|
+
{%- if not field.is_const %}
|
|
101
|
+
_instance.{{ field.field_name }} = testValue;
|
|
102
|
+
{%- endif %}
|
|
103
|
+
{%- if field.is_primitive %}
|
|
104
|
+
{%- if field.field_type.startswith("List<") or field.field_type.startswith("Dictionary<") %}
|
|
105
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EquivalentTo(testValue));
|
|
106
|
+
{%- else %}
|
|
107
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EqualTo(testValue));
|
|
108
|
+
{%- endif %}
|
|
109
|
+
{%- else %}
|
|
110
|
+
Assert.That(_instance.{{ field.field_name }}, Is.EqualTo(testValue));
|
|
111
|
+
{%- endif %}
|
|
112
|
+
}
|
|
113
|
+
{%- endfor %}
|
|
114
|
+
{%- if avro_annotation %}
|
|
115
|
+
/// <summary> Testing Avro serializer </summary>
|
|
116
|
+
[Test]
|
|
117
|
+
public void Test_ToByteArray_FromData_Avro()
|
|
118
|
+
{
|
|
119
|
+
var mediaType = "application/vnd.apache.avro+avro";
|
|
120
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
121
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
122
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
123
|
+
}
|
|
124
|
+
{%- endif %}
|
|
125
|
+
{%- if protobuf_net_annotation %}
|
|
126
|
+
/// <summary> Testing Protobuf serializer </summary>
|
|
127
|
+
[Test]
|
|
128
|
+
public void Test_ToByteArray_FromData_Protobuf()
|
|
129
|
+
{
|
|
130
|
+
var mediaType = "application/x-protobuf";
|
|
131
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
132
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
133
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
134
|
+
}
|
|
135
|
+
{%- endif %}
|
|
136
|
+
{%- if system_xml_annotation %}
|
|
137
|
+
/// <summary> Testing XML serializer </summary>
|
|
138
|
+
[Test]
|
|
139
|
+
public void Test_ToByteArray_FromData_Xml()
|
|
140
|
+
{
|
|
141
|
+
var mediaType = "application/xml";
|
|
142
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
143
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
144
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
145
|
+
}
|
|
146
|
+
{%- endif %}
|
|
147
|
+
{%- if system_text_json_annotation %}
|
|
148
|
+
/// <summary> Testing JSON serializer </summary>
|
|
149
|
+
[Test]
|
|
150
|
+
public void Test_ToByteArray_FromData_Json()
|
|
151
|
+
{
|
|
152
|
+
var mediaType = "application/json";
|
|
153
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
154
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
155
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
156
|
+
}
|
|
157
|
+
{%- endif %}
|
|
158
|
+
{%- if msgpack_annotation %}
|
|
159
|
+
/// <summary> Testing MsgPack serializer </summary>
|
|
160
|
+
[Test]
|
|
161
|
+
public void Test_ToByteArray_FromData_MsgPack()
|
|
162
|
+
{
|
|
163
|
+
var mediaType = "application/msgpack";
|
|
164
|
+
var bytes = _instance.ToByteArray(mediaType);
|
|
165
|
+
var newInstance = {{ class_base_name }}.FromData(bytes, mediaType);
|
|
166
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
167
|
+
}
|
|
168
|
+
{%- endif %}
|
|
169
|
+
{%- if avro_annotation or system_text_json_annotation or newtonsoft_json_annotation or system_xml_annotation or msgpack_annotation or protobuf_net_annotation %}
|
|
170
|
+
|
|
171
|
+
/// <summary> Testing FromData with edge cases </summary>
|
|
172
|
+
[Test]
|
|
173
|
+
public void Test_FromData_EdgeCases()
|
|
174
|
+
{
|
|
175
|
+
{%- if system_text_json_annotation %}
|
|
176
|
+
// Test null data - FromData returns null for null input
|
|
177
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/json"), Is.Null);
|
|
178
|
+
// Test empty data - should throw JsonException for invalid JSON
|
|
179
|
+
Assert.Throws<System.Text.Json.JsonException>(() => {{ class_base_name }}.FromData(Array.Empty<byte>(), "application/json"));
|
|
180
|
+
{%- elif newtonsoft_json_annotation %}
|
|
181
|
+
// Test null data - FromData returns null for null input
|
|
182
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/json"), Is.Null);
|
|
183
|
+
// Test empty data - Newtonsoft.Json returns null for empty string
|
|
184
|
+
Assert.That({{ class_base_name }}.FromData(Array.Empty<byte>(), "application/json"), Is.Null);
|
|
185
|
+
{%- elif avro_annotation %}
|
|
186
|
+
// Test null data - FromData returns null for null input
|
|
187
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "avro/binary"), Is.Null);
|
|
188
|
+
{%- elif msgpack_annotation %}
|
|
189
|
+
// Test null data - FromData returns null for null input
|
|
190
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/msgpack"), Is.Null);
|
|
191
|
+
{%- elif protobuf_net_annotation %}
|
|
192
|
+
// Test null data - FromData returns null for null input
|
|
193
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/x-protobuf"), Is.Null);
|
|
194
|
+
{%- elif system_xml_annotation %}
|
|
195
|
+
// Test null data - FromData returns null for null input
|
|
196
|
+
Assert.That({{ class_base_name }}.FromData((byte[])null!, "application/xml"), Is.Null);
|
|
197
|
+
{%- endif %}
|
|
198
|
+
}
|
|
199
|
+
{%- endif %}
|
|
200
|
+
{%- if system_text_json_annotation %}
|
|
201
|
+
|
|
202
|
+
/// <summary> Testing IsJsonMatch </summary>
|
|
203
|
+
[Test]
|
|
204
|
+
public void Test_IsJsonMatch()
|
|
205
|
+
{
|
|
206
|
+
var json = System.Text.Json.JsonSerializer.Serialize(_instance);
|
|
207
|
+
using var doc = System.Text.Json.JsonDocument.Parse(json);
|
|
208
|
+
Assert.That({{ class_base_name }}.IsJsonMatch(doc.RootElement), Is.True);
|
|
209
|
+
}
|
|
210
|
+
{%- endif %}
|
|
211
|
+
{%- if system_text_json_annotation or newtonsoft_json_annotation %}
|
|
212
|
+
|
|
213
|
+
/// <summary> Testing Gzip compression </summary>
|
|
214
|
+
[Test]
|
|
215
|
+
public void Test_ToByteArray_Gzip()
|
|
216
|
+
{
|
|
217
|
+
var mediaType = "application/json";
|
|
218
|
+
var gzipMediaType = "application/json+gzip";
|
|
219
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
220
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
221
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
222
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
223
|
+
"Gzip compressed data should have correct magic bytes");
|
|
224
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
225
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
226
|
+
}
|
|
227
|
+
{%- endif %}
|
|
228
|
+
{%- if msgpack_annotation and not (system_text_json_annotation or newtonsoft_json_annotation) %}
|
|
229
|
+
|
|
230
|
+
/// <summary> Testing Gzip compression with MessagePack </summary>
|
|
231
|
+
[Test]
|
|
232
|
+
public void Test_ToByteArray_Gzip_MsgPack()
|
|
233
|
+
{
|
|
234
|
+
var mediaType = "application/msgpack";
|
|
235
|
+
var gzipMediaType = "application/msgpack+gzip";
|
|
236
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
237
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
238
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
239
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
240
|
+
"Gzip compressed data should have correct magic bytes");
|
|
241
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
242
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
243
|
+
}
|
|
244
|
+
{%- endif %}
|
|
245
|
+
{%- if protobuf_net_annotation and not (system_text_json_annotation or newtonsoft_json_annotation or msgpack_annotation) %}
|
|
246
|
+
|
|
247
|
+
/// <summary> Testing Gzip compression with Protobuf </summary>
|
|
248
|
+
[Test]
|
|
249
|
+
public void Test_ToByteArray_Gzip_Protobuf()
|
|
250
|
+
{
|
|
251
|
+
var mediaType = "application/x-protobuf";
|
|
252
|
+
var gzipMediaType = "application/x-protobuf+gzip";
|
|
253
|
+
var plainBytes = _instance.ToByteArray(mediaType);
|
|
254
|
+
var gzipBytes = _instance.ToByteArray(gzipMediaType);
|
|
255
|
+
// Gzip compressed data should start with magic bytes 0x1f 0x8b
|
|
256
|
+
Assert.That(gzipBytes.Length >= 2 && gzipBytes[0] == 0x1f && gzipBytes[1] == 0x8b, Is.True,
|
|
257
|
+
"Gzip compressed data should have correct magic bytes");
|
|
258
|
+
var newInstance = {{ class_base_name }}.FromData(gzipBytes, gzipMediaType);
|
|
259
|
+
Assert.That(newInstance, Is.EqualTo(_instance));
|
|
260
|
+
}
|
|
261
|
+
{%- endif %}
|
|
262
|
+
}
|
|
263
|
+
{% endfilter %}
|
|
264
|
+
{% if namespace %}
|
|
265
|
+
}
|
|
266
|
+
{% endif %}
|