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

Commit 489f4fb

Browse files
committed
Adds unset output for many cases
1 parent 75fae57 commit 489f4fb

55 files changed

Lines changed: 137 additions & 137 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def get_{{@key.snakeCase}}(self) -> schemas.OUTPUT_BASE_TYPES:
2929
{{#if refInfo.refClass}}
3030

3131
@property
32-
{{> components/schemas/_helper_schema_output_ref_type fullRefModule="" mode="get_property" endChar=":" }}
32+
{{> components/schemas/_helper_schema_output_ref_type fullRefModule="" mode="get_property" endChar=":" optional=true }}
3333
{{> components/schemas/_helper_object_get_property required=false }}
3434
{{else}}
3535

3636
@property
37-
{{> components/schemas/_helper_schema_output_type mode="get_property" fullRefModule=null endChar=":" }}
37+
{{> components/schemas/_helper_schema_output_type mode="get_property" fullRefModule=null endChar=":" optional=true }}
3838
{{> components/schemas/_helper_object_get_property required=false }}
3939
{{/if}}
4040
{{/with}}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
{{#and ../enumInfo ../enumInfo.typeToValues.boolean}}
55
typing_extensions.Literal[{{#each ../enumInfo.typeToValues.boolean}}{{#if value}}True{{else}}False{{/if}}{{#unless @last}}, {{/unless}}{{/each}}]{{endChar}}
66
{{else}}
7-
bool{{endChar}}
7+
{{#if optional}}typing.Union[bool, schemas.Unset]{{else}}bool{{/if}}{{endChar}}
88
{{/and}}
99
{{else}}
1010
{{#eq this "null"}}
11-
None{{endChar}}
11+
{{#if optional}}typing.Union[None, schemas.Unset]{{else}}None{{/if}}{{endChar}}
1212
{{else}}
1313
{{#eq this "string"}}
1414
{{#eq format "binary"}}
@@ -17,7 +17,7 @@ typing.Union[bytes, schemas.FileIO]{{endChar}}
1717
{{#and ../enumInfo ../enumInfo.typeToValues.string}}
1818
typing_extensions.Literal[{{#each ../enumInfo.typeToValues.string}}"{{{value}}}"{{#unless @last}}, {{/unless}}{{/each}}]{{endChar}}
1919
{{else}}
20-
str{{endChar}}
20+
{{#if optional}}typing.Union[str, schemas.Unset]{{else}}str{{/if}}{{endChar}}
2121
{{/and}}
2222
{{/eq}}
2323
{{else}}
@@ -28,7 +28,7 @@ typing.Union[int, float]{{endChar}}
2828
{{#and ../enumInfo ../enumInfo.typeToValues.integer}}
2929
typing_extensions.Literal[{{#each ../enumInfo.typeToValues.integer}}{{value}}{{#unless @last}}, {{/unless}}{{/each}}]{{endChar}}
3030
{{else}}
31-
int{{endChar}}
31+
{{#if optional}}typing.Union[int, schemas.Unset]{{else}}int{{/if}}{{endChar}}
3232
{{/and}}
3333
{{else}}
3434
{{#eq this "array"}}

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_success_inline_content_and_header/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HeadersDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3333
})
3434

3535
@property
36-
def get_some_header(self) -> str:
36+
def get_some_header(self) -> typing.Union[str, schemas.Unset]:
3737
val = self.get("someHeader", schemas.unset)
3838
if val is schemas.unset:
3939
return val

samples/openapi3/client/petstore/python/src/petstore_api/components/responses/response_success_with_json_api_response/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_string_header(self) -> str:
9898
)
9999

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

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

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

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ReturnDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2727
})
2828

2929
@property
30-
def get__return(self) -> int:
30+
def get__return(self) -> typing.Union[int, schemas.Unset]:
3131
val = self.get("return", schemas.unset)
3232
if val is schemas.unset:
3333
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_class_name(self) -> str:
4646
)
4747

4848
@property
49-
def get_color(self) -> str:
49+
def get_color(self) -> typing.Union[str, schemas.Unset]:
5050
val = self.get("color", schemas.unset)
5151
if val is schemas.unset:
5252
return val

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ApiResponseDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
3333
})
3434

3535
@property
36-
def get_code(self) -> int:
36+
def get_code(self) -> typing.Union[int, schemas.Unset]:
3737
val = self.get("code", schemas.unset)
3838
if val is schemas.unset:
3939
return val
@@ -43,7 +43,7 @@ def get_code(self) -> int:
4343
)
4444

4545
@property
46-
def get_type(self) -> str:
46+
def get_type(self) -> typing.Union[str, schemas.Unset]:
4747
val = self.get("type", schemas.unset)
4848
if val is schemas.unset:
4949
return val
@@ -53,7 +53,7 @@ def get_type(self) -> str:
5353
)
5454

5555
@property
56-
def get_message(self) -> str:
56+
def get_message(self) -> typing.Union[str, schemas.Unset]:
5757
val = self.get("message", schemas.unset)
5858
if val is schemas.unset:
5959
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_cultivar(self) -> str:
6060
)
6161

6262
@property
63-
def get_origin(self) -> str:
63+
def get_origin(self) -> typing.Union[str, schemas.Unset]:
6464
val = self.get("origin", schemas.unset)
6565
if val is schemas.unset:
6666
return val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_cultivar(self) -> str:
5151
)
5252

5353
@property
54-
def get_mealy(self) -> bool:
54+
def get_mealy(self) -> typing.Union[bool, schemas.Unset]:
5555
val = self.get("mealy", schemas.unset)
5656
if val is schemas.unset:
5757
return val

0 commit comments

Comments
 (0)