structurize 2.22.0__py3-none-any.whl → 2.22.1__py3-none-any.whl

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/_version.py CHANGED
@@ -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.22.0'
32
- __version_tuple__ = version_tuple = (2, 22, 0)
31
+ __version__ = version = '2.22.1'
32
+ __version_tuple__ = version_tuple = (2, 22, 1)
33
33
 
34
- __commit_id__ = commit_id = 'g5d3e04df0'
34
+ __commit_id__ = commit_id = 'g09745f1ba'
avrotize/avrotojsons.py CHANGED
@@ -184,16 +184,38 @@ class AvroToJsonSchemaConverter:
184
184
  def handle_type_union(self, types: List[Union[str, Dict[str, Any]]]) -> Dict[str, Any] | List[Dict[str, Any]| str] | str:
185
185
  """
186
186
  Handle Avro type unions, returning a JSON schema that validates against any of the types.
187
+ Preserves nullability from Avro unions containing 'null'.
187
188
  """
189
+ is_nullable = 'null' in types
188
190
  non_null_types = [t for t in types if t != 'null']
191
+
189
192
  if len(non_null_types) == 1:
190
- # Single non-null type
191
- return self.parse_avro_schema(non_null_types[0])
193
+ # Single non-null type - check if it's a primitive that can use type array
194
+ single_type = non_null_types[0]
195
+ json_schema = self.parse_avro_schema(single_type)
196
+
197
+ if is_nullable and isinstance(json_schema, dict):
198
+ # For primitives with a simple 'type' field, we can use type array notation
199
+ if 'type' in json_schema and isinstance(json_schema['type'], str) and '$ref' not in json_schema:
200
+ # Primitive type - add null to type array
201
+ json_schema = copy.deepcopy(json_schema)
202
+ json_schema['type'] = [json_schema['type'], 'null']
203
+ elif '$ref' in json_schema:
204
+ # Reference type - use oneOf with null
205
+ json_schema = {
206
+ 'oneOf': [
207
+ {'type': 'null'},
208
+ json_schema
209
+ ]
210
+ }
211
+ return json_schema
192
212
  else:
193
213
  # Multiple non-null types
