Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit cc81d59

Browse files
committed
Adds unset types for optional map
1 parent bedc6e5 commit cc81d59

16 files changed

Lines changed: 36 additions & 28 deletions

File tree

modules/openapi-json-schema-generator/src/main/resources/python/components/schemas/_helper_schema_output_type_base.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ typing.Tuple[schemas.OUTPUT_BASE_TYPES]{{endChar}}
7676
{{else}}
7777
{{#eq this "object"}}
7878
{{#if mapOutputJsonPathPiece}}
79+
{{#if optional}}
80+
typing.Union[{{#if fullRefModule}}{{fullRefModule}}.{{/if}}{{mapOutputJsonPathPiece.camelCase}}, schemas.Unset]{{endChar}}
81+
{{else}}
7982
{{#if fullRefModule}}{{fullRefModule}}.{{/if}}{{mapOutputJsonPathPiece.camelCase}}{{endChar}}
83+
{{/if}}
8084
{{else}}
85+
{{#if optional}}
86+
typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]{{endChar}}
87+
{{else}}
8188
schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]{{endChar}}
89+
{{/if}}
8290
{{/if}}
8391
{{/eq}}
8492
{{/eq}}

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/additional_properties_class.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class AdditionalPropertiesClassDict(schemas.immutabledict[str, schemas.OUTPUT_BA
368368
})
369369

370370
@property
371-
def get_map_property(self) -> MapPropertyDict:
371+
def get_map_property(self) -> typing.Union[MapPropertyDict, schemas.Unset]:
372372
val = self.get("map_property", schemas.unset)
373373
if val is schemas.unset:
374374
return val
@@ -378,7 +378,7 @@ def get_map_property(self) -> MapPropertyDict:
378378
)
379379

380380
@property
381-
def get_map_of_map_property(self) -> MapOfMapPropertyDict:
381+
def get_map_of_map_property(self) -> typing.Union[MapOfMapPropertyDict, schemas.Unset]:
382382
val = self.get("map_of_map_property", schemas.unset)
383383
if val is schemas.unset:
384384
return val
@@ -398,7 +398,7 @@ def get_anytype1(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]
398398
)
399399

400400
@property
401-
def get_map_with_undeclared_properties_anytype1(self) -> schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]:
401+
def get_map_with_undeclared_properties_anytype1(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
402402
val = self.get("map_with_undeclared_properties_anytype_1", schemas.unset)
403403
if val is schemas.unset:
404404
return val
@@ -408,7 +408,7 @@ def get_map_with_undeclared_properties_anytype1(self) -> schemas.immutabledict[s
408408
)
409409

410410
@property
411-
def get_map_with_undeclared_properties_anytype2(self) -> schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]:
411+
def get_map_with_undeclared_properties_anytype2(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
412412
val = self.get("map_with_undeclared_properties_anytype_2", schemas.unset)
413413
if val is schemas.unset:
414414
return val
@@ -418,7 +418,7 @@ def get_map_with_undeclared_properties_anytype2(self) -> schemas.immutabledict[s
418418
)
419419

420420
@property
421-
def get_map_with_undeclared_properties_anytype3(self) -> MapWithUndeclaredPropertiesAnytype3Dict:
421+
def get_map_with_undeclared_properties_anytype3(self) -> typing.Union[MapWithUndeclaredPropertiesAnytype3Dict, schemas.Unset]:
422422
val = self.get("map_with_undeclared_properties_anytype_3", schemas.unset)
423423
if val is schemas.unset:
424424
return val
@@ -428,7 +428,7 @@ def get_map_with_undeclared_properties_anytype3(self) -> MapWithUndeclaredProper
428428
)
429429

430430
@property
431-
def get_empty_map(self) -> EmptyMapDict:
431+
def get_empty_map(self) -> typing.Union[EmptyMapDict, schemas.Unset]:
432432
val = self.get("empty_map", schemas.unset)
433433
if val is schemas.unset:
434434
return val
@@ -438,7 +438,7 @@ def get_empty_map(self) -> EmptyMapDict:
438438
)
439439

440440
@property
441-
def get_map_with_undeclared_properties_string(self) -> MapWithUndeclaredPropertiesStringDict:
441+
def get_map_with_undeclared_properties_string(self) -> typing.Union[MapWithUndeclaredPropertiesStringDict, schemas.Unset]:
442442
val = self.get("map_with_undeclared_properties_string", schemas.unset)
443443
if val is schemas.unset:
444444
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/file_schema_test_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FileSchemaTestClassDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYP
8888
})
8989

9090
@property
91-
def get_file(self) -> file.FileDict:
91+
def get_file(self) -> typing.Union[file.FileDict, schemas.Unset]:
9292
val = self.get("file", schemas.unset)
9393
if val is schemas.unset:
9494
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/map_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class MapTestDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
328328
})
329329

330330
@property
331-
def get_map_map_of_string(self) -> MapMapOfStringDict:
331+
def get_map_map_of_string(self) -> typing.Union[MapMapOfStringDict, schemas.Unset]:
332332
val = self.get("map_map_of_string", schemas.unset)
333333
if val is schemas.unset:
334334
return val
@@ -338,7 +338,7 @@ def get_map_map_of_string(self) -> MapMapOfStringDict:
338338
)
339339

340340
@property
341-
def get_map_of_enum_string(self) -> MapOfEnumStringDict:
341+
def get_map_of_enum_string(self) -> typing.Union[MapOfEnumStringDict, schemas.Unset]:
342342
val = self.get("map_of_enum_string", schemas.unset)
343343
if val is schemas.unset:
344344
return val
@@ -348,7 +348,7 @@ def get_map_of_enum_string(self) -> MapOfEnumStringDict:
348348
)
349349

350350
@property
351-
def get_direct_map(self) -> DirectMapDict:
351+
def get_direct_map(self) -> typing.Union[DirectMapDict, schemas.Unset]:
352352
val = self.get("direct_map", schemas.unset)
353353
if val is schemas.unset:
354354
return val
@@ -358,7 +358,7 @@ def get_direct_map(self) -> DirectMapDict:
358358
)
359359

