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

Commit bedc6e5

Browse files
committed
Adds array unset return value
1 parent e4e067b commit bedc6e5

13 files changed

Lines changed: 33 additions & 17 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,32 @@ typing_extensions.Literal[{{#each ../enumInfo.typeToValues.integer}}{{value}}{{#
4646
{{#eq this "array"}}
4747
{{#if arrayOutputJsonPathPiece}}
4848
{{#if fullRefModule}}
49+
{{#if optional}}
50+
typing.Union[{{fullRefModule}}.{{arrayOutputJsonPathPiece.camelCase}}, schemas.Unset]{{endChar}}
51+
{{else}}
4952
{{fullRefModule}}.{{arrayOutputJsonPathPiece.camelCase}}{{endChar}}
53+
{{/if}}
5054
{{else}}
5155
{{#if selfReference}}
56+
{{#if optional}}
57+
typing.Union['{{arrayOutputJsonPathPiece.camelCase}}', schemas.Unset]{{endChar}}
58+
{{else}}
5259
'{{arrayOutputJsonPathPiece.camelCase}}'{{endChar}}
60+
{{/if}}
5361
{{else}}
62+
{{#if optional}}
63+
typing.Union[{{arrayOutputJsonPathPiece.camelCase}}, schemas.Unset]{{endChar}}
64+
{{else}}
5465
{{arrayOutputJsonPathPiece.camelCase}}{{endChar}}
66+
{{/if}}
5567
{{/if}}
5668
{{/if}}
5769
{{else}}
70+
{{#if optional}}
71+
typing.Union[typing.Tuple[schemas.OUTPUT_BASE_TYPES], schemas.Unset]{{endChar}}
72+
{{else}}
5873
typing.Tuple[schemas.OUTPUT_BASE_TYPES]{{endChar}}
74+
{{/if}}
5975
{{/if}}
6076
{{else}}
6177
{{#eq this "object"}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ArrayOfArrayOfNumberOnlyDict(schemas.immutabledict[str, schemas.OUTPUT_BAS
141141
})
142142

143143
@property
144-
def get_array_array_number(self) -> ArrayArrayNumberTuple:
144+
def get_array_array_number(self) -> typing.Union[ArrayArrayNumberTuple, schemas.Unset]:
145145
val = self.get("ArrayArrayNumber", schemas.unset)
146146
if val is schemas.unset:
147147
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ArrayOfNumberOnlyDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES
8383
})
8484

8585
@property
86-
def get_array_number(self) -> ArrayNumberTuple:
86+
def get_array_number(self) -> typing.Union[ArrayNumberTuple, schemas.Unset]:
8787
val = self.get("ArrayNumber", schemas.unset)
8888
if val is schemas.unset:
8989
return val

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class ArrayTestDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
308308
})
309309

310310
@property
311-
def get_array_of_string(self) -> ArrayOfStringTuple:
311+
def get_array_of_string(self) -> typing.Union[ArrayOfStringTuple, schemas.Unset]:
312312
val = self.get("array_of_string", schemas.unset)
313313
if val is schemas.unset:
314314
return val
@@ -318,7 +318,7 @@ def get_array_of_string(self) -> ArrayOfStringTuple:
318318
)
319319

320320
@property
321-
def get_array_array_of_integer(self) -> ArrayArrayOfIntegerTuple:
321+
def get_array_array_of_integer(self) -> typing.Union[ArrayArrayOfIntegerTuple, schemas.Unset]:
322322
val = self.get("array_array_of_integer", schemas.unset)
323323
if val is schemas.unset:
324324
return val
@@ -328,7 +328,7 @@ def get_array_array_of_integer(self) -> ArrayArrayOfIntegerTuple:
328328
)
329329

330330
@property
331-
def get_array_array_of_model(self) -> ArrayArrayOfModelTuple:
331+
def get_array_array_of_model(self) -> typing.Union[ArrayArrayOfModelTuple, schemas.Unset]:
332332
val = self.get("array_array_of_model", schemas.unset)
333333
if val is schemas.unset:
334334
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def get_nullable_shape(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.
149149
)
150150

151151
@property
152-
def get_shapes(self) -> ShapesTuple:
152+
def get_shapes(self) -> typing.Union[ShapesTuple, schemas.Unset]:
153153
val = self.get("shapes", schemas.unset)
154154
if val is schemas.unset:
155155
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def get_just_symbol(self) -> typing.Union[typing_extensions.Literal[">=", "$"],
224224
)
225225

226226
@property
227-
def get_array_enum(self) -> ArrayEnumTuple:
227+
def get_array_enum(self) -> typing.Union[ArrayEnumTuple, schemas.Unset]:
228228
val = self.get("array_enum", schemas.unset)
229229
if val is schemas.unset:
230230
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
@@ -98,7 +98,7 @@ def get_file(self) -> file.FileDict:
9898
)
9999

100100
@property
101-
def get_files(self) -> FilesTuple:
101+
def get_files(self) -> typing.Union[FilesTuple, schemas.Unset]:
102102
val = self.get("files", schemas.unset)
103103
if val is schemas.unset:
104104
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def get_float64(self) -> typing.Union[int, float, schemas.Unset]:
357357
)
358358

359359
@property
360-
def get_array_with_unique_items(self) -> ArrayWithUniqueItemsTuple:
360+
def get_array_with_unique_items(self) -> typing.Union[ArrayWithUniqueItemsTuple, schemas.Unset]:
361361
val = self.get("arrayWithUniqueItems", schemas.unset)
362362
if val is schemas.unset:
363363
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
@@ -984,7 +984,7 @@ def get_datetime_propy(self) -> typing.Union[
984984
@property
985985
def get_array_nullable_propy(self) -> typing.Union[
986986
typing.Union[None, schemas.Unset],
987-
ArrayNullablePropTuple,
987+
typing.Union[ArrayNullablePropTuple, schemas.Unset],
988988
]:
989989
val = self.get("array_nullable_prop", schemas.unset)
990990
if val is schemas.unset:
@@ -1000,7 +1000,7 @@ def get_array_nullable_propy(self) -> typing.Union[
10001000
@property
10011001
def get_array_and_items_nullable_propy(self) -> typing.Union[
10021002
typing.Union[None, schemas.Unset],
1003-
ArrayAndItemsNullablePropTuple,
1003+
typing.Union[ArrayAndItemsNullablePropTuple, schemas.Unset],
10041004
]:
10051005
val = self.get("array_and_items_nullable_prop", schemas.unset)
10061006
if val is schemas.unset:
@@ -1014,7 +1014,7 @@ def get_array_and_items_nullable_propy(self) -> typing.Union[
10141014
)
10151015

10161016
@property
1017-
def get_array_items_nullable(self) -> ArrayItemsNullableTuple:
1017+
def get_array_items_nullable(self) -> typing.Union[ArrayItemsNullableTuple, schemas.Unset]:
10181018
val = self.get("array_items_nullable", schemas.unset)
10191019
if val is schemas.unset:
10201020
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
@@ -266,7 +266,7 @@ def get_category(self) -> category.CategoryDict:
266266
)
267267

268268
@property
269-
def get_tags(self) -> TagsTuple:
269+
def get_tags(self) -> typing.Union[TagsTuple, schemas.Unset]:
270270
val = self.get("tags", schemas.unset)
271271
if val is schemas.unset:
272272
return val

0 commit comments

Comments
 (0)