194
- union_types = [self.convert_reference(t) if isinstance(t,str) and t in self.defined_types else self.avro_primitive_to_json_type(t)
214
+ union_types = [self.convert_reference(t) if isinstance(t, str) and t in self.defined_types else self.avro_primitive_to_json_type(t)
195
215
  if isinstance(t, str) else self.parse_avro_schema(t)
196
216
  for t in non_null_types]
217
+ if is_nullable:
218
+ union_types.insert(0, {'type': 'null'})
197
219
  return {
198
220
  'oneOf': union_types
199
221
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structurize
3
- Version: 2.22.0
3
+ Version: 2.22.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
@@ -1,6 +1,6 @@
1
1
  avrotize/__init__.py,sha256=t5h5wkHXr6M0mmHAB5rhjZ3Gxy9xutGTGIfojfao9rI,3820
2
2
  avrotize/__main__.py,sha256=5pY8dYAURcOnFRvgb6fgaOIa_SOzPLIWbU8-ZTQ0jG4,88
3
- avrotize/_version.py,sha256=RizwlnbP9gT9Cli8S3AsqYTckMr4Y8rczsBdG4bV938,714
3
+ avrotize/_version.py,sha256=bVtkjzpTqgXVpMS2Ucy6CWAGuw5P6M7BUl7VGAIPpb8,714
4
4
  avrotize/asn1toavro.py,sha256=QDNwfBfXMxSH-k487CA3CaGCGDzOLs4PpVbbENm5uF0,8386
5
5
  avrotize/avrotize.py,sha256=VHFpBltMVBpyt0ju3ZWW725BKjQ4Fk-nrAy8udW-X44,5713
6
6
  avrotize/avrotocpp.py,sha256=hRZV247_TDD7Sm6_8sFx-UH5SueLLx2Wg6TvAVUX0iE,25693
@@ -13,7 +13,7 @@ avrotize/avrotographql.py,sha256=i6G7xWjH_Lsn_CLiM4BCPb8OyZuCCpsYjXwXNTRMwEE,739
13
13
  avrotize/avrotoiceberg.py,sha256=plVHGWkED1YDLcMDxL7NMdJl2f8G32hwlNWFrBLcsD8,9057
14
14
  avrotize/avrotojava.py,sha256=NZZ7mUFVzvp7HBsU0XPiCwl4GVXE1RtS86pfNFJsIq8,135427
15
15
  avrotize/avrotojs.py,sha256=QjB6XjFnDrpZBZrrWqS0TN8fQfRXBfhHabfG73FOIo8,12249
16
- avrotize/avrotojsons.py,sha256=WXWniQqwcl8eU35VibDv7qJJwbiLV_yoWZ4JxiZ8mHA,21588
16
+ avrotize/avrotojsons.py,sha256=I7EJz_IaCYLNzcycYXDOLAexHRHQfyb4yoWcxJ02vb0,22697
17
17
  avrotize/avrotojstruct.py,sha256=-Hs4Ta958bRKmOfSTzRFENABCZ6lQPSPbIBEXvOQD1M,14660
18
18
  avrotize/avrotokusto.py,sha256=D6AiRPa5uiZbqo9dqrFvAknsF5oNXgIzk8_08uZTZ2M,17636
19
19
  avrotize/avrotomd.py,sha256=WHPHnfmkI3xDNIHKZ3ReYxj6tib1eCny3JOznNSN6r8,5348
@@ -64,9 +64,9 @@ avrotize/structuretoxsd.py,sha256=01VpasyWSMOx04sILHLP7H-WkhGdXAEGKohUUfgrNf0,32
64
64
  avrotize/xsdtoavro.py,sha256=nQtNH_3pEZBp67oUCPqzhvItEExHTe-8obsIfNRXt8Y,19064
65
65
  avrotize/dependencies/cpp/vcpkg/vcpkg.json,sha256=se5qnUVQ1Q6wN_DqgIioqKg_y7ouh9oly2iBAJJXkgw,414
66
66
  avrotize/dependencies/typescript/node22/package.json,sha256=oAW_2X-b715kV7aajwuONZEMkyQUJGviG3GwnoUa7hU,387
67
- structurize-2.22.0.dist-info/licenses/LICENSE,sha256=xGtQGygTETTtDQJafZCUbpsed3GxO6grmqig-jGEuSk,11348
68
- structurize-2.22.0.dist-info/METADATA,sha256=nWSfeORdr2Q5aH2WjWQxw5-HcdXVAbGl7xmKrewxZNs,3670
69
- structurize-2.22.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
70
- structurize-2.22.0.dist-info/entry_points.txt,sha256=biIH7jA5auhVqfbwHVk2gmD_gvrPYKgjpCAn0JWZ-Rs,55
71
- structurize-2.22.0.dist-info/top_level.txt,sha256=yn-yQ0Cm1O9fbF8KJgv4IIvX4YRGelKgPqZF1wS5P50,9
72
- structurize-2.22.0.dist-info/RECORD,,
67
+ structurize-2.22.1.dist-info/licenses/LICENSE,sha256=xGtQGygTETTtDQJafZCUbpsed3GxO6grmqig-jGEuSk,11348
68
+ structurize-2.22.1.dist-info/METADATA,sha256=yjYBCdZGNjX3gB8xyaGSKI7g8eA67yH62Ej0w1JrbLY,3670
69
+ structurize-2.22.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
70
+ structurize-2.22.1.dist-info/entry_points.txt,sha256=biIH7jA5auhVqfbwHVk2gmD_gvrPYKgjpCAn0JWZ-Rs,55
71
+ structurize-2.22.1.dist-info/top_level.txt,sha256=yn-yQ0Cm1O9fbF8KJgv4IIvX4YRGelKgPqZF1wS5P50,9
72
+ structurize-2.22.1.dist-info/RECORD,,