diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py index 26e6450c7..7bf263058 100644 --- a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py +++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/parameters/__init__.py @@ -13,6 +13,9 @@ class ParametersEndpoints: @classmethod def get_common_parameters_overriding_param(cls) -> types.ModuleType: + """ + Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + """ return get_common_parameters_overriding_param @classmethod diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index f7df7582f..f70f53d11 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -44,6 +44,14 @@ def sync_detailed( client: Client, common: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, common=common, @@ -62,6 +70,14 @@ async def asyncio_detailed( client: Client, common: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, common=common, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 9f9981bc5..c395867d7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -44,6 +44,14 @@ def sync_detailed( client: Client, common: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, common=common, @@ -62,6 +70,14 @@ async def asyncio_detailed( client: Client, common: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + common (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, common=common, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index 89ecdac23..6bec8f41b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -68,6 +68,17 @@ def sync_detailed( null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, ) -> Response[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, not_null_required=not_null_required, @@ -92,6 +103,17 @@ async def asyncio_detailed( null_not_required: Union[Unset, None, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET, ) -> Response[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[Unset, None, datetime.datetime]): + null_not_required (Union[Unset, None, datetime.datetime]): + not_null_not_required (Union[Unset, None, datetime.datetime]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, not_null_required=not_null_required, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index a415417e5..f2336cdea 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -46,6 +46,15 @@ def sync_detailed( client: Client, param_query: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, @@ -66,6 +75,15 @@ async def asyncio_detailed( client: Client, param_query: Union[Unset, None, str] = UNSET, ) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index 78eb855da..b09c9f940 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -10,7 +10,7 @@ def _get_kwargs( param_path: str, *, client: Client, - param_query: str = "overriden_in_GET", + param_query: str = "overridden_in_GET", ) -> Dict[str, Any]: url = "{}/common_parameters_overriding/{param}".format(client.base_url, param=param_path) @@ -44,8 +44,19 @@ def sync_detailed( param_path: str, *, client: Client, - param_query: str = "overriden_in_GET", + param_query: str = "overridden_in_GET", ) -> Response[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, @@ -64,8 +75,19 @@ async def asyncio_detailed( param_path: str, *, client: Client, - param_query: str = "overriden_in_GET", + param_query: str = "overridden_in_GET", ) -> Response[Any]: + """Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code + + Args: + param_path (str): + param_query (str): A parameter with the same name as another. Default: + 'overridden_in_GET'. Example: an example string. + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index 067032a7f..2e016adbf 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -56,6 +56,17 @@ def sync_detailed( param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, ) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, @@ -80,6 +91,17 @@ async def asyncio_detailed( param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, ) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, None, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param_path=param_path, client=client, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index db68369c3..cfa48f320 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -46,6 +46,17 @@ def sync_detailed( *, client: Client, ) -> Response[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param4=param4, param2=param2, @@ -70,6 +81,17 @@ async def asyncio_detailed( *, client: Client, ) -> Response[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( param4=param4, param2=param2, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 322429ec6..c3e429627 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -36,6 +36,11 @@ def sync_detailed( *, client: Client, ) -> Response[Any]: + """ + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) @@ -52,6 +57,11 @@ async def asyncio_detailed( *, client: Client, ) -> Response[Any]: + """ + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py index 74d6fc26c..8ee63b9a1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py @@ -119,6 +119,25 @@ def sync_detailed( model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, ) -> Response[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -157,7 +176,24 @@ def sync( model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, ) -> Optional[Union[Any, HTTPValidationError]]: - """ """ + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return sync_detailed( client=client, @@ -190,6 +226,25 @@ async def asyncio_detailed( model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, ) -> Response[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, string_prop=string_prop, @@ -226,7 +281,24 @@ async def asyncio( model_prop: ModelWithUnionProperty, required_model_prop: ModelWithUnionProperty, ) -> Optional[Union[Any, HTTPValidationError]]: - """ """ + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + int_prop (int): Default: 7. + boolean_prop (bool): + list_prop (List[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, None, Unset, float]): Default: 0.6. + enum_prop (AnEnum): For testing Enums in all the ways they can be used + model_prop (ModelWithUnionProperty): + required_model_prop (ModelWithUnionProperty): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index 243e145c6..0b903c8bf 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -44,6 +44,14 @@ def sync_detailed( *, client: Client, ) -> Response[List[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Returns: + Response[List[bool]] + """ + kwargs = _get_kwargs( client=client, ) @@ -60,7 +68,13 @@ def sync( *, client: Client, ) -> Optional[List[bool]]: - """Get a list of booleans""" + """Get Basic List Of Booleans + + Get a list of booleans + + Returns: + Response[List[bool]] + """ return sync_detailed( client=client, @@ -71,6 +85,14 @@ async def asyncio_detailed( *, client: Client, ) -> Response[List[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Returns: + Response[List[bool]] + """ + kwargs = _get_kwargs( client=client, ) @@ -85,7 +107,13 @@ async def asyncio( *, client: Client, ) -> Optional[List[bool]]: - """Get a list of booleans""" + """Get Basic List Of Booleans + + Get a list of booleans + + Returns: + Response[List[bool]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 99200c0b8..5b401c1c9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -44,6 +44,14 @@ def sync_detailed( *, client: Client, ) -> Response[List[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Returns: + Response[List[float]] + """ + kwargs = _get_kwargs( client=client, ) @@ -60,7 +68,13 @@ def sync( *, client: Client, ) -> Optional[List[float]]: - """Get a list of floats""" + """Get Basic List Of Floats + + Get a list of floats + + Returns: + Response[List[float]] + """ return sync_detailed( client=client, @@ -71,6 +85,14 @@ async def asyncio_detailed( *, client: Client, ) -> Response[List[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Returns: + Response[List[float]] + """ + kwargs = _get_kwargs( client=client, ) @@ -85,7 +107,13 @@ async def asyncio( *, client: Client, ) -> Optional[List[float]]: - """Get a list of floats""" + """Get Basic List Of Floats + + Get a list of floats + + Returns: + Response[List[float]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index cfb47195a..6b229d1a5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -44,6 +44,14 @@ def sync_detailed( *, client: Client, ) -> Response[List[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Returns: + Response[List[int]] + """ + kwargs = _get_kwargs( client=client, ) @@ -60,7 +68,13 @@ def sync( *, client: Client, ) -> Optional[List[int]]: - """Get a list of integers""" + """Get Basic List Of Integers + + Get a list of integers + + Returns: + Response[List[int]] + """ return sync_detailed( client=client, @@ -71,6 +85,14 @@ async def asyncio_detailed( *, client: Client, ) -> Response[List[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Returns: + Response[List[int]] + """ + kwargs = _get_kwargs( client=client, ) @@ -85,7 +107,13 @@ async def asyncio( *, client: Client, ) -> Optional[List[int]]: - """Get a list of integers""" + """Get Basic List Of Integers + + Get a list of integers + + Returns: + Response[List[int]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 9a2542862..e42f0849a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -44,6 +44,14 @@ def sync_detailed( *, client: Client, ) -> Response[List[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Returns: + Response[List[str]] + """ + kwargs = _get_kwargs( client=client, ) @@ -60,7 +68,13 @@ def sync( *, client: Client, ) -> Optional[List[str]]: - """Get a list of strings""" + """Get Basic List Of Strings + + Get a list of strings + + Returns: + Response[List[str]] + """ return sync_detailed( client=client, @@ -71,6 +85,14 @@ async def asyncio_detailed( *, client: Client, ) -> Response[List[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Returns: + Response[List[str]] + """ + kwargs = _get_kwargs( client=client, ) @@ -85,7 +107,13 @@ async def asyncio( *, client: Client, ) -> Optional[List[str]]: - """Get a list of strings""" + """Get Basic List Of Strings + + Get a list of strings + + Returns: + Response[List[str]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index 24410bef0..d80c1917b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -100,6 +100,20 @@ def sync_detailed( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], ) -> Response[Union[HTTPValidationError, List[AModel]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Returns: + Response[Union[HTTPValidationError, List[AModel]]] + """ + kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -124,7 +138,19 @@ def sync( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], ) -> Optional[Union[HTTPValidationError, List[AModel]]]: - """Get a list of things""" + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Returns: + Response[Union[HTTPValidationError, List[AModel]]] + """ return sync_detailed( client=client, @@ -143,6 +169,20 @@ async def asyncio_detailed( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], ) -> Response[Union[HTTPValidationError, List[AModel]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Returns: + Response[Union[HTTPValidationError, List[AModel]]] + """ + kwargs = _get_kwargs( client=client, an_enum_value=an_enum_value, @@ -165,7 +205,19 @@ async def asyncio( an_enum_value_with_only_null: List[None], some_date: Union[datetime.date, datetime.datetime], ) -> Optional[Union[HTTPValidationError, List[AModel]]]: - """Get a list of things""" + """Get List + + Get a list of things + + Args: + an_enum_value (List[AnEnum]): + an_enum_value_with_null (List[Optional[AnEnumWithNull]]): + an_enum_value_with_only_null (List[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Returns: + Response[Union[HTTPValidationError, List[AModel]]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py index 3f0ce55ac..59ee29ab6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py @@ -60,6 +60,15 @@ def sync_detailed( client: Client, int_enum: AnIntEnum, ) -> Response[Union[Any, HTTPValidationError]]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -78,7 +87,14 @@ def sync( client: Client, int_enum: AnIntEnum, ) -> Optional[Union[Any, HTTPValidationError]]: - """ """ + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return sync_detailed( client=client, @@ -91,6 +107,15 @@ async def asyncio_detailed( client: Client, int_enum: AnIntEnum, ) -> Response[Union[Any, HTTPValidationError]]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, int_enum=int_enum, @@ -107,7 +132,14 @@ async def asyncio( client: Client, int_enum: AnIntEnum, ) -> Optional[Union[Any, HTTPValidationError]]: - """ """ + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index e74b82581..f5303c25b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -55,6 +55,17 @@ def sync_detailed( client: Client, json_body: AModel, ) -> Response[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -73,7 +84,16 @@ def sync( client: Client, json_body: AModel, ) -> Optional[Union[Any, HTTPValidationError]]: - """Try sending a JSON body""" + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return sync_detailed( client=client, @@ -86,6 +106,17 @@ async def asyncio_detailed( client: Client, json_body: AModel, ) -> Response[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -102,7 +133,16 @@ async def asyncio( client: Client, json_body: AModel, ) -> Optional[Union[Any, HTTPValidationError]]: - """Try sending a JSON body""" + """Json Body + + Try sending a JSON body + + Args: + json_body (AModel): A Model for testing all the ways custom objects can be used + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index 598632a49..cce9dfb1e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -36,6 +36,12 @@ def sync_detailed( *, client: Client, ) -> Response[Any]: + """No Response + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) @@ -52,6 +58,12 @@ async def asyncio_detailed( *, client: Client, ) -> Response[Any]: + """No Response + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index 34405a2b0..f8a18d050 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -45,6 +45,12 @@ def sync_detailed( *, client: Client, ) -> Response[File]: + """Octet Stream + + Returns: + Response[File] + """ + kwargs = _get_kwargs( client=client, ) @@ -61,7 +67,11 @@ def sync( *, client: Client, ) -> Optional[File]: - """ """ + """Octet Stream + + Returns: + Response[File] + """ return sync_detailed( client=client, @@ -72,6 +82,12 @@ async def asyncio_detailed( *, client: Client, ) -> Response[File]: + """Octet Stream + + Returns: + Response[File] + """ + kwargs = _get_kwargs( client=client, ) @@ -86,7 +102,11 @@ async def asyncio( *, client: Client, ) -> Optional[File]: - """ """ + """Octet Stream + + Returns: + Response[File] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index ecd55c9e7..f7fa6adce 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -40,6 +40,14 @@ def sync_detailed( client: Client, form_data: AFormData, ) -> Response[Any]: + """Post from data + + Post form data + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, form_data=form_data, @@ -58,6 +66,14 @@ async def asyncio_detailed( client: Client, form_data: AFormData, ) -> Response[Any]: + """Post from data + + Post form data + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, form_data=form_data, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index 8b076b59c..4770fd7a6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -53,6 +53,15 @@ def sync_detailed( client: Client, json_body: str, ) -> Response[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + json_body (str): + + Returns: + Response[Union[HTTPValidationError, str]] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -71,7 +80,14 @@ def sync( client: Client, json_body: str, ) -> Optional[Union[HTTPValidationError, str]]: - """ """ + """Json Body Which is String + + Args: + json_body (str): + + Returns: + Response[Union[HTTPValidationError, str]] + """ return sync_detailed( client=client, @@ -84,6 +100,15 @@ async def asyncio_detailed( client: Client, json_body: str, ) -> Response[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + json_body (str): + + Returns: + Response[Union[HTTPValidationError, str]] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -100,7 +125,14 @@ async def asyncio( client: Client, json_body: str, ) -> Optional[Union[HTTPValidationError, str]]: - """ """ + """Json Body Which is String + + Args: + json_body (str): + + Returns: + Response[Union[HTTPValidationError, str]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 655150038..6c40f6309 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -51,6 +51,15 @@ def sync_detailed( client: Client, json_body: TestInlineObjectsJsonBody, ) -> Response[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Returns: + Response[TestInlineObjectsResponse200] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -69,7 +78,14 @@ def sync( client: Client, json_body: TestInlineObjectsJsonBody, ) -> Optional[TestInlineObjectsResponse200]: - """ """ + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Returns: + Response[TestInlineObjectsResponse200] + """ return sync_detailed( client=client, @@ -82,6 +98,15 @@ async def asyncio_detailed( client: Client, json_body: TestInlineObjectsJsonBody, ) -> Response[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Returns: + Response[TestInlineObjectsResponse200] + """ + kwargs = _get_kwargs( client=client, json_body=json_body, @@ -98,7 +123,14 @@ async def asyncio( client: Client, json_body: TestInlineObjectsJsonBody, ) -> Optional[TestInlineObjectsResponse200]: - """ """ + """Test Inline Objects + + Args: + json_body (TestInlineObjectsJsonBody): + + Returns: + Response[TestInlineObjectsResponse200] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 2b9191822..6cd6a559f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -40,6 +40,17 @@ def sync_detailed( client: Client, my_token: str, ) -> Response[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, my_token=my_token, @@ -58,6 +69,17 @@ async def asyncio_detailed( client: Client, my_token: str, ) -> Response[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, my_token=my_token, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index 84f1581d5..29fc0f734 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -36,6 +36,12 @@ def sync_detailed( *, client: Client, ) -> Response[Any]: + """Unsupported Content + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) @@ -52,6 +58,12 @@ async def asyncio_detailed( *, client: Client, ) -> Response[Any]: + """Unsupported Content + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 652d8c323..a3f4d03c7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -60,6 +60,18 @@ def sync_detailed( multipart_data: BodyUploadFileTestsUploadPost, keep_alive: Union[Unset, bool] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (BodyUploadFileTestsUploadPost): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -80,7 +92,17 @@ def sync( multipart_data: BodyUploadFileTestsUploadPost, keep_alive: Union[Unset, bool] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: - """Upload a file""" + """Upload File + + Upload a file + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (BodyUploadFileTestsUploadPost): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return sync_detailed( client=client, @@ -95,6 +117,18 @@ async def asyncio_detailed( multipart_data: BodyUploadFileTestsUploadPost, keep_alive: Union[Unset, bool] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (BodyUploadFileTestsUploadPost): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -113,7 +147,17 @@ async def asyncio( multipart_data: BodyUploadFileTestsUploadPost, keep_alive: Union[Unset, bool] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: - """Upload a file""" + """Upload File + + Upload a file + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (BodyUploadFileTestsUploadPost): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index 8c9209a31..553bc619a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -63,6 +63,18 @@ def sync_detailed( multipart_data: List[File], keep_alive: Union[Unset, bool] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (List[File]): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -83,7 +95,17 @@ def sync( multipart_data: List[File], keep_alive: Union[Unset, bool] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: - """Upload several files in the same request""" + """Upload multiple files + + Upload several files in the same request + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (List[File]): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return sync_detailed( client=client, @@ -98,6 +120,18 @@ async def asyncio_detailed( multipart_data: List[File], keep_alive: Union[Unset, bool] = UNSET, ) -> Response[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (List[File]): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + kwargs = _get_kwargs( client=client, multipart_data=multipart_data, @@ -116,7 +150,17 @@ async def asyncio( multipart_data: List[File], keep_alive: Union[Unset, bool] = UNSET, ) -> Optional[Union[Any, HTTPValidationError]]: - """Upload several files in the same request""" + """Upload multiple files + + Upload several files in the same request + + Args: + keep_alive (Union[Unset, bool]): + multipart_data (List[File]): + + Returns: + Response[Union[Any, HTTPValidationError]] + """ return ( await asyncio_detailed( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index 87f924558..6e897586b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -44,6 +44,14 @@ def sync_detailed( client: Client, import_: str, ) -> Response[Any]: + """ + Args: + import_ (str): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, import_=import_, @@ -62,6 +70,14 @@ async def asyncio_detailed( client: Client, import_: str, ) -> Response[Any]: + """ + Args: + import_ (str): + + Returns: + Response[Any] + """ + kwargs = _get_kwargs( client=client, import_=import_, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py index f5c34f5be..958b24ab5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py @@ -9,7 +9,11 @@ @attr.s(auto_attribs=True) class AFormData: - """ """ + """ + Attributes: + an_required_field (str): + an_optional_field (Union[Unset, str]): + """ an_required_field: str an_optional_field: Union[Unset, str] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py index a7a68874a..48cd1ca77 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py @@ -16,7 +16,32 @@ @attr.s(auto_attribs=True) class AModel: - """A Model for testing all the ways custom objects can be used""" + """A Model for testing all the ways custom objects can be used + + Attributes: + an_enum_value (AnEnum): For testing Enums in all the ways they can be used + an_allof_enum_with_overridden_default (AnAllOfEnum): Default: AnAllOfEnum.OVERRIDDEN_DEFAULT. + a_camel_date_time (Union[datetime.date, datetime.datetime]): + a_date (datetime.date): + required_not_nullable (str): + one_of_models (Union[Any, FreeFormModel, ModelWithUnionProperty]): + model (ModelWithUnionProperty): + any_value (Union[Unset, Any]): + an_optional_allof_enum (Union[Unset, AnAllOfEnum]): + nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]): + a_nullable_date (Optional[datetime.date]): + a_not_required_date (Union[Unset, datetime.date]): + attr_1_leading_digit (Union[Unset, str]): + required_nullable (Optional[str]): + not_required_nullable (Union[Unset, None, str]): + not_required_not_nullable (Union[Unset, str]): + nullable_one_of_models (Union[FreeFormModel, ModelWithUnionProperty, None]): + not_required_one_of_models (Union[FreeFormModel, ModelWithUnionProperty, Unset]): + not_required_nullable_one_of_models (Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str]): + nullable_model (Optional[ModelWithUnionProperty]): + not_required_model (Union[Unset, ModelWithUnionProperty]): + not_required_nullable_model (Union[Unset, None, ModelWithUnionProperty]): + """ an_enum_value: AnEnum a_camel_date_time: Union[datetime.date, datetime.datetime] diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py index c71bf8dcf..1f1c05565 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -13,7 +13,39 @@ @attr.s(auto_attribs=True) class AModelWithPropertiesReferenceThatAreNotObject: - """ """ + """ + Attributes: + enum_properties_ref (List[AnEnum]): + str_properties_ref (List[str]): + date_properties_ref (List[datetime.date]): + datetime_properties_ref (List[datetime.datetime]): + int32_properties_ref (List[int]): + int64_properties_ref (List[int]): + float_properties_ref (List[float]): + double_properties_ref (List[float]): + file_properties_ref (List[File]): + bytestream_properties_ref (List[str]): + enum_properties (List[AnEnum]): + str_properties (List[str]): + date_properties (List[datetime.date]): + datetime_properties (List[datetime.datetime]): + int32_properties (List[int]): + int64_properties (List[int]): + float_properties (List[float]): + double_properties (List[float]): + file_properties (List[File]): + bytestream_properties (List[str]): + enum_property_ref (AnEnum): For testing Enums in all the ways they can be used + str_property_ref (str): + date_property_ref (datetime.date): + datetime_property_ref (datetime.datetime): + int32_property_ref (int): + int64_property_ref (int): + float_property_ref (float): + double_property_ref (float): + file_property_ref (File): + bytestream_property_ref (str): + """ enum_properties_ref: List[AnEnum] str_properties_ref: List[str] diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py index 515374d19..5a46393fd 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py @@ -10,7 +10,12 @@ @attr.s(auto_attribs=True) class AllOfSubModel: - """ """ + """ + Attributes: + a_sub_property (Union[Unset, str]): + type (Union[Unset, str]): + type_enum (Union[Unset, AllOfSubModelTypeEnum]): + """ a_sub_property: Union[Unset, str] = UNSET type: Union[Unset, str] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py index 5fabb03e4..c339eebd3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py @@ -11,7 +11,12 @@ @attr.s(auto_attribs=True) class AnotherAllOfSubModel: - """ """ + """ + Attributes: + another_sub_property (Union[Unset, str]): + type (Union[Unset, AnotherAllOfSubModelType]): + type_enum (Union[Unset, AnotherAllOfSubModelTypeEnum]): + """ another_sub_property: Union[Unset, str] = UNSET type: Union[Unset, AnotherAllOfSubModelType] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py index 683025d4e..200dbec53 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py @@ -22,7 +22,18 @@ @attr.s(auto_attribs=True) class BodyUploadFileTestsUploadPost: - """ """ + """ + Attributes: + some_file (File): + some_object (BodyUploadFileTestsUploadPostSomeObject): + some_optional_file (Union[Unset, File]): + some_string (Union[Unset, str]): Default: 'some_default_string'. + some_number (Union[Unset, float]): + some_array (Union[Unset, List[float]]): + some_optional_object (Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject]): + some_nullable_object (Optional[BodyUploadFileTestsUploadPostSomeNullableObject]): + some_enum (Union[Unset, DifferentEnum]): An enumeration. + """ some_file: File some_object: BodyUploadFileTestsUploadPostSomeObject diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py index b2ce8457e..522355858 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class BodyUploadFileTestsUploadPostAdditionalProperty: - """ """ + """ + Attributes: + foo (Union[Unset, str]): + """ foo: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py index f97e865aa..e809b413e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class BodyUploadFileTestsUploadPostSomeNullableObject: - """ """ + """ + Attributes: + bar (Union[Unset, str]): + """ bar: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py index 85eaba04e..8a4f123de 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py @@ -7,7 +7,11 @@ @attr.s(auto_attribs=True) class BodyUploadFileTestsUploadPostSomeObject: - """ """ + """ + Attributes: + num (float): + text (str): + """ num: float text: str diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py index f983f83f4..a32d5f979 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py @@ -7,7 +7,10 @@ @attr.s(auto_attribs=True) class BodyUploadFileTestsUploadPostSomeOptionalObject: - """ """ + """ + Attributes: + foo (str): + """ foo: str additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py b/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py index e777fcc87..21855e7e5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py @@ -10,7 +10,10 @@ @attr.s(auto_attribs=True) class HTTPValidationError: - """ """ + """ + Attributes: + detail (Union[Unset, List[ValidationError]]): + """ detail: Union[Unset, List[ValidationError]] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py index 415f27486..3dfc48a36 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py @@ -11,7 +11,13 @@ @attr.s(auto_attribs=True) class ModelFromAllOf: - """ """ + """ + Attributes: + a_sub_property (Union[Unset, str]): + type (Union[Unset, AnotherAllOfSubModelType]): + type_enum (Union[Unset, AnotherAllOfSubModelTypeEnum]): + another_sub_property (Union[Unset, str]): + """ a_sub_property: Union[Unset, str] = UNSET type: Union[Unset, AnotherAllOfSubModelType] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py index a2e168758..6e3faebf4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py @@ -12,7 +12,10 @@ @attr.s(auto_attribs=True) class ModelWithAdditionalPropertiesInlined: - """ """ + """ + Attributes: + a_number (Union[Unset, float]): + """ a_number: Union[Unset, float] = UNSET additional_properties: Dict[str, ModelWithAdditionalPropertiesInlinedAdditionalProperty] = attr.ib( diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py index 490f6e34c..66b487c00 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class ModelWithAdditionalPropertiesInlinedAdditionalProperty: - """ """ + """ + Attributes: + extra_props_prop (Union[Unset, str]): + """ extra_props_prop: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py index ee28313bd..40d384759 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py @@ -12,7 +12,10 @@ @attr.s(auto_attribs=True) class ModelWithPrimitiveAdditionalProperties: - """ """ + """ + Attributes: + a_date_holder (Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder]): + """ a_date_holder: Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder] = UNSET additional_properties: Dict[str, str] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py index e28a14e91..a3713efe2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py @@ -10,7 +10,10 @@ @attr.s(auto_attribs=True) class ModelWithPropertyRef: - """ """ + """ + Attributes: + inner (Union[Unset, ModelName]): + """ inner: Union[Unset, ModelName] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py index b7fa116e3..9afb3cdde 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py @@ -11,7 +11,10 @@ @attr.s(auto_attribs=True) class ModelWithUnionProperty: - """ """ + """ + Attributes: + a_property (Union[AnEnum, AnIntEnum, Unset]): + """ a_property: Union[AnEnum, AnIntEnum, Unset] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py index 27e91a80a..e8537d13d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py @@ -11,7 +11,10 @@ @attr.s(auto_attribs=True) class ModelWithUnionPropertyInlined: - """ """ + """ + Attributes: + fruit (Union[ModelWithUnionPropertyInlinedFruitType0, ModelWithUnionPropertyInlinedFruitType1, Unset]): + """ fruit: Union[ModelWithUnionPropertyInlinedFruitType0, ModelWithUnionPropertyInlinedFruitType1, Unset] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py index 333d822c7..466bfe252 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class ModelWithUnionPropertyInlinedFruitType0: - """ """ + """ + Attributes: + apples (Union[Unset, str]): + """ apples: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py index d2020747c..a0dae4331 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class ModelWithUnionPropertyInlinedFruitType1: - """ """ + """ + Attributes: + bananas (Union[Unset, str]): + """ bananas: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_json_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_json_body.py index e74ed557b..66f8ce42c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_json_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_json_body.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class TestInlineObjectsJsonBody: - """ """ + """ + Attributes: + a_property (Union[Unset, str]): + """ a_property: Union[Unset, str] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py index 7c6aa6fb2..3f9c1c944 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py @@ -9,7 +9,10 @@ @attr.s(auto_attribs=True) class TestInlineObjectsResponse200: - """ """ + """ + Attributes: + a_property (Union[Unset, str]): + """ a_property: Union[Unset, str] = UNSET diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py b/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py index 8bbb20c76..e2f6539ee 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py @@ -7,7 +7,12 @@ @attr.s(auto_attribs=True) class ValidationError: - """ """ + """ + Attributes: + loc (List[str]): + msg (str): + type (str): + """ loc: List[str] msg: str diff --git a/end_to_end_tests/openapi.json b/end_to_end_tests/openapi.json index 46db24487..0cb28e6f9 100644 --- a/end_to_end_tests/openapi.json +++ b/end_to_end_tests/openapi.json @@ -793,8 +793,8 @@ } }, "/common_parameters_overriding/{param}": { - "description": "Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code", "get": { + "description": "Test that if you have an overriding property from `PathItem` in `Operation`, it produces valid code", "tags": [ "parameters" ], @@ -804,8 +804,10 @@ "in": "query", "required": true, "schema": { + "description": "A parameter with the same name as another.", + "example": "an example string", "type": "string", - "default": "overriden_in_GET" + "default": "overridden_in_GET" } } ], diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index af368f8d7..359d6022c 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -416,6 +416,21 @@ def response_type(self) -> str: return self.responses[0].prop.get_type_string() return f"Union[{', '.join(types)}]" + def iter_all_parameters(self) -> Iterator[Property]: + """Iterate through all the parameters of this endpoint""" + yield from self.path_parameters.values() + yield from self.query_parameters.values() + yield from self.header_parameters.values() + yield from self.cookie_parameters.values() + if self.multipart_body: + yield self.multipart_body + if self.json_body: + yield self.json_body + + def list_all_parameters(self) -> List[Property]: + """Return a List of all the parameters of this endpoint""" + return list(self.iter_all_parameters()) + @dataclass class GeneratorData: diff --git a/openapi_python_client/parser/properties/__init__.py b/openapi_python_client/parser/properties/__init__.py index 98707cfa3..d6e1457c0 100644 --- a/openapi_python_client/parser/properties/__init__.py +++ b/openapi_python_client/parser/properties/__init__.py @@ -271,6 +271,8 @@ def _string_based_property( default=convert("datetime.datetime", data.default), nullable=data.nullable, python_name=python_name, + description=data.description, + example=data.example, ) if string_format == "date": return DateProperty( @@ -279,6 +281,8 @@ def _string_based_property( default=convert("datetime.date", data.default), nullable=data.nullable, python_name=python_name, + description=data.description, + example=data.example, ) if string_format == "binary": return FileProperty( @@ -287,6 +291,8 @@ def _string_based_property( default=None, nullable=data.nullable, python_name=python_name, + description=data.description, + example=data.example, ) return StringProperty( name=name, @@ -295,6 +301,8 @@ def _string_based_property( pattern=data.pattern, nullable=data.nullable, python_name=python_name, + description=data.description, + example=data.example, ) @@ -348,6 +356,8 @@ def build_enum_property( nullable=False, default="None", python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=None, + example=None, ), schemas, ) @@ -374,6 +384,8 @@ def build_enum_property( value_type=value_type, default=None, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ) default = get_enum_default(prop, data) @@ -451,6 +463,8 @@ def build_union_property( inner_properties=sub_properties, nullable=data.nullable, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) @@ -490,6 +504,8 @@ def build_list_property( inner_property=inner_prop, nullable=data.nullable, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) @@ -573,6 +589,8 @@ def _property_from_data( required=required, nullable=data.nullable, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) @@ -584,6 +602,8 @@ def _property_from_data( required=required, nullable=data.nullable, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) @@ -595,6 +615,8 @@ def _property_from_data( default=convert("bool", data.default), nullable=data.nullable, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) @@ -613,6 +635,8 @@ def _property_from_data( nullable=False, default=None, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + description=data.description, + example=data.example, ), schemas, ) diff --git a/openapi_python_client/parser/properties/model_property.py b/openapi_python_client/parser/properties/model_property.py index 0cfb7a902..cfaea08b0 100644 --- a/openapi_python_client/parser/properties/model_property.py +++ b/openapi_python_client/parser/properties/model_property.py @@ -256,6 +256,7 @@ def build_model_property( name=name, additional_properties=additional_properties, python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + example=data.example, ) if class_info.name in schemas.classes_by_name: error = PropertyError(data=data, detail=f'Attempted to generate duplicate models with name "{class_info.name}"') diff --git a/openapi_python_client/parser/properties/property.py b/openapi_python_client/parser/properties/property.py index af1135bf6..5b7f9ead9 100644 --- a/openapi_python_client/parser/properties/property.py +++ b/openapi_python_client/parser/properties/property.py @@ -30,6 +30,8 @@ class Property: _json_type_string: ClassVar[str] = "" # Type of the property after JSON serialization default: Optional[str] = attr.ib() python_name: PythonIdentifier + description: Optional[str] = attr.ib() + example: Optional[str] = attr.ib() template: ClassVar[Optional[str]] = None json_is_dict: ClassVar[bool] = False @@ -107,3 +109,12 @@ def to_string(self) -> str: if default is not None: return f"{self.python_name}: {self.get_type_string()} = {default}" return f"{self.python_name}: {self.get_type_string()}" + + def to_docstring(self) -> str: + """Returns property docstring""" + doc = f"{self.python_name} ({self.get_type_string()}): {self.description or ''}" + if self.default: + doc += f" Default: {self.default}." + if self.example: + doc += f" Example: {self.example}." + return doc diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index 98300640d..2aaa112d5 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -1,6 +1,6 @@ __all__ = ["Response", "response_from_data"] -from typing import Tuple, Union +from typing import Optional, Tuple, Union import attr @@ -28,7 +28,7 @@ class Response: } -def empty_response(*, status_code: int, response_name: str, config: Config) -> Response: +def empty_response(*, status_code: int, response_name: str, config: Config, description: Optional[str]) -> Response: """Return an untyped response, for when no response type is defined""" return Response( status_code=status_code, @@ -38,6 +38,8 @@ def empty_response(*, status_code: int, response_name: str, config: Config) -> R nullable=False, required=True, python_name=PythonIdentifier(value=response_name, prefix=config.field_prefix), + description=description, + example=None, ), source="None", ) @@ -49,13 +51,21 @@ def response_from_data( """Generate a Response from the OpenAPI dictionary representation of it""" response_name = f"response_{status_code}" - if isinstance(data, oai.Reference) or data.content is None: + if isinstance(data, oai.Reference): return ( - empty_response(status_code=status_code, response_name=response_name, config=config), + empty_response(status_code=status_code, response_name=response_name, config=config, description=None), schemas, ) content = data.content + if not content: + return ( + empty_response( + status_code=status_code, response_name=response_name, config=config, description=data.description + ), + schemas, + ) + for content_type, media_type in content.items(): if content_type in _SOURCE_BY_CONTENT_TYPE: source = _SOURCE_BY_CONTENT_TYPE[content_type] @@ -66,7 +76,9 @@ def response_from_data( if schema_data is None: return ( - empty_response(status_code=status_code, response_name=response_name, config=config), + empty_response( + status_code=status_code, response_name=response_name, config=config, description=data.description + ), schemas, ) diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index a0d1aa32f..36c65d7e2 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -147,3 +147,27 @@ json_body=json_body, {{ parameter.python_name }}={{ parameter.python_name }}, {% endfor %} {% endmacro %} + +{% macro docstring(endpoint, return_string) %} +"""{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}} + +{% endif -%} +{%- if endpoint.description %} {{ endpoint.description | wordwrap(100) }} + +{% endif %} +{% if not endpoint.summary and not endpoint.description %} +{# Leave extra space so that Args or Returns isn't at the top #} + +{% endif %} +{% set all_parameters = endpoint.list_all_parameters() %} +{% if all_parameters %} +Args: + {% for parameter in all_parameters %} + {{ parameter.to_docstring() | wordwrap(90) | indent(8) }} + {% endfor %} + +{% endif %} +Returns: + Response[{{ return_string }}] +""" +{% endmacro %} diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 5ddd2591b..02235516b 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -9,7 +9,8 @@ from ...types import Response, UNSET {{ relative }} {% endfor %} -{% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, json_body, multipart_body, arguments, client, kwargs, parse_response %} +{% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, json_body, multipart_body, + arguments, client, kwargs, parse_response, docstring %} {% set return_string = endpoint.response_type() %} {% set parsed_responses = (endpoint.responses | length > 0) and return_string != "Any" %} @@ -87,6 +88,8 @@ def _build_response(*, response: httpx.Response) -> Response[{{ return_string }} def sync_detailed( {{ arguments(endpoint) | indent(4) }} ) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string) | indent(4) }} + kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -102,7 +105,7 @@ def sync_detailed( def sync( {{ arguments(endpoint) | indent(4) }} ) -> Optional[{{ return_string }}]: - """ {{ endpoint.description }} """ + {{ docstring(endpoint, return_string) | indent(4) }} return sync_detailed( {{ kwargs(endpoint) }} @@ -112,6 +115,8 @@ def sync( async def asyncio_detailed( {{ arguments(endpoint) | indent(4) }} ) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string) | indent(4) }} + kwargs = _get_kwargs( {{ kwargs(endpoint) }} ) @@ -127,9 +132,10 @@ async def asyncio_detailed( async def asyncio( {{ arguments(endpoint) | indent(4) }} ) -> Optional[{{ return_string }}]: - """ {{ endpoint.description }} """ + {{ docstring(endpoint, return_string) | indent(4) }} return (await asyncio_detailed( {{ kwargs(endpoint) }} )).parsed {% endif %} + diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index c4c23c878..49246fa31 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -28,7 +28,28 @@ T = TypeVar("T", bound="{{ class_name }}") @attr.s(auto_attribs=True) class {{ class_name }}: - """ {{ model.description }} """ + """{% if model.title %}{{ model.title | wordwrap(116) }} + + {% endif -%} + {%- if model.description %}{{ model.description | wordwrap(116) }} + + {% endif %} + {% if not model.title and not model.description %} + {# Leave extra space so that a section doesn't start on the first line #} + + {% endif %} + {% if model.example %} + Example: + {{ model.example | string | wordwrap(112) | indent(12) }} + + {% endif %} + {% if model.required_properties or model.optional_properties %} + Attributes: + {% for property in model.required_properties + model.optional_properties %} + {{ property.to_docstring() | wordwrap(112) | indent(12) }} + {% endfor %}{% endif %} + """ + {% for property in model.required_properties + model.optional_properties %} {% if property.default is none and property.required %} {{ property.to_string() }} diff --git a/tests/conftest.py b/tests/conftest.py index dfa885c23..2a683f102 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,7 @@ IntProperty, ListProperty, ModelProperty, + NoneProperty, Property, StringProperty, UnionProperty, @@ -36,6 +37,8 @@ def _factory(**kwargs): "relative_imports": set(), "additional_properties": False, "python_name": "", + "description": "", + "example": "", **kwargs, } return ModelProperty(**kwargs) @@ -125,6 +128,21 @@ def _factory(**kwargs): return _factory +@pytest.fixture +def none_property_factory() -> Callable[..., NoneProperty]: + """ + This fixture surfaces in the test as a function which manufactures StringProperties with defaults. + + You can pass the same params into this as the StringProperty constructor to override defaults. + """ + + def _factory(**kwargs): + kwargs = _common_kwargs(kwargs) + return NoneProperty(**kwargs) + + return _factory + + @pytest.fixture def date_time_property_factory() -> Callable[..., DateTimeProperty]: """ @@ -210,6 +228,8 @@ def _common_kwargs(kwargs: Dict[str, Any]) -> Dict[str, Any]: "required": True, "nullable": False, "default": None, + "description": None, + "example": None, **kwargs, } if not kwargs.get("python_name"): diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index fc5824201..53d96596a 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -427,9 +427,8 @@ def test__add_responses_error(self, mocker): ), ] - def test__add_responses(self, mocker): + def test__add_responses(self, mocker, date_time_property_factory, date_property_factory): from openapi_python_client.parser.openapi import Endpoint, Response - from openapi_python_client.parser.properties import DateProperty, DateTimeProperty response_1_data = mocker.MagicMock() response_2_data = mocker.MagicMock() @@ -444,12 +443,12 @@ def test__add_responses(self, mocker): response_1 = Response( status_code=200, source="source", - prop=DateTimeProperty(name="datetime", required=True, nullable=False, default=None, python_name="datetime"), + prop=date_time_property_factory(name="datetime"), ) response_2 = Response( status_code=404, source="source", - prop=DateProperty(name="date", required=True, nullable=False, default=None, python_name="date"), + prop=date_property_factory(name="date"), ) response_from_data = mocker.patch( f"{MODULE_NAME}.response_from_data", side_effect=[(response_1, schemas_1), (response_2, schemas_2)] @@ -532,23 +531,21 @@ def test_validation_error_when_location_not_supported(self, mocker): with pytest.raises(pydantic.ValidationError): oai.Parameter(name="test", required=True, param_schema=mocker.MagicMock(), param_in="error_location") - def test__add_parameters_with_location_postfix_conflict1(self, mocker): + def test__add_parameters_with_location_postfix_conflict1(self, mocker, property_factory): """Checks when the PythonIdentifier of new parameter already used.""" from openapi_python_client.parser.openapi import Endpoint from openapi_python_client.parser.properties import Property endpoint = self.make_endpoint() - path_prop_conflicted = Property( - name="prop_name_path", required=False, nullable=False, default=None, python_name="prop_name_path" - ) - query_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name") - path_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name") + path_prop_conflicted = property_factory(name="prop_name_path", required=False, nullable=False, default=None) + query_prop = property_factory(name="prop_name", required=False, nullable=False, default=None) + path_prop = property_factory(name="prop_name", required=False, nullable=False, default=None) schemas_1 = mocker.MagicMock() schemas_2 = mocker.MagicMock() schemas_3 = mocker.MagicMock() - property_from_data = mocker.patch( + mocker.patch( f"{MODULE_NAME}.property_from_data", side_effect=[ (path_prop_conflicted, schemas_1), @@ -580,17 +577,14 @@ def test__add_parameters_with_location_postfix_conflict1(self, mocker): assert isinstance(result, ParseError) assert result.detail == "Parameters with same Python identifier `prop_name_path` detected" - def test__add_parameters_with_location_postfix_conflict2(self, mocker): + def test__add_parameters_with_location_postfix_conflict2(self, mocker, property_factory): """Checks when an existing parameter has a conflicting PythonIdentifier after renaming.""" from openapi_python_client.parser.openapi import Endpoint - from openapi_python_client.parser.properties import Property endpoint = self.make_endpoint() - path_prop_conflicted = Property( - name="prop_name_path", required=False, nullable=False, default=None, python_name="prop_name_path" - ) - path_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name") - query_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name") + path_prop_conflicted = property_factory(name="prop_name_path", required=False, nullable=False, default=None) + path_prop = property_factory(name="prop_name", required=False, nullable=False, default=None) + query_prop = property_factory(name="prop_name", required=False, nullable=False, default=None) schemas_1 = mocker.MagicMock() schemas_2 = mocker.MagicMock() schemas_3 = mocker.MagicMock() diff --git a/tests/test_parser/test_properties/test_init.py b/tests/test_parser/test_properties/test_init.py index 91f85435b..3d2de6519 100644 --- a/tests/test_parser/test_properties/test_init.py +++ b/tests/test_parser/test_properties/test_init.py @@ -1,3 +1,4 @@ +from typing import Type from unittest.mock import MagicMock, call import attr @@ -6,7 +7,14 @@ import openapi_python_client.schema as oai from openapi_python_client import Config from openapi_python_client.parser.errors import PropertyError, ValidationError -from openapi_python_client.parser.properties import BooleanProperty, FloatProperty, IntProperty, NoneProperty, Schemas +from openapi_python_client.parser.properties import ( + BooleanProperty, + FloatProperty, + IntProperty, + NoneProperty, + Property, + Schemas, +) MODULE_NAME = "openapi_python_client.parser.properties" @@ -336,7 +344,7 @@ def test_property_from_data_str_enum_with_null(self, enum_property_factory): "ParentAnEnum": prop, } - def test_property_from_data_null_enum(self, enum_property_factory): + def test_property_from_data_null_enum(self, enum_property_factory, none_property_factory): from openapi_python_client.parser.properties import Class, Schemas, property_from_data from openapi_python_client.schema import Schema @@ -350,9 +358,7 @@ def test_property_from_data_null_enum(self, enum_property_factory): name=name, required=required, data=data, schemas=schemas, parent_name="parent", config=Config() ) - assert prop == NoneProperty( - name="my_enum", required=required, nullable=False, default="None", python_name="my_enum" - ) + assert prop == none_property_factory(name="my_enum", required=required, nullable=False, default="None") def test_property_from_data_int_enum(self, enum_property_factory): from openapi_python_client.parser.properties import Class, Schemas, property_from_data @@ -527,12 +533,14 @@ def test_property_from_data_invalid_ref(self, mocker): ("boolean", BooleanProperty, bool), ], ) - def test_property_from_data_simple_types(self, openapi_type, prop_type, python_type): + def test_property_from_data_simple_types(self, openapi_type: str, prop_type: Type[Property], python_type): from openapi_python_client.parser.properties import Schemas, property_from_data name = "test_prop" required = True - data = oai.Schema.construct(type=openapi_type, default=1) + description = "a description" + example = "an example" + data = oai.Schema.construct(type=openapi_type, default=1, description=description, example=example) schemas = Schemas() p, new_schemas = property_from_data( @@ -540,7 +548,13 @@ def test_property_from_data_simple_types(self, openapi_type, prop_type, python_t ) assert p == prop_type( - name=name, required=required, default=python_type(data.default), nullable=False, python_name=name + name=name, + required=required, + default=python_type(data.default), + nullable=False, + python_name=name, + description=description, + example=example, ) assert new_schemas == schemas @@ -552,7 +566,13 @@ def test_property_from_data_simple_types(self, openapi_type, prop_type, python_t name=name, required=required, data=data, schemas=schemas, parent_name="parent", config=MagicMock() ) assert p == prop_type( - name=name, required=required, default=python_type(data.default), nullable=True, python_name=name + name=name, + required=required, + default=python_type(data.default), + nullable=True, + python_name=name, + description=description, + example=example, ) # Test bad default value @@ -655,8 +675,8 @@ def test_property_from_data_union_of_one_element(self, mocker, model_property_fa assert prop == attr.evolve(existing_model, name=name, required=required, nullable=nullable, python_name=name) build_union_property.assert_not_called() - def test_property_from_data_no_valid_props_in_data(self): - from openapi_python_client.parser.properties import AnyProperty, Schemas, property_from_data + def test_property_from_data_no_valid_props_in_data(self, any_property_factory): + from openapi_python_client.parser.properties import Schemas, property_from_data schemas = Schemas() data = oai.Schema() @@ -666,7 +686,7 @@ def test_property_from_data_no_valid_props_in_data(self): name=name, required=True, data=data, schemas=schemas, parent_name="parent", config=MagicMock() ) - assert prop == AnyProperty(name=name, required=True, nullable=False, default=None, python_name=name) + assert prop == any_property_factory(name=name, required=True, nullable=False, default=None) assert new_schemas == schemas def test_property_from_data_validation_error(self, mocker): diff --git a/tests/test_parser/test_properties/test_model_property.py b/tests/test_parser/test_properties/test_model_property.py index 6e1d98166..7b96cb687 100644 --- a/tests/test_parser/test_properties/test_model_property.py +++ b/tests/test_parser/test_properties/test_model_property.py @@ -61,6 +61,8 @@ class TestBuildModelProperty: nullable=False, default=None, python_name="additional_property", + description=None, + example=None, ), ), ], diff --git a/tests/test_parser/test_responses.py b/tests/test_parser/test_responses.py index 8c35cea1f..ab73cfb74 100644 --- a/tests/test_parser/test_responses.py +++ b/tests/test_parser/test_responses.py @@ -7,7 +7,7 @@ MODULE_NAME = "openapi_python_client.parser.responses" -def test_response_from_data_no_content(): +def test_response_from_data_no_content(any_property_factory): from openapi_python_client.parser.responses import Response, response_from_data response, schemas = response_from_data( @@ -20,7 +20,36 @@ def test_response_from_data_no_content(): assert response == Response( status_code=200, - prop=AnyProperty(name="response_200", default=None, nullable=False, required=True, python_name="response_200"), + prop=any_property_factory( + name="response_200", + default=None, + nullable=False, + required=True, + description="", + ), + source="None", + ) + + +def test_response_from_data_reference(any_property_factory): + from openapi_python_client.parser.responses import Response, response_from_data + + response, schemas = response_from_data( + status_code=200, + data=oai.Reference.construct(), + schemas=Schemas(), + parent_name="parent", + config=MagicMock(), + ) + + assert response == Response( + status_code=200, + prop=any_property_factory( + name="response_200", + default=None, + nullable=False, + required=True, + ), source="None", ) @@ -36,7 +65,7 @@ def test_response_from_data_unsupported_content_type(): assert response == ParseError(data=data, detail="Unsupported content_type {'blah': None}") -def test_response_from_data_no_content_schema(): +def test_response_from_data_no_content_schema(any_property_factory): from openapi_python_client.parser.responses import Response, response_from_data data = oai.Response.construct(description="", content={"application/json": oai.MediaType.construct()}) @@ -46,7 +75,13 @@ def test_response_from_data_no_content_schema(): assert response == Response( status_code=200, - prop=AnyProperty(name="response_200", default=None, nullable=False, required=True, python_name="response_200"), + prop=any_property_factory( + name="response_200", + default=None, + nullable=False, + required=True, + description=data.description, + ), source="None", ) diff --git a/tests/test_templates/test_property_templates/test_date_property/test_date_property.py b/tests/test_templates/test_property_templates/test_date_property/test_date_property.py index 02137add4..f5d4aa798 100644 --- a/tests/test_templates/test_property_templates/test_date_property/test_date_property.py +++ b/tests/test_templates/test_property_templates/test_date_property/test_date_property.py @@ -12,6 +12,8 @@ def date_property(required=True, nullable=True, default=None) -> DateProperty: nullable=nullable, default=default, python_name="a_prop", + description="", + example="", )