360360
@property
361-
def get_indirect_map(self) -> string_boolean_map.StringBooleanMapDict:
361+
def get_indirect_map(self) -> typing.Union[string_boolean_map.StringBooleanMapDict, schemas.Unset]:
362362
val = self.get("indirect_map", schemas.unset)
363363
if val is schemas.unset:
364364
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/mixed_properties_and_additional_properties_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def get_date_time(self) -> typing.Union[str, schemas.Unset]:
113113
)
114114

115115
@property
116-
def get_map(self) -> MapDict:
116+
def get_map(self) -> typing.Union[MapDict, schemas.Unset]:
117117
val = self.get("map", schemas.unset)
118118
if val is schemas.unset:
119119
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/nullable_class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ def get_array_items_nullable(self) -> typing.Union[ArrayItemsNullableTuple, sche
10261026
@property
10271027
def get_object_nullable_propy(self) -> typing.Union[
10281028
typing.Union[None, schemas.Unset],
1029-
ObjectNullablePropDict,
1029+
typing.Union[ObjectNullablePropDict, schemas.Unset],
10301030
]:
10311031
val = self.get("object_nullable_prop", schemas.unset)
10321032
if val is schemas.unset:
@@ -1042,7 +1042,7 @@ def get_object_nullable_propy(self) -> typing.Union[
10421042
@property
10431043
def get_object_and_items_nullable_propy(self) -> typing.Union[
10441044
typing.Union[None, schemas.Unset],
1045-
ObjectAndItemsNullablePropDict,
1045+
typing.Union[ObjectAndItemsNullablePropDict, schemas.Unset],
10461046
]:
10471047
val = self.get("object_and_items_nullable_prop", schemas.unset)
10481048
if val is schemas.unset:
@@ -1056,7 +1056,7 @@ def get_object_and_items_nullable_propy(self) -> typing.Union[
10561056
)
10571057

10581058
@property
1059-
def get_object_items_nullable(self) -> ObjectItemsNullableDict:
1059+
def get_object_items_nullable(self) -> typing.Union[ObjectItemsNullableDict, schemas.Unset]:
10601060
val = self.get("object_items_nullable", schemas.unset)
10611061
if val is schemas.unset:
10621062
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_colliding_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ObjectWithCollidingPropertiesDict(schemas.immutabledict[str, schemas.OUTPU
3030
})
3131

3232
@property
33-
def get_some_prop(self) -> schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]:
33+
def get_some_prop(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
3434
val = self.get("someProp", schemas.unset)
3535
if val is schemas.unset:
3636
return val
@@ -40,7 +40,7 @@ def get_some_prop(self) -> schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
4040
)
4141

4242
@property
43-
def get_someprop(self) -> schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]:
43+
def get_someprop(self) -> typing.Union[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], schemas.Unset]:
4444
val = self.get("someprop", schemas.unset)
4545
if val is schemas.unset:
4646
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/object_with_decimal_properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_width(self) -> typing.Union[str, schemas.Unset]:
5454
)
5555

5656
@property
57-
def get_cost(self) -> money.MoneyDict:
57+
def get_cost(self) -> typing.Union[money.MoneyDict, schemas.Unset]:
5858
val = self.get("cost", schemas.unset)
5959
if val is schemas.unset:
6060
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/pet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def get_id(self) -> typing.Union[int, schemas.Unset]:
256256
)
257257

258258
@property
259-
def get_category(self) -> category.CategoryDict:
259+
def get_category(self) -> typing.Union[category.CategoryDict, schemas.Unset]:
260260
val = self.get("category", schemas.unset)
261261
if val is schemas.unset:
262262
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/schema/player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_name(self) -> typing.Union[str, schemas.Unset]:
3939
)
4040

4141
@property
42-
def get_enemy_player(self) -> PlayerDict:
42+
def get_enemy_player(self) -> typing.Union[PlayerDict, schemas.Unset]:
4343
val = self.get("enemyPlayer", schemas.unset)
4444
if val is schemas.unset:
4545
return val

0 commit comments

Comments
 (0)