Skip to content

Commit

Permalink
[python] Fixes endpoint overload type hint + required property not in…
Browse files Browse the repository at this point in the history
… properties (#13790)

* Adds endpoint overload type hint fix to template

* Samples regenerated

* Adds fix for required property not in properties

* Regenerates samples
  • Loading branch information
spacether authored Oct 22, 2022
1 parent c0c31e8 commit ac3bb68
Show file tree
Hide file tree
Showing 236 changed files with 1,235 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
{{/eq}}
{{/with}}
{{/if}}
{{else}}
{{#if isOverload}}
{{#eq skipDeserialization "True"}}
skip_deserialization: typing_extensions.Literal[True],
{{/eq}}
{{/if}}
{{/if}}
{{#if queryParams}}
query_params: RequestQueryParams = frozendict.frozendict(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ def __new__(
{{#if complexType}}
{{baseName}}: '{{complexType}}',
{{else}}
{{#if getSchemaIsFromAdditionalProperties}}
{{#if addPropsUnset}}
{{baseName}}: typing.Union[schemas.AnyTypeSchema, {{> model_templates/schema_python_types }}],
{{else}}
{{baseName}}: typing.Union[MetaOapg.additional_properties, {{> model_templates/schema_python_types }}],
{{/if}}
{{else}}
{{baseName}}: typing.Union[MetaOapg.properties.{{baseName}}, {{> model_templates/schema_python_types }}],
{{/if}}
{{/if}}
{{/unless}}
{{/with}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ class {{> model_templates/classname }}(
{{/if}}
{{> model_templates/property_type_hints }}

{{#if additionalProperties}}
{{> model_templates/new }}
{{else}}
{{> model_templates/new addPropsUnset=true }}
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -2978,4 +2978,17 @@ components:
$ref: "#/components/schemas/ArrayWithValidationsInItems"
required:
- from
- "!reference"
- "!reference"
ObjectWithOptionalTestProp:
type: object
properties:
test:
type: string
ObjectWithAllOfWithReqTestPropFromUnsetAddProp:
allOf:
- $ref: '#/components/schemas/ObjectWithOptionalTestProp'
- type: object
required: [ test ]
properties:
name:
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_additionalproperties_allows_a_schema_which_should_validate_response_bo
@typing.overload
def _post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_additionalproperties_allows_a_schema_which_should_validate_response_bod
@typing.overload
def post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAdditionalpropertiesAllowsASchemaWhichShouldValidateResponseBodyForCon
@typing.overload
def post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_additionalproperties_are_allowed_by_default_response_body_for_content_
@typing.overload
def _post_additionalproperties_are_allowed_by_default_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_additionalproperties_are_allowed_by_default_response_body_for_content_t
@typing.overload
def post_additionalproperties_are_allowed_by_default_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_additionalproperties_are_allowed_by_default_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAdditionalpropertiesAreAllowedByDefaultResponseBodyForContentTypes(Bas
@typing.overload
def post_additionalproperties_are_allowed_by_default_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_additionalproperties_can_exist_by_itself_response_body_for_content_typ
@typing.overload
def _post_additionalproperties_can_exist_by_itself_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_additionalproperties_can_exist_by_itself_response_body_for_content_type
@typing.overload
def post_additionalproperties_can_exist_by_itself_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_additionalproperties_can_exist_by_itself_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAdditionalpropertiesCanExistByItselfResponseBodyForContentTypes(BaseAp
@typing.overload
def post_additionalproperties_can_exist_by_itself_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_additionalproperties_should_not_look_in_applicators_response_body_for_
@typing.overload
def _post_additionalproperties_should_not_look_in_applicators_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_additionalproperties_should_not_look_in_applicators_response_body_for_c
@typing.overload
def post_additionalproperties_should_not_look_in_applicators_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_additionalproperties_should_not_look_in_applicators_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAdditionalpropertiesShouldNotLookInApplicatorsResponseBodyForContentTy
@typing.overload
def post_additionalproperties_should_not_look_in_applicators_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_allof_combined_with_anyof_oneof_response_body_for_content_types_oapg(
@typing.overload
def _post_allof_combined_with_anyof_oneof_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_allof_combined_with_anyof_oneof_response_body_for_content_types(
@typing.overload
def post_allof_combined_with_anyof_oneof_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_allof_combined_with_anyof_oneof_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAllofCombinedWithAnyofOneofResponseBodyForContentTypes(BaseApi):
@typing.overload
def post_allof_combined_with_anyof_oneof_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_allof_response_body_for_content_types_oapg(
@typing.overload
def _post_allof_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_allof_response_body_for_content_types(
@typing.overload
def post_allof_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_allof_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAllofResponseBodyForContentTypes(BaseApi):
@typing.overload
def post_allof_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _post_allof_simple_types_response_body_for_content_types_oapg(
@typing.overload
def _post_allof_simple_types_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -148,6 +149,7 @@ def post_allof_simple_types_response_body_for_content_types(
@typing.overload
def post_allof_simple_types_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -197,6 +199,7 @@ def post(
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BaseApi(api_client.Api):
@typing.overload
def _post_allof_simple_types_response_body_for_content_types_oapg(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -143,6 +144,7 @@ class PostAllofSimpleTypesResponseBodyForContentTypes(BaseApi):
@typing.overload
def post_allof_simple_types_response_body_for_content_types(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down Expand Up @@ -192,6 +194,7 @@ class ApiForpost(BaseApi):
@typing.overload
def post(
self,
skip_deserialization: typing_extensions.Literal[True],
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
Expand Down
Loading

0 comments on commit ac3bb68

Please sign in to comment.