From f38651e0cea8fb85a54c4391e04a1a773751f151 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 10:05:26 -0800 Subject: [PATCH 1/9] add option to put docstrings on model attributes --- README.md | 10 + .../.gitignore | 23 + .../README.md | 124 ++++ .../my_test_api_client/__init__.py | 8 + .../my_test_api_client/api/__init__.py | 1 + .../my_test_api_client/api/bodies/__init__.py | 0 .../api/bodies/json_like.py | 103 ++++ .../api/bodies/post_bodies_multiple.py | 142 +++++ .../my_test_api_client/api/bodies/refs.py | 103 ++++ .../my_test_api_client/api/config/__init__.py | 0 .../api/config/content_type_override.py | 153 +++++ .../api/default/__init__.py | 0 .../api/default/get_common_parameters.py | 99 ++++ .../api/default/get_models_allof.py | 122 ++++ .../get_models_oneof_with_required_const.py | 159 ++++++ .../api/default/post_common_parameters.py | 99 ++++ .../api/default/reserved_parameters.py | 108 ++++ .../api/defaults/__init__.py | 0 .../defaults/defaults_tests_defaults_post.py | 363 ++++++++++++ .../my_test_api_client/api/enums/__init__.py | 0 .../enums/bool_enum_tests_bool_enum_post.py | 101 ++++ .../api/enums/int_enum_tests_int_enum_post.py | 103 ++++ .../api/location/__init__.py | 0 .../api/location/get_location_header_types.py | 149 +++++ .../get_location_query_optionality.py | 143 +++++ .../my_test_api_client/api/naming/__init__.py | 0 .../api/naming/hyphen_in_path.py | 91 +++ .../api/naming/mixed_case.py | 169 ++++++ ...st_naming_property_conflict_with_import.py | 158 ++++++ .../api/parameter_references/__init__.py | 0 .../get_parameter_references_path_param.py | 141 +++++ .../api/parameters/__init__.py | 0 ...lete_common_parameters_overriding_param.py | 106 ++++ .../get_common_parameters_overriding_param.py | 110 ++++ .../get_same_name_multiple_locations_param.py | 130 +++++ .../parameters/multiple_path_parameters.py | 112 ++++ .../api/responses/__init__.py | 0 ..._responses_unions_simple_before_complex.py | 128 +++++ .../api/responses/text_response.py | 120 ++++ .../my_test_api_client/api/tag1/__init__.py | 0 .../api/tag1/get_tag_with_number.py | 77 +++ .../my_test_api_client/api/tag2/__init__.py | 0 .../api/tag2/get_tag_with_number.py | 77 +++ .../my_test_api_client/api/tests/__init__.py | 0 .../api/tests/callback_test.py | 171 ++++++ .../api/tests/description_with_backslash.py | 83 +++ .../api/tests/get_basic_list_of_booleans.py | 129 +++++ .../api/tests/get_basic_list_of_floats.py | 129 +++++ .../api/tests/get_basic_list_of_integers.py | 129 +++++ .../api/tests/get_basic_list_of_strings.py | 129 +++++ .../api/tests/get_user_list.py | 250 ++++++++ .../tests/json_body_tests_json_body_post.py | 171 ++++++ .../no_response_tests_no_response_get.py | 79 +++ .../octet_stream_tests_octet_stream_get.py | 122 ++++ .../octet_stream_tests_octet_stream_post.py | 162 ++++++ .../api/tests/post_form_data.py | 107 ++++ .../api/tests/post_form_data_inline.py | 107 ++++ .../api/tests/post_tests_json_body_string.py | 162 ++++++ .../api/tests/test_inline_objects.py | 160 ++++++ ..._with_cookie_auth_token_with_cookie_get.py | 104 ++++ ...d_content_tests_unsupported_content_get.py | 79 +++ .../tests/upload_file_tests_upload_post.py | 170 ++++++ ...upload_multiple_files_tests_upload_post.py | 173 ++++++ .../my_test_api_client/api/true_/__init__.py | 0 .../my_test_api_client/api/true_/false_.py | 99 ++++ .../my_test_api_client/client.py | 268 +++++++++ .../my_test_api_client/errors.py | 16 + .../my_test_api_client/models/__init__.py | 171 ++++++ .../models/a_discriminated_union_type_1.py | 53 ++ .../models/a_discriminated_union_type_2.py | 53 ++ .../my_test_api_client/models/a_form_data.py | 63 +++ .../my_test_api_client/models/a_model.py | 508 +++++++++++++++++ ...roperties_reference_that_are_not_object.py | 343 +++++++++++ .../all_of_has_properties_but_no_type.py | 77 +++ ...of_has_properties_but_no_type_type_enum.py | 9 + .../models/all_of_sub_model.py | 77 +++ .../models/all_of_sub_model_type_enum.py | 9 + .../models/an_all_of_enum.py | 11 + ...h_a_circular_ref_in_items_object_a_item.py | 77 +++ ...ems_object_additional_properties_a_item.py | 84 +++ ...ems_object_additional_properties_b_item.py | 84 +++ ...h_a_circular_ref_in_items_object_b_item.py | 77 +++ ...items_object_additional_properties_item.py | 72 +++ ...th_a_recursive_ref_in_items_object_item.py | 69 +++ .../my_test_api_client/models/an_enum.py | 9 + .../models/an_enum_with_null.py | 9 + .../my_test_api_client/models/an_int_enum.py | 10 + .../models/another_all_of_sub_model.py | 85 +++ .../models/another_all_of_sub_model_type.py | 8 + .../another_all_of_sub_model_type_enum.py | 8 + .../body_upload_file_tests_upload_post.py | 422 ++++++++++++++ ...e_tests_upload_post_additional_property.py | 53 ++ ..._tests_upload_post_some_nullable_object.py | 53 ++ ...load_file_tests_upload_post_some_object.py | 60 ++ ..._tests_upload_post_some_optional_object.py | 53 ++ .../models/different_enum.py | 9 + .../my_test_api_client/models/extended.py | 534 ++++++++++++++++++ .../models/free_form_model.py | 41 ++ ...t_location_header_types_int_enum_header.py | 10 + ...ocation_header_types_string_enum_header.py | 10 + .../models/get_models_allof_response_200.py | 100 ++++ ...with_required_const_response_200_type_0.py | 65 +++ ...with_required_const_response_200_type_1.py | 65 +++ .../models/http_validation_error.py | 49 ++ .../my_test_api_client/models/import_.py | 41 ++ .../models/json_like_body.py | 53 ++ .../models/mixed_case_response_200.py | 61 ++ .../models/model_from_all_of.py | 93 +++ .../my_test_api_client/models/model_name.py | 41 ++ .../models/model_reference_with_periods.py | 43 ++ ...odel_with_additional_properties_inlined.py | 72 +++ ..._properties_inlined_additional_property.py | 53 ++ .../model_with_additional_properties_refed.py | 50 ++ .../models/model_with_any_json_properties.py | 100 ++++ ...n_properties_additional_property_type_0.py | 41 ++ .../model_with_backslash_in_description.py | 45 ++ .../models/model_with_circular_ref_a.py | 66 +++ .../models/model_with_circular_ref_b.py | 66 +++ ...circular_ref_in_additional_properties_a.py | 58 ++ ...circular_ref_in_additional_properties_b.py | 58 ++ .../models/model_with_date_time_property.py | 62 ++ .../models/model_with_discriminated_union.py | 98 ++++ .../models/model_with_merged_properties.py | 103 ++++ ...l_with_merged_properties_string_to_enum.py | 9 + .../models/model_with_no_properties.py | 19 + ...el_with_primitive_additional_properties.py | 70 +++ ...ive_additional_properties_a_date_holder.py | 50 ++ .../models/model_with_property_ref.py | 66 +++ .../models/model_with_recursive_ref.py | 60 ++ ..._recursive_ref_in_additional_properties.py | 50 ++ .../models/model_with_union_property.py | 59 ++ .../model_with_union_property_inlined.py | 69 +++ ...ith_union_property_inlined_fruit_type_0.py | 53 ++ ...ith_union_property_inlined_fruit_type_1.py | 53 ++ .../my_test_api_client/models/none.py | 41 ++ .../models/post_bodies_multiple_data_body.py | 53 ++ .../models/post_bodies_multiple_files_body.py | 66 +++ .../models/post_bodies_multiple_json_body.py | 53 ++ .../models/post_form_data_inline_body.py | 63 +++ ...ming_property_conflict_with_import_body.py | 63 +++ ...perty_conflict_with_import_response_200.py | 63 +++ ...ions_simple_before_complex_response_200.py | 83 +++ ...ple_before_complex_response_200a_type_1.py | 41 ++ .../models/test_inline_objects_body.py | 33 ++ .../test_inline_objects_response_200.py | 33 ++ .../models/validation_error.py | 47 ++ .../my_test_api_client/py.typed | 1 + .../my_test_api_client/types.py | 46 ++ .../pyproject.toml | 27 + .../docstrings_on_attributes.config.yml | 15 + end_to_end_tests/regen_golden_record.py | 110 ++-- end_to_end_tests/test_end_to_end.py | 10 + integration-tests/pyproject.toml | 11 +- openapi_python_client/__init__.py | 1 + openapi_python_client/config.py | 3 + openapi_python_client/templates/helpers.jinja | 4 +- .../templates/model.py.jinja | 17 +- 157 files changed, 12600 insertions(+), 67 deletions(-) create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/.gitignore create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/README.md create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/errors.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/py.typed create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/pyproject.toml create mode 100644 end_to_end_tests/docstrings_on_attributes.config.yml diff --git a/README.md b/README.md index a184be377..b07e7b29b 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,16 @@ class_overrides: The easiest way to find what needs to be overridden is probably to generate your client and go look at everything in the `models` folder. +### docstrings_on_attributes + +By default, when `openapi-python-client` generates a model class, it includes a list of attributes and their +descriptions in the docstring for the class. If you set this option to `true`, then the attribute descriptions +will be put in docstrings for the attributes themselves, and will not be in the class docstring. + +```yaml +docstrings_on_attributes: true +``` + ### literal_enums By default, `openapi-python-client` generates classes inheriting for `Enum` for enums. It can instead use `Literal` diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/.gitignore b/end_to_end_tests/docstrings-on-attributes-golden-record/.gitignore new file mode 100644 index 000000000..79a2c3d73 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/.gitignore @@ -0,0 +1,23 @@ +__pycache__/ +build/ +dist/ +*.egg-info/ +.pytest_cache/ + +# pyenv +.python-version + +# Environments +.env +.venv + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# JetBrains +.idea/ + +/coverage.xml +/.coverage diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/README.md b/end_to_end_tests/docstrings-on-attributes-golden-record/README.md new file mode 100644 index 000000000..79b20f411 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/README.md @@ -0,0 +1,124 @@ +# my-test-api-client +A client library for accessing My Test API + +## Usage +First, create a client: + +```python +from my_test_api_client import Client + +client = Client(base_url="https://api.example.com") +``` + +If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: + +```python +from my_test_api_client import AuthenticatedClient + +client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +``` + +Now call your endpoint and use your models: + +```python +from my_test_api_client.models import MyDataModel +from my_test_api_client.api.my_tag import get_my_data_model +from my_test_api_client.types import Response + +with client as client: + my_data: MyDataModel = get_my_data_model.sync(client=client) + # or if you need more info (e.g. status_code) + response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +``` + +Or do the same thing with an async version: + +```python +from my_test_api_client.models import MyDataModel +from my_test_api_client.api.my_tag import get_my_data_model +from my_test_api_client.types import Response + +async with client as client: + my_data: MyDataModel = await get_my_data_model.asyncio(client=client) + response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +``` + +By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl="/path/to/certificate_bundle.pem", +) +``` + +You can also disable certificate validation altogether, but beware that **this is a security risk**. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl=False +) +``` + +Things to know: +1. Every path/method combo becomes a Python module with four functions: + 1. `sync`: Blocking request that returns parsed data (if successful) or `None` + 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `asyncio`: Like `sync` but async instead of blocking + 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking + +1. All path/query params, and bodies become method arguments. +1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) +1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default` + +## Advanced customizations + +There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case): + +```python +from my_test_api_client import Client + +def log_request(request): + print(f"Request event hook: {request.method} {request.url} - Waiting for response") + +def log_response(response): + request = response.request + print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") + +client = Client( + base_url="https://api.example.com", + httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, +) + +# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() +``` + +You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url): + +```python +import httpx +from my_test_api_client import Client + +client = Client( + base_url="https://api.example.com", +) +# Note that base_url needs to be re-set, as would any shared cookies, headers, etc. +client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030")) +``` + +## Building / publishing this package +This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: +1. Update the metadata in pyproject.toml (e.g. authors, version) +1. If you're using a private repository, configure it with Poetry + 1. `poetry config repositories. ` + 1. `poetry config http-basic. ` +1. Publish the client with `poetry publish --build -r ` or, if for public PyPI, just `poetry publish --build` + +If you want to install this client into another project without publishing it (e.g. for development) then: +1. If that project **is using Poetry**, you can simply do `poetry add ` from that project +1. If that project is not using Poetry: + 1. Build a wheel with `poetry build -f wheel` + 1. Install that wheel from the other project `pip install ` diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/__init__.py new file mode 100644 index 000000000..3747245da --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing My Test API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/__init__.py new file mode 100644 index 000000000..81f9fa241 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py new file mode 100644 index 000000000..626bacfa6 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py @@ -0,0 +1,103 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.json_like_body import JsonLikeBody +from ...types import Response + + +def _get_kwargs( + *, + body: JsonLikeBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/bodies/json-like", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/vnd+json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: JsonLikeBody, +) -> Response[Any]: + """A content type that works like json but isn't application/json + + Args: + body (JsonLikeBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: JsonLikeBody, +) -> Response[Any]: + """A content type that works like json but isn't application/json + + Args: + body (JsonLikeBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py new file mode 100644 index 000000000..84ec8eee0 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py @@ -0,0 +1,142 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.post_bodies_multiple_data_body import PostBodiesMultipleDataBody +from ...models.post_bodies_multiple_files_body import PostBodiesMultipleFilesBody +from ...models.post_bodies_multiple_json_body import PostBodiesMultipleJsonBody +from ...types import File, Response + + +def _get_kwargs( + *, + body: Union[ + PostBodiesMultipleJsonBody, + File, + PostBodiesMultipleDataBody, + PostBodiesMultipleFilesBody, + ], +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/bodies/multiple", + } + + if isinstance(body, PostBodiesMultipleJsonBody): + _json_body = body.to_dict() + + _kwargs["json"] = _json_body + headers["Content-Type"] = "application/json" + if isinstance(body, File): + _content_body = body.payload + + _kwargs["content"] = _content_body + headers["Content-Type"] = "application/octet-stream" + if isinstance(body, PostBodiesMultipleDataBody): + _data_body = body.to_dict() + + _kwargs["data"] = _data_body + headers["Content-Type"] = "application/x-www-form-urlencoded" + if isinstance(body, PostBodiesMultipleFilesBody): + _files_body = body.to_multipart() + + _kwargs["files"] = _files_body + headers["Content-Type"] = "multipart/form-data" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: Union[ + PostBodiesMultipleJsonBody, + File, + PostBodiesMultipleDataBody, + PostBodiesMultipleFilesBody, + ], +) -> Response[Any]: + """Test multiple bodies + + Args: + body (PostBodiesMultipleJsonBody): + body (File): + body (PostBodiesMultipleDataBody): + body (PostBodiesMultipleFilesBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: Union[ + PostBodiesMultipleJsonBody, + File, + PostBodiesMultipleDataBody, + PostBodiesMultipleFilesBody, + ], +) -> Response[Any]: + """Test multiple bodies + + Args: + body (PostBodiesMultipleJsonBody): + body (File): + body (PostBodiesMultipleDataBody): + body (PostBodiesMultipleFilesBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py new file mode 100644 index 000000000..a79cf178a --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py @@ -0,0 +1,103 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.a_model import AModel +from ...types import Response + + +def _get_kwargs( + *, + body: AModel, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/bodies/refs", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Any]: + """Test request body defined via ref + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Any]: + """Test request body defined via ref + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py new file mode 100644 index 000000000..2bd74aac4 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + *, + body: str, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/config/content-type-override", + } + + _body = body + + _kwargs["json"] = _body + headers["Content-Type"] = "openapi/python/client" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Response[str]: + """Content Type Override + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[str] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Optional[str]: + """Content Type Override + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + str + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Response[str]: + """Content Type Override + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[str] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Optional[str]: + """Content Type Override + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + str + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py new file mode 100644 index 000000000..7de222f55 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -0,0 +1,99 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + common: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["common"] = common + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/common_parameters", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + common: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + common (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + common=common, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + common: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + common (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + common=common, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py new file mode 100644 index 000000000..9d837acd6 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py @@ -0,0 +1,122 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_models_allof_response_200 import GetModelsAllofResponse200 +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/models/allof", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[GetModelsAllofResponse200]: + if response.status_code == 200: + response_200 = GetModelsAllofResponse200.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[GetModelsAllofResponse200]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[GetModelsAllofResponse200]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetModelsAllofResponse200] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[GetModelsAllofResponse200]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetModelsAllofResponse200 + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[GetModelsAllofResponse200]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetModelsAllofResponse200] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[GetModelsAllofResponse200]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetModelsAllofResponse200 + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py new file mode 100644 index 000000000..85f68fb7c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py @@ -0,0 +1,159 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_models_oneof_with_required_const_response_200_type_0 import ( + GetModelsOneofWithRequiredConstResponse200Type0, +) +from ...models.get_models_oneof_with_required_const_response_200_type_1 import ( + GetModelsOneofWithRequiredConstResponse200Type1, +) +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/models/oneof-with-required-const", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + if response.status_code == 200: + + def _parse_response_200( + data: object, + ) -> Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1" + ]: + try: + if not isinstance(data, dict): + raise TypeError() + response_200_type_0 = GetModelsOneofWithRequiredConstResponse200Type0.from_dict(data) + + return response_200_type_0 + except: # noqa: E722 + pass + if not isinstance(data, dict): + raise TypeError() + response_200_type_1 = GetModelsOneofWithRequiredConstResponse200Type1.from_dict(data) + + return response_200_type_1 + + response_200 = _parse_response_200(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1'] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[ + Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] +]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1'] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py new file mode 100644 index 000000000..5bd941c69 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -0,0 +1,99 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + common: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["common"] = common + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/common_parameters", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + common: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + common (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + common=common, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + common: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + common (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + common=common, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py new file mode 100644 index 000000000..fe7adf04c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response + + +def _get_kwargs( + *, + client_query: str, + url_query: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["client"] = client_query + + params["url"] = url_query + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/naming/reserved-parameters", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + client_query: str, + url_query: str, +) -> Response[Any]: + """ + Args: + client_query (str): + url_query (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + client_query=client_query, + url_query=url_query, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + client_query: str, + url_query: str, +) -> Response[Any]: + """ + Args: + client_query (str): + url_query (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + client_query=client_query, + url_query=url_query, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py new file mode 100644 index 000000000..ffc9b535e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py @@ -0,0 +1,363 @@ +import datetime +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx +from dateutil.parser import isoparse + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.an_enum import AnEnum +from ...models.http_validation_error import HTTPValidationError +from ...models.model_with_union_property import ModelWithUnionProperty +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + string_prop: str = "the default string", + string_with_num: str = "1", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + float_with_int: float = 3.0, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: list[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["string_prop"] = string_prop + + params["string with num"] = string_with_num + + json_date_prop = date_prop.isoformat() + params["date_prop"] = json_date_prop + + params["float_prop"] = float_prop + + params["float_with_int"] = float_with_int + + params["int_prop"] = int_prop + + params["boolean_prop"] = boolean_prop + + json_list_prop = [] + for list_prop_item_data in list_prop: + list_prop_item = list_prop_item_data.value + json_list_prop.append(list_prop_item) + + params["list_prop"] = json_list_prop + + json_union_prop: Union[float, str] + json_union_prop = union_prop + params["union_prop"] = json_union_prop + + json_union_prop_with_ref: Union[Unset, float, str] + if isinstance(union_prop_with_ref, Unset): + json_union_prop_with_ref = UNSET + elif isinstance(union_prop_with_ref, AnEnum): + json_union_prop_with_ref = union_prop_with_ref.value + else: + json_union_prop_with_ref = union_prop_with_ref + params["union_prop_with_ref"] = json_union_prop_with_ref + + json_enum_prop = enum_prop.value + params["enum_prop"] = json_enum_prop + + json_model_prop = model_prop.to_dict() + params.update(json_model_prop) + + json_required_model_prop = required_model_prop.to_dict() + params.update(json_required_model_prop) + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/defaults", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + string_prop: str = "the default string", + string_with_num: str = "1", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + float_with_int: float = 3.0, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: list[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", +) -> Response[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + string_with_num (str): Default: '1'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + float_with_int (float): Default: 3.0. + int_prop (int): Default: 7. + boolean_prop (bool): Default: False. + list_prop (list[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, 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): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + string_prop=string_prop, + string_with_num=string_with_num, + date_prop=date_prop, + float_prop=float_prop, + float_with_int=float_with_int, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + string_prop: str = "the default string", + string_with_num: str = "1", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + float_with_int: float = 3.0, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: list[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", +) -> Optional[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + string_with_num (str): Default: '1'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + float_with_int (float): Default: 3.0. + int_prop (int): Default: 7. + boolean_prop (bool): Default: False. + list_prop (list[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, 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): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + string_prop=string_prop, + string_with_num=string_with_num, + date_prop=date_prop, + float_prop=float_prop, + float_with_int=float_with_int, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + string_prop: str = "the default string", + string_with_num: str = "1", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + float_with_int: float = 3.0, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: list[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", +) -> Response[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + string_with_num (str): Default: '1'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + float_with_int (float): Default: 3.0. + int_prop (int): Default: 7. + boolean_prop (bool): Default: False. + list_prop (list[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, 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): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + string_prop=string_prop, + string_with_num=string_with_num, + date_prop=date_prop, + float_prop=float_prop, + float_with_int=float_with_int, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + string_prop: str = "the default string", + string_with_num: str = "1", + date_prop: datetime.date = isoparse("1010-10-10").date(), + float_prop: float = 3.14, + float_with_int: float = 3.0, + int_prop: int = 7, + boolean_prop: bool = False, + list_prop: list[AnEnum], + union_prop: Union[float, str] = "not a float", + union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, + enum_prop: AnEnum, + model_prop: "ModelWithUnionProperty", + required_model_prop: "ModelWithUnionProperty", +) -> Optional[Union[Any, HTTPValidationError]]: + """Defaults + + Args: + string_prop (str): Default: 'the default string'. + string_with_num (str): Default: '1'. + date_prop (datetime.date): Default: isoparse('1010-10-10').date(). + float_prop (float): Default: 3.14. + float_with_int (float): Default: 3.0. + int_prop (int): Default: 7. + boolean_prop (bool): Default: False. + list_prop (list[AnEnum]): + union_prop (Union[float, str]): Default: 'not a float'. + union_prop_with_ref (Union[AnEnum, 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): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + string_prop=string_prop, + string_with_num=string_with_num, + date_prop=date_prop, + float_prop=float_prop, + float_with_int=float_with_int, + int_prop=int_prop, + boolean_prop=boolean_prop, + list_prop=list_prop, + union_prop=union_prop, + union_prop_with_ref=union_prop_with_ref, + enum_prop=enum_prop, + model_prop=model_prop, + required_model_prop=required_model_prop, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py new file mode 100644 index 000000000..52385855c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -0,0 +1,101 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response + + +def _get_kwargs( + *, + bool_enum: bool, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["bool_enum"] = bool_enum + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/enum/bool", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + bool_enum: bool, +) -> Response[Any]: + """Bool Enum + + Args: + bool_enum (bool): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + bool_enum=bool_enum, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + bool_enum: bool, +) -> Response[Any]: + """Bool Enum + + Args: + bool_enum (bool): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + bool_enum=bool_enum, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py new file mode 100644 index 000000000..26c3729fe --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -0,0 +1,103 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.an_int_enum import AnIntEnum +from ...types import UNSET, Response + + +def _get_kwargs( + *, + int_enum: AnIntEnum, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_int_enum = int_enum.value + params["int_enum"] = json_int_enum + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/enum/int", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + int_enum: AnIntEnum, +) -> Response[Any]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + int_enum=int_enum, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + int_enum: AnIntEnum, +) -> Response[Any]: + """Int Enum + + Args: + int_enum (AnIntEnum): An enumeration. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + int_enum=int_enum, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py new file mode 100644 index 000000000..ad9428a72 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -0,0 +1,149 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader +from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + if not isinstance(boolean_header, Unset): + headers["Boolean-Header"] = "true" if boolean_header else "false" + + if not isinstance(string_header, Unset): + headers["String-Header"] = string_header + + if not isinstance(number_header, Unset): + headers["Number-Header"] = str(number_header) + + if not isinstance(integer_header, Unset): + headers["Integer-Header"] = str(integer_header) + + if not isinstance(int_enum_header, Unset): + headers["Int-Enum-Header"] = str(int_enum_header) + + if not isinstance(string_enum_header, Unset): + headers["String-Enum-Header"] = str(string_enum_header) + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/location/header/types", + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, +) -> Response[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + boolean_header: Union[Unset, bool] = UNSET, + string_header: Union[Unset, str] = UNSET, + number_header: Union[Unset, float] = UNSET, + integer_header: Union[Unset, int] = UNSET, + int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, + string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, +) -> Response[Any]: + """ + Args: + boolean_header (Union[Unset, bool]): + string_header (Union[Unset, str]): + number_header (Union[Unset, float]): + integer_header (Union[Unset, int]): + int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): + string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + boolean_header=boolean_header, + string_header=string_header, + number_header=number_header, + integer_header=integer_header, + int_enum_header=int_enum_header, + string_enum_header=string_enum_header, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py new file mode 100644 index 000000000..e28e37a36 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -0,0 +1,143 @@ +import datetime +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + not_null_required: datetime.datetime, + null_required: Union[None, datetime.datetime], + null_not_required: Union[None, Unset, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, datetime.datetime] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_not_null_required = not_null_required.isoformat() + params["not_null_required"] = json_not_null_required + + json_null_required: Union[None, str] + if isinstance(null_required, datetime.datetime): + json_null_required = null_required.isoformat() + else: + json_null_required = null_required + params["null_required"] = json_null_required + + json_null_not_required: Union[None, Unset, str] + if isinstance(null_not_required, Unset): + json_null_not_required = UNSET + elif isinstance(null_not_required, datetime.datetime): + json_null_not_required = null_not_required.isoformat() + else: + json_null_not_required = null_not_required + params["null_not_required"] = json_null_not_required + + json_not_null_not_required: Union[Unset, str] = UNSET + if not isinstance(not_null_not_required, Unset): + json_not_null_not_required = not_null_not_required.isoformat() + params["not_null_not_required"] = json_not_null_not_required + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/location/query/optionality", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + not_null_required: datetime.datetime, + null_required: Union[None, datetime.datetime], + null_not_required: Union[None, Unset, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, datetime.datetime] = UNSET, +) -> Response[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[None, datetime.datetime]): + null_not_required (Union[None, Unset, datetime.datetime]): + not_null_not_required (Union[Unset, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + not_null_required: datetime.datetime, + null_required: Union[None, datetime.datetime], + null_not_required: Union[None, Unset, datetime.datetime] = UNSET, + not_null_not_required: Union[Unset, datetime.datetime] = UNSET, +) -> Response[Any]: + """ + Args: + not_null_required (datetime.datetime): + null_required (Union[None, datetime.datetime]): + null_not_required (Union[None, Unset, datetime.datetime]): + not_null_not_required (Union[Unset, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + not_null_required=not_null_required, + null_required=null_required, + null_not_required=null_not_required, + not_null_not_required=not_null_not_required, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py new file mode 100644 index 000000000..a0caba2d6 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py @@ -0,0 +1,91 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + hyphen_in_path: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/naming/{hyphen_in_path}", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + hyphen_in_path: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Args: + hyphen_in_path (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + hyphen_in_path=hyphen_in_path, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + hyphen_in_path: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Args: + hyphen_in_path (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + hyphen_in_path=hyphen_in_path, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py new file mode 100644 index 000000000..7df2d318f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.mixed_case_response_200 import MixedCaseResponse200 +from ...types import UNSET, Response + + +def _get_kwargs( + *, + mixed_case: str, + mixedCase: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["mixed_case"] = mixed_case + + params["mixedCase"] = mixedCase + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/naming/mixed-case", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[MixedCaseResponse200]: + if response.status_code == 200: + response_200 = MixedCaseResponse200.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[MixedCaseResponse200]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + mixed_case: str, + mixedCase: str, +) -> Response[MixedCaseResponse200]: + """ + Args: + mixed_case (str): + mixedCase (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MixedCaseResponse200] + """ + + kwargs = _get_kwargs( + mixed_case=mixed_case, + mixedCase=mixedCase, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + mixed_case: str, + mixedCase: str, +) -> Optional[MixedCaseResponse200]: + """ + Args: + mixed_case (str): + mixedCase (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MixedCaseResponse200 + """ + + return sync_detailed( + client=client, + mixed_case=mixed_case, + mixedCase=mixedCase, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + mixed_case: str, + mixedCase: str, +) -> Response[MixedCaseResponse200]: + """ + Args: + mixed_case (str): + mixedCase (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MixedCaseResponse200] + """ + + kwargs = _get_kwargs( + mixed_case=mixed_case, + mixedCase=mixedCase, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + mixed_case: str, + mixedCase: str, +) -> Optional[MixedCaseResponse200]: + """ + Args: + mixed_case (str): + mixedCase (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MixedCaseResponse200 + """ + + return ( + await asyncio_detailed( + client=client, + mixed_case=mixed_case, + mixedCase=mixedCase, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py new file mode 100644 index 000000000..3bb8b698b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py @@ -0,0 +1,158 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody +from ...models.post_naming_property_conflict_with_import_response_200 import ( + PostNamingPropertyConflictWithImportResponse200, +) +from ...types import Response + + +def _get_kwargs( + *, + body: PostNamingPropertyConflictWithImportBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/naming/property-conflict-with-import", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PostNamingPropertyConflictWithImportResponse200]: + if response.status_code == 200: + response_200 = PostNamingPropertyConflictWithImportResponse200.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PostNamingPropertyConflictWithImportResponse200]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: PostNamingPropertyConflictWithImportBody, +) -> Response[PostNamingPropertyConflictWithImportResponse200]: + """ + Args: + body (PostNamingPropertyConflictWithImportBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostNamingPropertyConflictWithImportResponse200] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: PostNamingPropertyConflictWithImportBody, +) -> Optional[PostNamingPropertyConflictWithImportResponse200]: + """ + Args: + body (PostNamingPropertyConflictWithImportBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PostNamingPropertyConflictWithImportResponse200 + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: PostNamingPropertyConflictWithImportBody, +) -> Response[PostNamingPropertyConflictWithImportResponse200]: + """ + Args: + body (PostNamingPropertyConflictWithImportBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostNamingPropertyConflictWithImportResponse200] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: PostNamingPropertyConflictWithImportBody, +) -> Optional[PostNamingPropertyConflictWithImportResponse200]: + """ + Args: + body (PostNamingPropertyConflictWithImportBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PostNamingPropertyConflictWithImportResponse200 + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py new file mode 100644 index 000000000..e7a8e2712 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -0,0 +1,141 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + path_param: str, + *, + string_param: Union[Unset, str] = UNSET, + integer_param: Union[Unset, int] = 0, + header_param: Union[None, Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + if not isinstance(header_param, Unset): + headers["header param"] = header_param + + cookies = {} + if cookie_param is not UNSET: + cookies["cookie param"] = cookie_param + + params: dict[str, Any] = {} + + params["string param"] = string_param + + params["integer param"] = integer_param + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/parameter-references/{path_param}", + "params": params, + "cookies": cookies, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + path_param: str, + *, + client: Union[AuthenticatedClient, Client], + string_param: Union[Unset, str] = UNSET, + integer_param: Union[Unset, int] = 0, + header_param: Union[None, Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, +) -> Response[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, str]): + integer_param (Union[Unset, int]): Default: 0. + header_param (Union[None, Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + path_param=path_param, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + path_param: str, + *, + client: Union[AuthenticatedClient, Client], + string_param: Union[Unset, str] = UNSET, + integer_param: Union[Unset, int] = 0, + header_param: Union[None, Unset, str] = UNSET, + cookie_param: Union[Unset, str] = UNSET, +) -> Response[Any]: + """Test different types of parameter references + + Args: + path_param (str): + string_param (Union[Unset, str]): + integer_param (Union[Unset, int]): Default: 0. + header_param (Union[None, Unset, str]): + cookie_param (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + path_param=path_param, + string_param=string_param, + integer_param=integer_param, + header_param=header_param, + cookie_param=cookie_param, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py new file mode 100644 index 000000000..704996107 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -0,0 +1,106 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + param_path: str, + *, + param_query: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["param"] = param_query + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": f"/common_parameters_overriding/{param_path}", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + param_query: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + param_query: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py new file mode 100644 index 000000000..b6efbba9b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -0,0 +1,110 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response + + +def _get_kwargs( + param_path: str, + *, + param_query: str = "overridden_in_GET", +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["param"] = param_query + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/common_parameters_overriding/{param_path}", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + 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. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + 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. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py new file mode 100644 index 000000000..6a7ed7fd5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -0,0 +1,130 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + param_path: str, + *, + param_query: Union[Unset, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + if not isinstance(param_header, Unset): + headers["param"] = param_header + + cookies = {} + if param_cookie is not UNSET: + cookies["param"] = param_cookie + + params: dict[str, Any] = {} + + params["param"] = param_query + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/same-name-multiple-locations/{param_path}", + "params": params, + "cookies": cookies, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + param_query: Union[Unset, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + param_path: str, + *, + client: Union[AuthenticatedClient, Client], + param_query: Union[Unset, str] = UNSET, + param_header: Union[Unset, str] = UNSET, + param_cookie: Union[Unset, str] = UNSET, +) -> Response[Any]: + """ + Args: + param_path (str): + param_query (Union[Unset, str]): + param_header (Union[Unset, str]): + param_cookie (Union[Unset, str]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param_path=param_path, + param_query=param_query, + param_header=param_header, + param_cookie=param_cookie, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py new file mode 100644 index 000000000..44345aa26 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -0,0 +1,112 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + param4: str, + param2: int, + param1: str, + param3: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + param4: str, + param2: int, + param1: str, + param3: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param4=param4, + param2=param2, + param1=param1, + param3=param3, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + param4: str, + param2: int, + param1: str, + param3: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Args: + param4 (str): + param2 (int): + param1 (str): + param3 (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + param4=param4, + param2=param2, + param1=param1, + param3=param3, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py new file mode 100644 index 000000000..cf0599306 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.post_responses_unions_simple_before_complex_response_200 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200, +) +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/responses/unions/simple_before_complex", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + if response.status_code == 200: + response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PostResponsesUnionsSimpleBeforeComplexResponse200 + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PostResponsesUnionsSimpleBeforeComplexResponse200] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: + """Regression test for #603 + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PostResponsesUnionsSimpleBeforeComplexResponse200 + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py new file mode 100644 index 000000000..057ceb2de --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py @@ -0,0 +1,120 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/responses/text", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: + if response.status_code == 200: + response_200 = response.text + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[str]: + """Text Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[str] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[str]: + """Text Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + str + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[str]: + """Text Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[str] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[str]: + """Text Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + str + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py new file mode 100644 index 000000000..62631355f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -0,0 +1,77 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tag_with_number", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py new file mode 100644 index 000000000..62631355f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py @@ -0,0 +1,77 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tag_with_number", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """ + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py new file mode 100644 index 000000000..0852815d2 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py @@ -0,0 +1,171 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.a_model import AModel +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: AModel, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/callback", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Optional[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Optional[Union[Any, HTTPValidationError]]: + """Path with callback + + Try sending a request related to a callback + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py new file mode 100644 index 000000000..e7cd44f70 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -0,0 +1,83 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/description-with-backslash", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + r""" Test description with \ + + Test description with \ + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py new file mode 100644 index 000000000..147eed3a7 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/basic_lists/booleans", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[bool]]: + if response.status_code == 200: + response_200 = cast(list[bool], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[bool]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[bool]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[bool] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[bool]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[bool]]: + """Get Basic List Of Booleans + + Get a list of booleans + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[bool] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py new file mode 100644 index 000000000..02b3abb1f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/basic_lists/floats", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[float]]: + if response.status_code == 200: + response_200 = cast(list[float], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[float]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[float]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[float] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[float]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[float]]: + """Get Basic List Of Floats + + Get a list of floats + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[float] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py new file mode 100644 index 000000000..e71537363 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/basic_lists/integers", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[int]]: + if response.status_code == 200: + response_200 = cast(list[int], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[int]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[int]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[int] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[int]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[int]]: + """Get Basic List Of Integers + + Get a list of integers + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[int] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py new file mode 100644 index 000000000..70f153829 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/basic_lists/strings", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[list[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[list[str]]: + """Get Basic List Of Strings + + Get a list of strings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py new file mode 100644 index 000000000..a708cf71d --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py @@ -0,0 +1,250 @@ +import datetime +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.a_model import AModel +from ...models.an_enum import AnEnum +from ...models.an_enum_with_null import AnEnumWithNull +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + *, + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], + some_date: Union[datetime.date, datetime.datetime], +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_an_enum_value = [] + for an_enum_value_item_data in an_enum_value: + an_enum_value_item = an_enum_value_item_data.value + json_an_enum_value.append(an_enum_value_item) + + params["an_enum_value"] = json_an_enum_value + + json_an_enum_value_with_null = [] + for an_enum_value_with_null_item_data in an_enum_value_with_null: + an_enum_value_with_null_item: Union[None, str] + if isinstance(an_enum_value_with_null_item_data, AnEnumWithNull): + an_enum_value_with_null_item = an_enum_value_with_null_item_data.value + else: + an_enum_value_with_null_item = an_enum_value_with_null_item_data + json_an_enum_value_with_null.append(an_enum_value_with_null_item) + + params["an_enum_value_with_null"] = json_an_enum_value_with_null + + json_an_enum_value_with_only_null = an_enum_value_with_only_null + + params["an_enum_value_with_only_null"] = json_an_enum_value_with_only_null + + json_some_date: str + if isinstance(some_date, datetime.date): + json_some_date = some_date.isoformat() + else: + json_some_date = some_date.isoformat() + + params["some_date"] = json_some_date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = AModel.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if response.status_code == 423: + response_423 = HTTPValidationError.from_dict(response.json()) + + return response_423 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, list["AModel"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + 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[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, list['AModel']]] + """ + + kwargs = _get_kwargs( + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], + some_date: Union[datetime.date, datetime.datetime], +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, list['AModel']] + """ + + return sync_detailed( + client=client, + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + 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[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, list['AModel']]] + """ + + kwargs = _get_kwargs( + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], + some_date: Union[datetime.date, datetime.datetime], +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: + """Get List + + Get a list of things + + Args: + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): + some_date (Union[datetime.date, datetime.datetime]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, list['AModel']] + """ + + return ( + await asyncio_detailed( + client=client, + an_enum_value=an_enum_value, + an_enum_value_with_null=an_enum_value_with_null, + an_enum_value_with_only_null=an_enum_value_with_only_null, + some_date=some_date, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py new file mode 100644 index 000000000..f33a23dc7 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -0,0 +1,171 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.a_model import AModel +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: AModel, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/json_body", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Optional[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Response[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: AModel, +) -> Optional[Union[Any, HTTPValidationError]]: + """Json Body + + Try sending a JSON body + + Args: + body (AModel): A Model for testing all the ways custom objects can be used + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py new file mode 100644 index 000000000..586947f49 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -0,0 +1,79 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/no_response", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """No Response + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py new file mode 100644 index 000000000..efb0f4ae5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -0,0 +1,122 @@ +from http import HTTPStatus +from io import BytesIO +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import File, Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/octet_stream", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[File]: + if response.status_code == 200: + response_200 = File(payload=BytesIO(response.content)) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[File]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[File] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + File + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[File] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[File]: + """Octet Stream + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + File + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py new file mode 100644 index 000000000..ea0cbd65a --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py @@ -0,0 +1,162 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import File, Response + + +def _get_kwargs( + *, + body: File, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/octet_stream", + } + + _body = body.payload + + _kwargs["content"] = _body + headers["Content-Type"] = "application/octet-stream" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: File, +) -> Response[Union[HTTPValidationError, str]]: + """Binary (octet stream) request body + + Args: + body (File): A file to upload + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: File, +) -> Optional[Union[HTTPValidationError, str]]: + """Binary (octet stream) request body + + Args: + body (File): A file to upload + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: File, +) -> Response[Union[HTTPValidationError, str]]: + """Binary (octet stream) request body + + Args: + body (File): A file to upload + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: File, +) -> Optional[Union[HTTPValidationError, str]]: + """Binary (octet stream) request body + + Args: + body (File): A file to upload + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py new file mode 100644 index 000000000..ec65d0363 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.a_form_data import AFormData +from ...types import Response + + +def _get_kwargs( + *, + body: AFormData, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/post_form_data", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AFormData, +) -> Response[Any]: + """Post form data + + Post form data + + Args: + body (AFormData): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: AFormData, +) -> Response[Any]: + """Post form data + + Post form data + + Args: + body (AFormData): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py new file mode 100644 index 000000000..bc5ad7cc4 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.post_form_data_inline_body import PostFormDataInlineBody +from ...types import Response + + +def _get_kwargs( + *, + body: PostFormDataInlineBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/post_form_data_inline", + } + + _body = body.to_dict() + + _kwargs["data"] = _body + headers["Content-Type"] = "application/x-www-form-urlencoded" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: PostFormDataInlineBody, +) -> Response[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Args: + body (PostFormDataInlineBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: PostFormDataInlineBody, +) -> Response[Any]: + """Post form data (inline schema) + + Post form data (inline schema) + + Args: + body (PostFormDataInlineBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py new file mode 100644 index 000000000..ba40de26f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -0,0 +1,162 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: str, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/json_body/string", + } + + _body = body + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Response[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Response[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Json Body Which is String + + Args: + body (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py new file mode 100644 index 000000000..287ea4a1a --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.test_inline_objects_body import TestInlineObjectsBody +from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 +from ...types import Response + + +def _get_kwargs( + *, + body: TestInlineObjectsBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/inline_objects", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[TestInlineObjectsResponse200]: + if response.status_code == 200: + response_200 = TestInlineObjectsResponse200.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[TestInlineObjectsResponse200]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: TestInlineObjectsBody, +) -> Response[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + body (TestInlineObjectsBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[TestInlineObjectsResponse200] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: TestInlineObjectsBody, +) -> Optional[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + body (TestInlineObjectsBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + TestInlineObjectsResponse200 + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: TestInlineObjectsBody, +) -> Response[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + body (TestInlineObjectsBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[TestInlineObjectsResponse200] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: TestInlineObjectsBody, +) -> Optional[TestInlineObjectsResponse200]: + """Test Inline Objects + + Args: + body (TestInlineObjectsBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + TestInlineObjectsResponse200 + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py new file mode 100644 index 000000000..22ac00650 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -0,0 +1,104 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + *, + my_token: str, +) -> dict[str, Any]: + cookies = {} + cookies["MyToken"] = my_token + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/auth/token_with_cookie", + "cookies": cookies, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if response.status_code == 401: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + my_token: str, +) -> Response[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + my_token=my_token, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + my_token: str, +) -> Response[Any]: + """TOKEN_WITH_COOKIE + + Test optional cookie parameters + + Args: + my_token (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + my_token=my_token, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py new file mode 100644 index 000000000..61e8434e6 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -0,0 +1,79 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/tests/unsupported_content", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Any]: + """Unsupported Content + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py new file mode 100644 index 000000000..9f1864ec3 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -0,0 +1,170 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: BodyUploadFileTestsUploadPost, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/upload", + } + + _body = body.to_multipart() + + _kwargs["files"] = _body + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: BodyUploadFileTestsUploadPost, +) -> Response[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + body (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: BodyUploadFileTestsUploadPost, +) -> Optional[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + body (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: BodyUploadFileTestsUploadPost, +) -> Response[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + body (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: BodyUploadFileTestsUploadPost, +) -> Optional[Union[Any, HTTPValidationError]]: + """Upload File + + Upload a file + + Args: + body (BodyUploadFileTestsUploadPost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py new file mode 100644 index 000000000..3f8edc817 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -0,0 +1,173 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import File, Response + + +def _get_kwargs( + *, + body: list[File], +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/tests/upload/multiple", + } + + _body = [] + for body_item_data in body: + body_item = body_item_data.to_tuple() + + _body.append(body_item) + + _kwargs["files"] = _body + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: list[File], +) -> Response[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + body (list[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: list[File], +) -> Optional[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + body (list[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: list[File], +) -> Response[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + body (list[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + body: list[File], +) -> Optional[Union[Any, HTTPValidationError]]: + """Upload multiple files + + Upload several files in the same request + + Args: + body (list[File]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py new file mode 100644 index 000000000..b46550153 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py @@ -0,0 +1,99 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response + + +def _get_kwargs( + *, + import_: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["import"] = import_ + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/naming/keywords", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + import_: str, +) -> Response[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + import_=import_, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + import_: str, +) -> Response[Any]: + """ + Args: + import_ (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + import_=import_, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py new file mode 100644 index 000000000..e80446f10 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any, Optional, Union + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + def with_headers(self, headers: dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/errors.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/errors.py new file mode 100644 index 000000000..5f92e76ac --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py new file mode 100644 index 000000000..f354c31c7 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py @@ -0,0 +1,171 @@ +"""Contains all the data models used in inputs/outputs""" + +from .a_discriminated_union_type_1 import ADiscriminatedUnionType1 +from .a_discriminated_union_type_2 import ADiscriminatedUnionType2 +from .a_form_data import AFormData +from .a_model import AModel +from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject +from .all_of_has_properties_but_no_type import AllOfHasPropertiesButNoType +from .all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum +from .all_of_sub_model import AllOfSubModel +from .all_of_sub_model_type_enum import AllOfSubModelTypeEnum +from .an_all_of_enum import AnAllOfEnum +from .an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem +from .an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, +) +from .an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, +) +from .an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem +from .an_array_with_a_recursive_ref_in_items_object_additional_properties_item import ( + AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem, +) +from .an_array_with_a_recursive_ref_in_items_object_item import AnArrayWithARecursiveRefInItemsObjectItem +from .an_enum import AnEnum +from .an_enum_with_null import AnEnumWithNull +from .an_int_enum import AnIntEnum +from .another_all_of_sub_model import AnotherAllOfSubModel +from .another_all_of_sub_model_type import AnotherAllOfSubModelType +from .another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum +from .body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost +from .body_upload_file_tests_upload_post_additional_property import BodyUploadFileTestsUploadPostAdditionalProperty +from .body_upload_file_tests_upload_post_some_nullable_object import BodyUploadFileTestsUploadPostSomeNullableObject +from .body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject +from .body_upload_file_tests_upload_post_some_optional_object import BodyUploadFileTestsUploadPostSomeOptionalObject +from .different_enum import DifferentEnum +from .extended import Extended +from .free_form_model import FreeFormModel +from .get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader +from .get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from .get_models_allof_response_200 import GetModelsAllofResponse200 +from .get_models_oneof_with_required_const_response_200_type_0 import GetModelsOneofWithRequiredConstResponse200Type0 +from .get_models_oneof_with_required_const_response_200_type_1 import GetModelsOneofWithRequiredConstResponse200Type1 +from .http_validation_error import HTTPValidationError +from .import_ import Import +from .json_like_body import JsonLikeBody +from .mixed_case_response_200 import MixedCaseResponse200 +from .model_from_all_of import ModelFromAllOf +from .model_name import ModelName +from .model_reference_with_periods import ModelReferenceWithPeriods +from .model_with_additional_properties_inlined import ModelWithAdditionalPropertiesInlined +from .model_with_additional_properties_inlined_additional_property import ( + ModelWithAdditionalPropertiesInlinedAdditionalProperty, +) +from .model_with_additional_properties_refed import ModelWithAdditionalPropertiesRefed +from .model_with_any_json_properties import ModelWithAnyJsonProperties +from .model_with_any_json_properties_additional_property_type_0 import ModelWithAnyJsonPropertiesAdditionalPropertyType0 +from .model_with_backslash_in_description import ModelWithBackslashInDescription +from .model_with_circular_ref_a import ModelWithCircularRefA +from .model_with_circular_ref_b import ModelWithCircularRefB +from .model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA +from .model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB +from .model_with_date_time_property import ModelWithDateTimeProperty +from .model_with_discriminated_union import ModelWithDiscriminatedUnion +from .model_with_merged_properties import ModelWithMergedProperties +from .model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum +from .model_with_no_properties import ModelWithNoProperties +from .model_with_primitive_additional_properties import ModelWithPrimitiveAdditionalProperties +from .model_with_primitive_additional_properties_a_date_holder import ModelWithPrimitiveAdditionalPropertiesADateHolder +from .model_with_property_ref import ModelWithPropertyRef +from .model_with_recursive_ref import ModelWithRecursiveRef +from .model_with_recursive_ref_in_additional_properties import ModelWithRecursiveRefInAdditionalProperties +from .model_with_union_property import ModelWithUnionProperty +from .model_with_union_property_inlined import ModelWithUnionPropertyInlined +from .model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 +from .model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 +from .none import None_ +from .post_bodies_multiple_data_body import PostBodiesMultipleDataBody +from .post_bodies_multiple_files_body import PostBodiesMultipleFilesBody +from .post_bodies_multiple_json_body import PostBodiesMultipleJsonBody +from .post_form_data_inline_body import PostFormDataInlineBody +from .post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody +from .post_naming_property_conflict_with_import_response_200 import PostNamingPropertyConflictWithImportResponse200 +from .post_responses_unions_simple_before_complex_response_200 import PostResponsesUnionsSimpleBeforeComplexResponse200 +from .post_responses_unions_simple_before_complex_response_200a_type_1 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, +) +from .test_inline_objects_body import TestInlineObjectsBody +from .test_inline_objects_response_200 import TestInlineObjectsResponse200 +from .validation_error import ValidationError + +__all__ = ( + "ADiscriminatedUnionType1", + "ADiscriminatedUnionType2", + "AFormData", + "AllOfHasPropertiesButNoType", + "AllOfHasPropertiesButNoTypeTypeEnum", + "AllOfSubModel", + "AllOfSubModelTypeEnum", + "AModel", + "AModelWithPropertiesReferenceThatAreNotObject", + "AnAllOfEnum", + "AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem", + "AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem", + "AnArrayWithACircularRefInItemsObjectAItem", + "AnArrayWithACircularRefInItemsObjectBItem", + "AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem", + "AnArrayWithARecursiveRefInItemsObjectItem", + "AnEnum", + "AnEnumWithNull", + "AnIntEnum", + "AnotherAllOfSubModel", + "AnotherAllOfSubModelType", + "AnotherAllOfSubModelTypeEnum", + "BodyUploadFileTestsUploadPost", + "BodyUploadFileTestsUploadPostAdditionalProperty", + "BodyUploadFileTestsUploadPostSomeNullableObject", + "BodyUploadFileTestsUploadPostSomeObject", + "BodyUploadFileTestsUploadPostSomeOptionalObject", + "DifferentEnum", + "Extended", + "FreeFormModel", + "GetLocationHeaderTypesIntEnumHeader", + "GetLocationHeaderTypesStringEnumHeader", + "GetModelsAllofResponse200", + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + "HTTPValidationError", + "Import", + "JsonLikeBody", + "MixedCaseResponse200", + "ModelFromAllOf", + "ModelName", + "ModelReferenceWithPeriods", + "ModelWithAdditionalPropertiesInlined", + "ModelWithAdditionalPropertiesInlinedAdditionalProperty", + "ModelWithAdditionalPropertiesRefed", + "ModelWithAnyJsonProperties", + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + "ModelWithBackslashInDescription", + "ModelWithCircularRefA", + "ModelWithCircularRefB", + "ModelWithCircularRefInAdditionalPropertiesA", + "ModelWithCircularRefInAdditionalPropertiesB", + "ModelWithDateTimeProperty", + "ModelWithDiscriminatedUnion", + "ModelWithMergedProperties", + "ModelWithMergedPropertiesStringToEnum", + "ModelWithNoProperties", + "ModelWithPrimitiveAdditionalProperties", + "ModelWithPrimitiveAdditionalPropertiesADateHolder", + "ModelWithPropertyRef", + "ModelWithRecursiveRef", + "ModelWithRecursiveRefInAdditionalProperties", + "ModelWithUnionProperty", + "ModelWithUnionPropertyInlined", + "ModelWithUnionPropertyInlinedFruitType0", + "ModelWithUnionPropertyInlinedFruitType1", + "None_", + "PostBodiesMultipleDataBody", + "PostBodiesMultipleFilesBody", + "PostBodiesMultipleJsonBody", + "PostFormDataInlineBody", + "PostNamingPropertyConflictWithImportBody", + "PostNamingPropertyConflictWithImportResponse200", + "PostResponsesUnionsSimpleBeforeComplexResponse200", + "PostResponsesUnionsSimpleBeforeComplexResponse200AType1", + "TestInlineObjectsBody", + "TestInlineObjectsResponse200", + "ValidationError", +) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py new file mode 100644 index 000000000..3fdcc28f9 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ADiscriminatedUnionType1") + + +@_attrs_define +class ADiscriminatedUnionType1: + model_type: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + model_type = self.model_type + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if model_type is not UNSET: + field_dict["modelType"] = model_type + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_type = d.pop("modelType", UNSET) + + a_discriminated_union_type_1 = cls( + model_type=model_type, + ) + + a_discriminated_union_type_1.additional_properties = d + return a_discriminated_union_type_1 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py new file mode 100644 index 000000000..c2175cb92 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ADiscriminatedUnionType2") + + +@_attrs_define +class ADiscriminatedUnionType2: + model_type: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + model_type = self.model_type + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if model_type is not UNSET: + field_dict["modelType"] = model_type + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_type = d.pop("modelType", UNSET) + + a_discriminated_union_type_2 = cls( + model_type=model_type, + ) + + a_discriminated_union_type_2.additional_properties = d + return a_discriminated_union_type_2 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py new file mode 100644 index 000000000..dfe24eda5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py @@ -0,0 +1,63 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AFormData") + + +@_attrs_define +class AFormData: + an_required_field: str + an_optional_field: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + an_required_field = self.an_required_field + + an_optional_field = self.an_optional_field + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "an_required_field": an_required_field, + } + ) + if an_optional_field is not UNSET: + field_dict["an_optional_field"] = an_optional_field + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + an_required_field = d.pop("an_required_field") + + an_optional_field = d.pop("an_optional_field", UNSET) + + a_form_data = cls( + an_required_field=an_required_field, + an_optional_field=an_optional_field, + ) + + a_form_data.additional_properties = d + return a_form_data + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py new file mode 100644 index 000000000..d819efeb0 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py @@ -0,0 +1,508 @@ +import datetime +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast +from uuid import UUID + +from attrs import define as _attrs_define +from dateutil.parser import isoparse + +from ..models.an_all_of_enum import AnAllOfEnum +from ..models.an_enum import AnEnum +from ..models.different_enum import DifferentEnum +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + +T = TypeVar("T", bound="AModel") + + +@_attrs_define +class AModel: + """A Model for testing all the ways custom objects can be used""" + + an_enum_value: AnEnum + """ For testing Enums in all the ways they can be used """ + a_camel_date_time: Union[datetime.date, datetime.datetime] + a_date: datetime.date + a_nullable_date: Union[None, datetime.date] + a_uuid: UUID + required_nullable: Union[None, str] + required_not_nullable: str + one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Any] + nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None] + model: "ModelWithUnionProperty" + nullable_model: Union["ModelWithUnionProperty", None] + an_allof_enum_with_overridden_default: AnAllOfEnum = AnAllOfEnum.OVERRIDDEN_DEFAULT + a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") + any_value: Union[Unset, Any] = "default" + an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET + a_not_required_date: Union[Unset, datetime.date] = UNSET + a_not_required_uuid: Union[Unset, UUID] = UNSET + attr_1_leading_digit: Union[Unset, str] = UNSET + attr_leading_underscore: Union[Unset, str] = UNSET + not_required_nullable: Union[None, Unset, str] = UNSET + not_required_not_nullable: Union[Unset, str] = UNSET + not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET + not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET + not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET + not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET + + def to_dict(self) -> dict[str, Any]: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + an_enum_value = self.an_enum_value.value + + an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value + + a_camel_date_time: str + if isinstance(self.a_camel_date_time, datetime.datetime): + a_camel_date_time = self.a_camel_date_time.isoformat() + else: + a_camel_date_time = self.a_camel_date_time.isoformat() + + a_date = self.a_date.isoformat() + + a_nullable_date: Union[None, str] + if isinstance(self.a_nullable_date, datetime.date): + a_nullable_date = self.a_nullable_date.isoformat() + else: + a_nullable_date = self.a_nullable_date + + a_uuid = str(self.a_uuid) + + a_nullable_uuid: Union[None, str] + if isinstance(self.a_nullable_uuid, UUID): + a_nullable_uuid = str(self.a_nullable_uuid) + else: + a_nullable_uuid = self.a_nullable_uuid + + required_nullable: Union[None, str] + required_nullable = self.required_nullable + + required_not_nullable = self.required_not_nullable + + one_of_models: Union[Any, dict[str, Any]] + if isinstance(self.one_of_models, FreeFormModel): + one_of_models = self.one_of_models.to_dict() + elif isinstance(self.one_of_models, ModelWithUnionProperty): + one_of_models = self.one_of_models.to_dict() + else: + one_of_models = self.one_of_models + + nullable_one_of_models: Union[None, dict[str, Any]] + if isinstance(self.nullable_one_of_models, FreeFormModel): + nullable_one_of_models = self.nullable_one_of_models.to_dict() + elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): + nullable_one_of_models = self.nullable_one_of_models.to_dict() + else: + nullable_one_of_models = self.nullable_one_of_models + + model = self.model.to_dict() + + nullable_model: Union[None, dict[str, Any]] + if isinstance(self.nullable_model, ModelWithUnionProperty): + nullable_model = self.nullable_model.to_dict() + else: + nullable_model = self.nullable_model + + any_value = self.any_value + + an_optional_allof_enum: Union[Unset, str] = UNSET + if not isinstance(self.an_optional_allof_enum, Unset): + an_optional_allof_enum = self.an_optional_allof_enum.value + + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET + if not isinstance(self.nested_list_of_enums, Unset): + nested_list_of_enums = [] + for nested_list_of_enums_item_data in self.nested_list_of_enums: + nested_list_of_enums_item = [] + for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: + nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value + nested_list_of_enums_item.append(nested_list_of_enums_item_item) + + nested_list_of_enums.append(nested_list_of_enums_item) + + a_not_required_date: Union[Unset, str] = UNSET + if not isinstance(self.a_not_required_date, Unset): + a_not_required_date = self.a_not_required_date.isoformat() + + a_not_required_uuid: Union[Unset, str] = UNSET + if not isinstance(self.a_not_required_uuid, Unset): + a_not_required_uuid = str(self.a_not_required_uuid) + + attr_1_leading_digit = self.attr_1_leading_digit + + attr_leading_underscore = self.attr_leading_underscore + + not_required_nullable: Union[None, Unset, str] + if isinstance(self.not_required_nullable, Unset): + not_required_nullable = UNSET + else: + not_required_nullable = self.not_required_nullable + + not_required_not_nullable = self.not_required_not_nullable + + not_required_one_of_models: Union[Unset, dict[str, Any]] + if isinstance(self.not_required_one_of_models, Unset): + not_required_one_of_models = UNSET + elif isinstance(self.not_required_one_of_models, FreeFormModel): + not_required_one_of_models = self.not_required_one_of_models.to_dict() + else: + not_required_one_of_models = self.not_required_one_of_models.to_dict() + + not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] + if isinstance(self.not_required_nullable_one_of_models, Unset): + not_required_nullable_one_of_models = UNSET + elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + else: + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models + + not_required_model: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.not_required_model, Unset): + not_required_model = self.not_required_model.to_dict() + + not_required_nullable_model: Union[None, Unset, dict[str, Any]] + if isinstance(self.not_required_nullable_model, Unset): + not_required_nullable_model = UNSET + elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): + not_required_nullable_model = self.not_required_nullable_model.to_dict() + else: + not_required_nullable_model = self.not_required_nullable_model + + field_dict: dict[str, Any] = {} + field_dict.update( + { + "an_enum_value": an_enum_value, + "an_allof_enum_with_overridden_default": an_allof_enum_with_overridden_default, + "aCamelDateTime": a_camel_date_time, + "a_date": a_date, + "a_nullable_date": a_nullable_date, + "a_uuid": a_uuid, + "a_nullable_uuid": a_nullable_uuid, + "required_nullable": required_nullable, + "required_not_nullable": required_not_nullable, + "one_of_models": one_of_models, + "nullable_one_of_models": nullable_one_of_models, + "model": model, + "nullable_model": nullable_model, + } + ) + if any_value is not UNSET: + field_dict["any_value"] = any_value + if an_optional_allof_enum is not UNSET: + field_dict["an_optional_allof_enum"] = an_optional_allof_enum + if nested_list_of_enums is not UNSET: + field_dict["nested_list_of_enums"] = nested_list_of_enums + if a_not_required_date is not UNSET: + field_dict["a_not_required_date"] = a_not_required_date + if a_not_required_uuid is not UNSET: + field_dict["a_not_required_uuid"] = a_not_required_uuid + if attr_1_leading_digit is not UNSET: + field_dict["1_leading_digit"] = attr_1_leading_digit + if attr_leading_underscore is not UNSET: + field_dict["_leading_underscore"] = attr_leading_underscore + if not_required_nullable is not UNSET: + field_dict["not_required_nullable"] = not_required_nullable + if not_required_not_nullable is not UNSET: + field_dict["not_required_not_nullable"] = not_required_not_nullable + if not_required_one_of_models is not UNSET: + field_dict["not_required_one_of_models"] = not_required_one_of_models + if not_required_nullable_one_of_models is not UNSET: + field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models + if not_required_model is not UNSET: + field_dict["not_required_model"] = not_required_model + if not_required_nullable_model is not UNSET: + field_dict["not_required_nullable_model"] = not_required_nullable_model + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + d = src_dict.copy() + an_enum_value = AnEnum(d.pop("an_enum_value")) + + an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) + + def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: + try: + if not isinstance(data, str): + raise TypeError() + a_camel_date_time_type_0 = isoparse(data) + + return a_camel_date_time_type_0 + except: # noqa: E722 + pass + if not isinstance(data, str): + raise TypeError() + a_camel_date_time_type_1 = isoparse(data).date() + + return a_camel_date_time_type_1 + + a_camel_date_time = _parse_a_camel_date_time(d.pop("aCamelDateTime")) + + a_date = isoparse(d.pop("a_date")).date() + + def _parse_a_nullable_date(data: object) -> Union[None, datetime.date]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + a_nullable_date_type_0 = isoparse(data).date() + + return a_nullable_date_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.date], data) + + a_nullable_date = _parse_a_nullable_date(d.pop("a_nullable_date")) + + a_uuid = UUID(d.pop("a_uuid")) + + def _parse_a_nullable_uuid(data: object) -> Union[None, UUID]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + a_nullable_uuid_type_0 = UUID(data) + + return a_nullable_uuid_type_0 + except: # noqa: E722 + pass + return cast(Union[None, UUID], data) + + a_nullable_uuid = _parse_a_nullable_uuid(d.pop("a_nullable_uuid")) + + def _parse_required_nullable(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + required_nullable = _parse_required_nullable(d.pop("required_nullable")) + + required_not_nullable = d.pop("required_not_nullable") + + def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: + try: + if not isinstance(data, dict): + raise TypeError() + one_of_models_type_0 = FreeFormModel.from_dict(data) + + return one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", Any], data) + + one_of_models = _parse_one_of_models(d.pop("one_of_models")) + + def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return nullable_one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return nullable_one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) + + nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) + + model = ModelWithUnionProperty.from_dict(d.pop("model")) + + def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + + return nullable_model_type_1 + except: # noqa: E722 + pass + return cast(Union["ModelWithUnionProperty", None], data) + + nullable_model = _parse_nullable_model(d.pop("nullable_model")) + + any_value = d.pop("any_value", UNSET) + + _an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET) + an_optional_allof_enum: Union[Unset, AnAllOfEnum] + if isinstance(_an_optional_allof_enum, Unset): + an_optional_allof_enum = UNSET + else: + an_optional_allof_enum = AnAllOfEnum(_an_optional_allof_enum) + + nested_list_of_enums = [] + _nested_list_of_enums = d.pop("nested_list_of_enums", UNSET) + for nested_list_of_enums_item_data in _nested_list_of_enums or []: + nested_list_of_enums_item = [] + _nested_list_of_enums_item = nested_list_of_enums_item_data + for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: + nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) + + nested_list_of_enums_item.append(nested_list_of_enums_item_item) + + nested_list_of_enums.append(nested_list_of_enums_item) + + _a_not_required_date = d.pop("a_not_required_date", UNSET) + a_not_required_date: Union[Unset, datetime.date] + if isinstance(_a_not_required_date, Unset): + a_not_required_date = UNSET + else: + a_not_required_date = isoparse(_a_not_required_date).date() + + _a_not_required_uuid = d.pop("a_not_required_uuid", UNSET) + a_not_required_uuid: Union[Unset, UUID] + if isinstance(_a_not_required_uuid, Unset): + a_not_required_uuid = UNSET + else: + a_not_required_uuid = UUID(_a_not_required_uuid) + + attr_1_leading_digit = d.pop("1_leading_digit", UNSET) + + attr_leading_underscore = d.pop("_leading_underscore", UNSET) + + def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) + + not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) + + def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return not_required_one_of_models_type_0 + except: # noqa: E722 + pass + if not isinstance(data, dict): + raise TypeError() + not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_one_of_models_type_1 + + not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) + + def _parse_not_required_nullable_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return not_required_nullable_one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_nullable_one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) + + not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( + d.pop("not_required_nullable_one_of_models", UNSET) + ) + + _not_required_model = d.pop("not_required_model", UNSET) + not_required_model: Union[Unset, ModelWithUnionProperty] + if isinstance(_not_required_model, Unset): + not_required_model = UNSET + else: + not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) + + def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_nullable_model_type_1 + except: # noqa: E722 + pass + return cast(Union["ModelWithUnionProperty", None, Unset], data) + + not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) + + a_model = cls( + an_enum_value=an_enum_value, + an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, + a_camel_date_time=a_camel_date_time, + a_date=a_date, + a_nullable_date=a_nullable_date, + a_uuid=a_uuid, + a_nullable_uuid=a_nullable_uuid, + required_nullable=required_nullable, + required_not_nullable=required_not_nullable, + one_of_models=one_of_models, + nullable_one_of_models=nullable_one_of_models, + model=model, + nullable_model=nullable_model, + any_value=any_value, + an_optional_allof_enum=an_optional_allof_enum, + nested_list_of_enums=nested_list_of_enums, + a_not_required_date=a_not_required_date, + a_not_required_uuid=a_not_required_uuid, + attr_1_leading_digit=attr_1_leading_digit, + attr_leading_underscore=attr_leading_underscore, + not_required_nullable=not_required_nullable, + not_required_not_nullable=not_required_not_nullable, + not_required_one_of_models=not_required_one_of_models, + not_required_nullable_one_of_models=not_required_nullable_one_of_models, + not_required_model=not_required_model, + not_required_nullable_model=not_required_nullable_model, + ) + + return a_model diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py new file mode 100644 index 000000000..0c338207d --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -0,0 +1,343 @@ +import datetime +from io import BytesIO +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.an_enum import AnEnum +from ..types import File + +T = TypeVar("T", bound="AModelWithPropertiesReferenceThatAreNotObject") + + +@_attrs_define +class AModelWithPropertiesReferenceThatAreNotObject: + 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 + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + enum_properties_ref = [] + for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: + componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value + enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) + + str_properties_ref = self.str_properties_ref + + date_properties_ref = [] + for componentsschemas_an_other_array_of_date_item_data in self.date_properties_ref: + componentsschemas_an_other_array_of_date_item = ( + componentsschemas_an_other_array_of_date_item_data.isoformat() + ) + date_properties_ref.append(componentsschemas_an_other_array_of_date_item) + + datetime_properties_ref = [] + for componentsschemas_an_other_array_of_date_time_item_data in self.datetime_properties_ref: + componentsschemas_an_other_array_of_date_time_item = ( + componentsschemas_an_other_array_of_date_time_item_data.isoformat() + ) + datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) + + int32_properties_ref = self.int32_properties_ref + + int64_properties_ref = self.int64_properties_ref + + float_properties_ref = self.float_properties_ref + + double_properties_ref = self.double_properties_ref + + file_properties_ref = [] + for componentsschemas_an_other_array_of_file_item_data in self.file_properties_ref: + componentsschemas_an_other_array_of_file_item = ( + componentsschemas_an_other_array_of_file_item_data.to_tuple() + ) + + file_properties_ref.append(componentsschemas_an_other_array_of_file_item) + + bytestream_properties_ref = self.bytestream_properties_ref + + enum_properties = [] + for componentsschemas_an_array_of_enum_item_data in self.enum_properties: + componentsschemas_an_array_of_enum_item = componentsschemas_an_array_of_enum_item_data.value + enum_properties.append(componentsschemas_an_array_of_enum_item) + + str_properties = self.str_properties + + date_properties = [] + for componentsschemas_an_array_of_date_item_data in self.date_properties: + componentsschemas_an_array_of_date_item = componentsschemas_an_array_of_date_item_data.isoformat() + date_properties.append(componentsschemas_an_array_of_date_item) + + datetime_properties = [] + for componentsschemas_an_array_of_date_time_item_data in self.datetime_properties: + componentsschemas_an_array_of_date_time_item = componentsschemas_an_array_of_date_time_item_data.isoformat() + datetime_properties.append(componentsschemas_an_array_of_date_time_item) + + int32_properties = self.int32_properties + + int64_properties = self.int64_properties + + float_properties = self.float_properties + + double_properties = self.double_properties + + file_properties = [] + for componentsschemas_an_array_of_file_item_data in self.file_properties: + componentsschemas_an_array_of_file_item = componentsschemas_an_array_of_file_item_data.to_tuple() + + file_properties.append(componentsschemas_an_array_of_file_item) + + bytestream_properties = self.bytestream_properties + + enum_property_ref = self.enum_property_ref.value + + str_property_ref = self.str_property_ref + + date_property_ref = self.date_property_ref.isoformat() + + datetime_property_ref = self.datetime_property_ref.isoformat() + + int32_property_ref = self.int32_property_ref + + int64_property_ref = self.int64_property_ref + + float_property_ref = self.float_property_ref + + double_property_ref = self.double_property_ref + + file_property_ref = self.file_property_ref.to_tuple() + + bytestream_property_ref = self.bytestream_property_ref + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "enum_properties_ref": enum_properties_ref, + "str_properties_ref": str_properties_ref, + "date_properties_ref": date_properties_ref, + "datetime_properties_ref": datetime_properties_ref, + "int32_properties_ref": int32_properties_ref, + "int64_properties_ref": int64_properties_ref, + "float_properties_ref": float_properties_ref, + "double_properties_ref": double_properties_ref, + "file_properties_ref": file_properties_ref, + "bytestream_properties_ref": bytestream_properties_ref, + "enum_properties": enum_properties, + "str_properties": str_properties, + "date_properties": date_properties, + "datetime_properties": datetime_properties, + "int32_properties": int32_properties, + "int64_properties": int64_properties, + "float_properties": float_properties, + "double_properties": double_properties, + "file_properties": file_properties, + "bytestream_properties": bytestream_properties, + "enum_property_ref": enum_property_ref, + "str_property_ref": str_property_ref, + "date_property_ref": date_property_ref, + "datetime_property_ref": datetime_property_ref, + "int32_property_ref": int32_property_ref, + "int64_property_ref": int64_property_ref, + "float_property_ref": float_property_ref, + "double_property_ref": double_property_ref, + "file_property_ref": file_property_ref, + "bytestream_property_ref": bytestream_property_ref, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + enum_properties_ref = [] + _enum_properties_ref = d.pop("enum_properties_ref") + for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref: + componentsschemas_an_other_array_of_enum_item = AnEnum(componentsschemas_an_other_array_of_enum_item_data) + + enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) + + str_properties_ref = cast(list[str], d.pop("str_properties_ref")) + + date_properties_ref = [] + _date_properties_ref = d.pop("date_properties_ref") + for componentsschemas_an_other_array_of_date_item_data in _date_properties_ref: + componentsschemas_an_other_array_of_date_item = isoparse( + componentsschemas_an_other_array_of_date_item_data + ).date() + + date_properties_ref.append(componentsschemas_an_other_array_of_date_item) + + datetime_properties_ref = [] + _datetime_properties_ref = d.pop("datetime_properties_ref") + for componentsschemas_an_other_array_of_date_time_item_data in _datetime_properties_ref: + componentsschemas_an_other_array_of_date_time_item = isoparse( + componentsschemas_an_other_array_of_date_time_item_data + ) + + datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) + + int32_properties_ref = cast(list[int], d.pop("int32_properties_ref")) + + int64_properties_ref = cast(list[int], d.pop("int64_properties_ref")) + + float_properties_ref = cast(list[float], d.pop("float_properties_ref")) + + double_properties_ref = cast(list[float], d.pop("double_properties_ref")) + + file_properties_ref = [] + _file_properties_ref = d.pop("file_properties_ref") + for componentsschemas_an_other_array_of_file_item_data in _file_properties_ref: + componentsschemas_an_other_array_of_file_item = File( + payload=BytesIO(componentsschemas_an_other_array_of_file_item_data) + ) + + file_properties_ref.append(componentsschemas_an_other_array_of_file_item) + + bytestream_properties_ref = cast(list[str], d.pop("bytestream_properties_ref")) + + enum_properties = [] + _enum_properties = d.pop("enum_properties") + for componentsschemas_an_array_of_enum_item_data in _enum_properties: + componentsschemas_an_array_of_enum_item = AnEnum(componentsschemas_an_array_of_enum_item_data) + + enum_properties.append(componentsschemas_an_array_of_enum_item) + + str_properties = cast(list[str], d.pop("str_properties")) + + date_properties = [] + _date_properties = d.pop("date_properties") + for componentsschemas_an_array_of_date_item_data in _date_properties: + componentsschemas_an_array_of_date_item = isoparse(componentsschemas_an_array_of_date_item_data).date() + + date_properties.append(componentsschemas_an_array_of_date_item) + + datetime_properties = [] + _datetime_properties = d.pop("datetime_properties") + for componentsschemas_an_array_of_date_time_item_data in _datetime_properties: + componentsschemas_an_array_of_date_time_item = isoparse(componentsschemas_an_array_of_date_time_item_data) + + datetime_properties.append(componentsschemas_an_array_of_date_time_item) + + int32_properties = cast(list[int], d.pop("int32_properties")) + + int64_properties = cast(list[int], d.pop("int64_properties")) + + float_properties = cast(list[float], d.pop("float_properties")) + + double_properties = cast(list[float], d.pop("double_properties")) + + file_properties = [] + _file_properties = d.pop("file_properties") + for componentsschemas_an_array_of_file_item_data in _file_properties: + componentsschemas_an_array_of_file_item = File( + payload=BytesIO(componentsschemas_an_array_of_file_item_data) + ) + + file_properties.append(componentsschemas_an_array_of_file_item) + + bytestream_properties = cast(list[str], d.pop("bytestream_properties")) + + enum_property_ref = AnEnum(d.pop("enum_property_ref")) + + str_property_ref = d.pop("str_property_ref") + + date_property_ref = isoparse(d.pop("date_property_ref")).date() + + datetime_property_ref = isoparse(d.pop("datetime_property_ref")) + + int32_property_ref = d.pop("int32_property_ref") + + int64_property_ref = d.pop("int64_property_ref") + + float_property_ref = d.pop("float_property_ref") + + double_property_ref = d.pop("double_property_ref") + + file_property_ref = File(payload=BytesIO(d.pop("file_property_ref"))) + + bytestream_property_ref = d.pop("bytestream_property_ref") + + a_model_with_properties_reference_that_are_not_object = cls( + enum_properties_ref=enum_properties_ref, + str_properties_ref=str_properties_ref, + date_properties_ref=date_properties_ref, + datetime_properties_ref=datetime_properties_ref, + int32_properties_ref=int32_properties_ref, + int64_properties_ref=int64_properties_ref, + float_properties_ref=float_properties_ref, + double_properties_ref=double_properties_ref, + file_properties_ref=file_properties_ref, + bytestream_properties_ref=bytestream_properties_ref, + enum_properties=enum_properties, + str_properties=str_properties, + date_properties=date_properties, + datetime_properties=datetime_properties, + int32_properties=int32_properties, + int64_properties=int64_properties, + float_properties=float_properties, + double_properties=double_properties, + file_properties=file_properties, + bytestream_properties=bytestream_properties, + enum_property_ref=enum_property_ref, + str_property_ref=str_property_ref, + date_property_ref=date_property_ref, + datetime_property_ref=datetime_property_ref, + int32_property_ref=int32_property_ref, + int64_property_ref=int64_property_ref, + float_property_ref=float_property_ref, + double_property_ref=double_property_ref, + file_property_ref=file_property_ref, + bytestream_property_ref=bytestream_property_ref, + ) + + a_model_with_properties_reference_that_are_not_object.additional_properties = d + return a_model_with_properties_reference_that_are_not_object + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py new file mode 100644 index 000000000..4869c0f96 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py @@ -0,0 +1,77 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AllOfHasPropertiesButNoType") + + +@_attrs_define +class AllOfHasPropertiesButNoType: + a_sub_property: Union[Unset, str] = UNSET + type_: Union[Unset, str] = UNSET + type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a_sub_property = self.a_sub_property + + type_ = self.type_ + + type_enum: Union[Unset, int] = UNSET + if not isinstance(self.type_enum, Unset): + type_enum = self.type_enum.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a_sub_property is not UNSET: + field_dict["a_sub_property"] = a_sub_property + if type_ is not UNSET: + field_dict["type"] = type_ + if type_enum is not UNSET: + field_dict["type_enum"] = type_enum + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_sub_property = d.pop("a_sub_property", UNSET) + + type_ = d.pop("type", UNSET) + + _type_enum = d.pop("type_enum", UNSET) + type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] + if isinstance(_type_enum, Unset): + type_enum = UNSET + else: + type_enum = AllOfHasPropertiesButNoTypeTypeEnum(_type_enum) + + all_of_has_properties_but_no_type = cls( + a_sub_property=a_sub_property, + type_=type_, + type_enum=type_enum, + ) + + all_of_has_properties_but_no_type.additional_properties = d + return all_of_has_properties_but_no_type + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py new file mode 100644 index 000000000..4966e1970 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py @@ -0,0 +1,9 @@ +from enum import IntEnum + + +class AllOfHasPropertiesButNoTypeTypeEnum(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py new file mode 100644 index 000000000..c44f73a90 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py @@ -0,0 +1,77 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.all_of_sub_model_type_enum import AllOfSubModelTypeEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AllOfSubModel") + + +@_attrs_define +class AllOfSubModel: + a_sub_property: Union[Unset, str] = UNSET + type_: Union[Unset, str] = UNSET + type_enum: Union[Unset, AllOfSubModelTypeEnum] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a_sub_property = self.a_sub_property + + type_ = self.type_ + + type_enum: Union[Unset, int] = UNSET + if not isinstance(self.type_enum, Unset): + type_enum = self.type_enum.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a_sub_property is not UNSET: + field_dict["a_sub_property"] = a_sub_property + if type_ is not UNSET: + field_dict["type"] = type_ + if type_enum is not UNSET: + field_dict["type_enum"] = type_enum + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_sub_property = d.pop("a_sub_property", UNSET) + + type_ = d.pop("type", UNSET) + + _type_enum = d.pop("type_enum", UNSET) + type_enum: Union[Unset, AllOfSubModelTypeEnum] + if isinstance(_type_enum, Unset): + type_enum = UNSET + else: + type_enum = AllOfSubModelTypeEnum(_type_enum) + + all_of_sub_model = cls( + a_sub_property=a_sub_property, + type_=type_, + type_enum=type_enum, + ) + + all_of_sub_model.additional_properties = d + return all_of_sub_model + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py new file mode 100644 index 000000000..817e0eb7c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py @@ -0,0 +1,9 @@ +from enum import IntEnum + + +class AllOfSubModelTypeEnum(IntEnum): + VALUE_0 = 0 + VALUE_1 = 1 + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py new file mode 100644 index 000000000..3aef48f8f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class AnAllOfEnum(str, Enum): + A_DEFAULT = "a_default" + BAR = "bar" + FOO = "foo" + OVERRIDDEN_DEFAULT = "overridden_default" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py new file mode 100644 index 000000000..5d1fdf75e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py @@ -0,0 +1,77 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem + + +T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAItem") + + +@_attrs_define +class AnArrayWithACircularRefInItemsObjectAItem: + circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectBItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, list[dict[str, Any]]] = UNSET + if not isinstance(self.circular, Unset): + circular = [] + for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in self.circular: + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data.to_dict() + ) + circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if circular is not UNSET: + field_dict["circular"] = circular + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.an_array_with_a_circular_ref_in_items_object_b_item import ( + AnArrayWithACircularRefInItemsObjectBItem, + ) + + d = src_dict.copy() + circular = [] + _circular = d.pop("circular", UNSET) + for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in _circular or []: + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( + AnArrayWithACircularRefInItemsObjectBItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data + ) + ) + + circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) + + an_array_with_a_circular_ref_in_items_object_a_item = cls( + circular=circular, + ) + + an_array_with_a_circular_ref_in_items_object_a_item.additional_properties = d + return an_array_with_a_circular_ref_in_items_object_a_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py new file mode 100644 index 000000000..be27e601b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py @@ -0,0 +1,84 @@ +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, + ) + + +T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem") + + +@_attrs_define +class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem: + additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]] = ( + _attrs_field(init=False, factory=dict) + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = [] + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data + ) in prop: + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data.to_dict() + field_dict[prop_name].append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, + ) + + d = src_dict.copy() + an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = [] + _additional_property = prop_dict + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data + ) in _additional_property: + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data + ) + ) + + additional_property.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item + ) + + additional_properties[prop_name] = additional_property + + an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.additional_properties = ( + additional_properties + ) + return an_array_with_a_circular_ref_in_items_object_additional_properties_a_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: + return self.additional_properties[key] + + def __setitem__( + self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] + ) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py new file mode 100644 index 000000000..0b62f118b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py @@ -0,0 +1,84 @@ +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, + ) + + +T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem") + + +@_attrs_define +class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem: + additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]] = ( + _attrs_field(init=False, factory=dict) + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = [] + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data + ) in prop: + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data.to_dict() + field_dict[prop_name].append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, + ) + + d = src_dict.copy() + an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = [] + _additional_property = prop_dict + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data + ) in _additional_property: + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = ( + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data + ) + ) + + additional_property.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item + ) + + additional_properties[prop_name] = additional_property + + an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.additional_properties = ( + additional_properties + ) + return an_array_with_a_circular_ref_in_items_object_additional_properties_b_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: + return self.additional_properties[key] + + def __setitem__( + self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] + ) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py new file mode 100644 index 000000000..de63ba76c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py @@ -0,0 +1,77 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem + + +T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectBItem") + + +@_attrs_define +class AnArrayWithACircularRefInItemsObjectBItem: + circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectAItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, list[dict[str, Any]]] = UNSET + if not isinstance(self.circular, Unset): + circular = [] + for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in self.circular: + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data.to_dict() + ) + circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if circular is not UNSET: + field_dict["circular"] = circular + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.an_array_with_a_circular_ref_in_items_object_a_item import ( + AnArrayWithACircularRefInItemsObjectAItem, + ) + + d = src_dict.copy() + circular = [] + _circular = d.pop("circular", UNSET) + for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in _circular or []: + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( + AnArrayWithACircularRefInItemsObjectAItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data + ) + ) + + circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) + + an_array_with_a_circular_ref_in_items_object_b_item = cls( + circular=circular, + ) + + an_array_with_a_circular_ref_in_items_object_b_item.additional_properties = d + return an_array_with_a_circular_ref_in_items_object_b_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py new file mode 100644 index 000000000..e861688d8 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py @@ -0,0 +1,72 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem") + + +@_attrs_define +class AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem: + additional_properties: dict[str, list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]] = ( + _attrs_field(init=False, factory=dict) + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = [] + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in prop: + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data.to_dict() + field_dict[prop_name].append( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + an_array_with_a_recursive_ref_in_items_object_additional_properties_item = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = [] + _additional_property = prop_dict + for ( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data + ) in _additional_property: + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = ( + AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.from_dict( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data + ) + ) + + additional_property.append( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item + ) + + additional_properties[prop_name] = additional_property + + an_array_with_a_recursive_ref_in_items_object_additional_properties_item.additional_properties = ( + additional_properties + ) + return an_array_with_a_recursive_ref_in_items_object_additional_properties_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: + return self.additional_properties[key] + + def __setitem__( + self, key: str, value: list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] + ) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py new file mode 100644 index 000000000..a1a89b4fa --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py @@ -0,0 +1,69 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AnArrayWithARecursiveRefInItemsObjectItem") + + +@_attrs_define +class AnArrayWithARecursiveRefInItemsObjectItem: + recursive: Union[Unset, list["AnArrayWithARecursiveRefInItemsObjectItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + recursive: Union[Unset, list[dict[str, Any]]] = UNSET + if not isinstance(self.recursive, Unset): + recursive = [] + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in self.recursive: + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data.to_dict() + ) + recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if recursive is not UNSET: + field_dict["recursive"] = recursive + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + recursive = [] + _recursive = d.pop("recursive", UNSET) + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in _recursive or []: + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( + AnArrayWithARecursiveRefInItemsObjectItem.from_dict( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data + ) + ) + + recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) + + an_array_with_a_recursive_ref_in_items_object_item = cls( + recursive=recursive, + ) + + an_array_with_a_recursive_ref_in_items_object_item.additional_properties = d + return an_array_with_a_recursive_ref_in_items_object_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py new file mode 100644 index 000000000..c266d0763 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class AnEnum(str, Enum): + FIRST_VALUE = "FIRST_VALUE" + SECOND_VALUE = "SECOND_VALUE" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py new file mode 100644 index 000000000..b1d6611e0 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class AnEnumWithNull(str, Enum): + FIRST_VALUE = "FIRST_VALUE" + SECOND_VALUE = "SECOND_VALUE" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py new file mode 100644 index 000000000..d7d7a713d --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py @@ -0,0 +1,10 @@ +from enum import IntEnum + + +class AnIntEnum(IntEnum): + VALUE_NEGATIVE_1 = -1 + VALUE_1 = 1 + VALUE_2 = 2 + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py new file mode 100644 index 000000000..d5e26e481 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py @@ -0,0 +1,85 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.another_all_of_sub_model_type import AnotherAllOfSubModelType +from ..models.another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AnotherAllOfSubModel") + + +@_attrs_define +class AnotherAllOfSubModel: + another_sub_property: Union[Unset, str] = UNSET + type_: Union[Unset, AnotherAllOfSubModelType] = UNSET + type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + another_sub_property = self.another_sub_property + + type_: Union[Unset, str] = UNSET + if not isinstance(self.type_, Unset): + type_ = self.type_.value + + type_enum: Union[Unset, int] = UNSET + if not isinstance(self.type_enum, Unset): + type_enum = self.type_enum.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if another_sub_property is not UNSET: + field_dict["another_sub_property"] = another_sub_property + if type_ is not UNSET: + field_dict["type"] = type_ + if type_enum is not UNSET: + field_dict["type_enum"] = type_enum + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + another_sub_property = d.pop("another_sub_property", UNSET) + + _type_ = d.pop("type", UNSET) + type_: Union[Unset, AnotherAllOfSubModelType] + if isinstance(_type_, Unset): + type_ = UNSET + else: + type_ = AnotherAllOfSubModelType(_type_) + + _type_enum = d.pop("type_enum", UNSET) + type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] + if isinstance(_type_enum, Unset): + type_enum = UNSET + else: + type_enum = AnotherAllOfSubModelTypeEnum(_type_enum) + + another_all_of_sub_model = cls( + another_sub_property=another_sub_property, + type_=type_, + type_enum=type_enum, + ) + + another_all_of_sub_model.additional_properties = d + return another_all_of_sub_model + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py new file mode 100644 index 000000000..b2e82aa7c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class AnotherAllOfSubModelType(str, Enum): + SUBMODEL = "submodel" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py new file mode 100644 index 000000000..d54ed9dde --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py @@ -0,0 +1,8 @@ +from enum import IntEnum + + +class AnotherAllOfSubModelTypeEnum(IntEnum): + VALUE_0 = 0 + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py new file mode 100644 index 000000000..f26df5faf --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py @@ -0,0 +1,422 @@ +import datetime +import json +from io import BytesIO +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.different_enum import DifferentEnum +from ..types import UNSET, File, FileJsonType, Unset + +if TYPE_CHECKING: + from ..models.a_form_data import AFormData + from ..models.body_upload_file_tests_upload_post_additional_property import ( + BodyUploadFileTestsUploadPostAdditionalProperty, + ) + from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( + BodyUploadFileTestsUploadPostSomeNullableObject, + ) + from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject + from ..models.body_upload_file_tests_upload_post_some_optional_object import ( + BodyUploadFileTestsUploadPostSomeOptionalObject, + ) + + +T = TypeVar("T", bound="BodyUploadFileTestsUploadPost") + + +@_attrs_define +class BodyUploadFileTestsUploadPost: + some_file: File + some_required_number: float + some_object: "BodyUploadFileTestsUploadPostSomeObject" + some_nullable_object: Union["BodyUploadFileTestsUploadPostSomeNullableObject", None] + some_optional_file: Union[Unset, File] = UNSET + some_string: Union[Unset, str] = "some_default_string" + a_datetime: Union[Unset, datetime.datetime] = UNSET + a_date: Union[Unset, datetime.date] = UNSET + some_number: Union[Unset, float] = UNSET + some_nullable_number: Union[None, Unset, float] = UNSET + some_int_array: Union[Unset, list[Union[None, int]]] = UNSET + some_array: Union[None, Unset, list["AFormData"]] = UNSET + some_optional_object: Union[Unset, "BodyUploadFileTestsUploadPostSomeOptionalObject"] = UNSET + some_enum: Union[Unset, DifferentEnum] = UNSET + """ An enumeration. """ + additional_properties: dict[str, "BodyUploadFileTestsUploadPostAdditionalProperty"] = _attrs_field( + init=False, factory=dict + ) + + def to_dict(self) -> dict[str, Any]: + from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( + BodyUploadFileTestsUploadPostSomeNullableObject, + ) + + some_file = self.some_file.to_tuple() + + some_required_number = self.some_required_number + + some_object = self.some_object.to_dict() + + some_nullable_object: Union[None, dict[str, Any]] + if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): + some_nullable_object = self.some_nullable_object.to_dict() + else: + some_nullable_object = self.some_nullable_object + + some_optional_file: Union[Unset, FileJsonType] = UNSET + if not isinstance(self.some_optional_file, Unset): + some_optional_file = self.some_optional_file.to_tuple() + + some_string = self.some_string + + a_datetime: Union[Unset, str] = UNSET + if not isinstance(self.a_datetime, Unset): + a_datetime = self.a_datetime.isoformat() + + a_date: Union[Unset, str] = UNSET + if not isinstance(self.a_date, Unset): + a_date = self.a_date.isoformat() + + some_number = self.some_number + + some_nullable_number: Union[None, Unset, float] + if isinstance(self.some_nullable_number, Unset): + some_nullable_number = UNSET + else: + some_nullable_number = self.some_nullable_number + + some_int_array: Union[Unset, list[Union[None, int]]] = UNSET + if not isinstance(self.some_int_array, Unset): + some_int_array = [] + for some_int_array_item_data in self.some_int_array: + some_int_array_item: Union[None, int] + some_int_array_item = some_int_array_item_data + some_int_array.append(some_int_array_item) + + some_array: Union[None, Unset, list[dict[str, Any]]] + if isinstance(self.some_array, Unset): + some_array = UNSET + elif isinstance(self.some_array, list): + some_array = [] + for some_array_type_0_item_data in self.some_array: + some_array_type_0_item = some_array_type_0_item_data.to_dict() + some_array.append(some_array_type_0_item) + + else: + some_array = self.some_array + + some_optional_object: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.some_optional_object, Unset): + some_optional_object = self.some_optional_object.to_dict() + + some_enum: Union[Unset, str] = UNSET + if not isinstance(self.some_enum, Unset): + some_enum = self.some_enum.value + + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.to_dict() + field_dict.update( + { + "some_file": some_file, + "some_required_number": some_required_number, + "some_object": some_object, + "some_nullable_object": some_nullable_object, + } + ) + if some_optional_file is not UNSET: + field_dict["some_optional_file"] = some_optional_file + if some_string is not UNSET: + field_dict["some_string"] = some_string + if a_datetime is not UNSET: + field_dict["a_datetime"] = a_datetime + if a_date is not UNSET: + field_dict["a_date"] = a_date + if some_number is not UNSET: + field_dict["some_number"] = some_number + if some_nullable_number is not UNSET: + field_dict["some_nullable_number"] = some_nullable_number + if some_int_array is not UNSET: + field_dict["some_int_array"] = some_int_array + if some_array is not UNSET: + field_dict["some_array"] = some_array + if some_optional_object is not UNSET: + field_dict["some_optional_object"] = some_optional_object + if some_enum is not UNSET: + field_dict["some_enum"] = some_enum + + return field_dict + + def to_multipart(self) -> dict[str, Any]: + some_file = self.some_file.to_tuple() + + some_required_number = (None, str(self.some_required_number).encode(), "text/plain") + + some_object = (None, json.dumps(self.some_object.to_dict()).encode(), "application/json") + + some_nullable_object: tuple[None, bytes, str] + + if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): + some_nullable_object = (None, json.dumps(self.some_nullable_object.to_dict()).encode(), "application/json") + else: + some_nullable_object = (None, str(self.some_nullable_object).encode(), "text/plain") + + some_optional_file: Union[Unset, FileJsonType] = UNSET + if not isinstance(self.some_optional_file, Unset): + some_optional_file = self.some_optional_file.to_tuple() + + some_string = ( + self.some_string + if isinstance(self.some_string, Unset) + else (None, str(self.some_string).encode(), "text/plain") + ) + + a_datetime: Union[Unset, bytes] = UNSET + if not isinstance(self.a_datetime, Unset): + a_datetime = self.a_datetime.isoformat().encode() + + a_date: Union[Unset, bytes] = UNSET + if not isinstance(self.a_date, Unset): + a_date = self.a_date.isoformat().encode() + + some_number = ( + self.some_number + if isinstance(self.some_number, Unset) + else (None, str(self.some_number).encode(), "text/plain") + ) + + some_nullable_number: Union[Unset, tuple[None, bytes, str]] + + if isinstance(self.some_nullable_number, Unset): + some_nullable_number = UNSET + elif isinstance(self.some_nullable_number, float): + some_nullable_number = (None, str(self.some_nullable_number).encode(), "text/plain") + else: + some_nullable_number = (None, str(self.some_nullable_number).encode(), "text/plain") + + some_int_array: Union[Unset, tuple[None, bytes, str]] = UNSET + if not isinstance(self.some_int_array, Unset): + _temp_some_int_array = [] + for some_int_array_item_data in self.some_int_array: + some_int_array_item: Union[None, int] + some_int_array_item = some_int_array_item_data + _temp_some_int_array.append(some_int_array_item) + some_int_array = (None, json.dumps(_temp_some_int_array).encode(), "application/json") + + some_array: Union[Unset, tuple[None, bytes, str]] + + if isinstance(self.some_array, Unset): + some_array = UNSET + elif isinstance(self.some_array, list): + _temp_some_array = [] + for some_array_type_0_item_data in self.some_array: + some_array_type_0_item = some_array_type_0_item_data.to_dict() + _temp_some_array.append(some_array_type_0_item) + some_array = (None, json.dumps(_temp_some_array).encode(), "application/json") + else: + some_array = (None, str(self.some_array).encode(), "text/plain") + + some_optional_object: Union[Unset, tuple[None, bytes, str]] = UNSET + if not isinstance(self.some_optional_object, Unset): + some_optional_object = (None, json.dumps(self.some_optional_object.to_dict()).encode(), "application/json") + + some_enum: Union[Unset, tuple[None, bytes, str]] = UNSET + if not isinstance(self.some_enum, Unset): + some_enum = (None, str(self.some_enum.value).encode(), "text/plain") + + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = (None, json.dumps(prop.to_dict()).encode(), "application/json") + field_dict.update( + { + "some_file": some_file, + "some_required_number": some_required_number, + "some_object": some_object, + "some_nullable_object": some_nullable_object, + } + ) + if some_optional_file is not UNSET: + field_dict["some_optional_file"] = some_optional_file + if some_string is not UNSET: + field_dict["some_string"] = some_string + if a_datetime is not UNSET: + field_dict["a_datetime"] = a_datetime + if a_date is not UNSET: + field_dict["a_date"] = a_date + if some_number is not UNSET: + field_dict["some_number"] = some_number + if some_nullable_number is not UNSET: + field_dict["some_nullable_number"] = some_nullable_number + if some_int_array is not UNSET: + field_dict["some_int_array"] = some_int_array + if some_array is not UNSET: + field_dict["some_array"] = some_array + if some_optional_object is not UNSET: + field_dict["some_optional_object"] = some_optional_object + if some_enum is not UNSET: + field_dict["some_enum"] = some_enum + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.a_form_data import AFormData + from ..models.body_upload_file_tests_upload_post_additional_property import ( + BodyUploadFileTestsUploadPostAdditionalProperty, + ) + from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( + BodyUploadFileTestsUploadPostSomeNullableObject, + ) + from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject + from ..models.body_upload_file_tests_upload_post_some_optional_object import ( + BodyUploadFileTestsUploadPostSomeOptionalObject, + ) + + d = src_dict.copy() + some_file = File(payload=BytesIO(d.pop("some_file"))) + + some_required_number = d.pop("some_required_number") + + some_object = BodyUploadFileTestsUploadPostSomeObject.from_dict(d.pop("some_object")) + + def _parse_some_nullable_object(data: object) -> Union["BodyUploadFileTestsUploadPostSomeNullableObject", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + some_nullable_object_type_0 = BodyUploadFileTestsUploadPostSomeNullableObject.from_dict(data) + + return some_nullable_object_type_0 + except: # noqa: E722 + pass + return cast(Union["BodyUploadFileTestsUploadPostSomeNullableObject", None], data) + + some_nullable_object = _parse_some_nullable_object(d.pop("some_nullable_object")) + + _some_optional_file = d.pop("some_optional_file", UNSET) + some_optional_file: Union[Unset, File] + if isinstance(_some_optional_file, Unset): + some_optional_file = UNSET + else: + some_optional_file = File(payload=BytesIO(_some_optional_file)) + + some_string = d.pop("some_string", UNSET) + + _a_datetime = d.pop("a_datetime", UNSET) + a_datetime: Union[Unset, datetime.datetime] + if isinstance(_a_datetime, Unset): + a_datetime = UNSET + else: + a_datetime = isoparse(_a_datetime) + + _a_date = d.pop("a_date", UNSET) + a_date: Union[Unset, datetime.date] + if isinstance(_a_date, Unset): + a_date = UNSET + else: + a_date = isoparse(_a_date).date() + + some_number = d.pop("some_number", UNSET) + + def _parse_some_nullable_number(data: object) -> Union[None, Unset, float]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, float], data) + + some_nullable_number = _parse_some_nullable_number(d.pop("some_nullable_number", UNSET)) + + some_int_array = [] + _some_int_array = d.pop("some_int_array", UNSET) + for some_int_array_item_data in _some_int_array or []: + + def _parse_some_int_array_item(data: object) -> Union[None, int]: + if data is None: + return data + return cast(Union[None, int], data) + + some_int_array_item = _parse_some_int_array_item(some_int_array_item_data) + + some_int_array.append(some_int_array_item) + + def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + some_array_type_0 = [] + _some_array_type_0 = data + for some_array_type_0_item_data in _some_array_type_0: + some_array_type_0_item = AFormData.from_dict(some_array_type_0_item_data) + + some_array_type_0.append(some_array_type_0_item) + + return some_array_type_0 + except: # noqa: E722 + pass + return cast(Union[None, Unset, list["AFormData"]], data) + + some_array = _parse_some_array(d.pop("some_array", UNSET)) + + _some_optional_object = d.pop("some_optional_object", UNSET) + some_optional_object: Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject] + if isinstance(_some_optional_object, Unset): + some_optional_object = UNSET + else: + some_optional_object = BodyUploadFileTestsUploadPostSomeOptionalObject.from_dict(_some_optional_object) + + _some_enum = d.pop("some_enum", UNSET) + some_enum: Union[Unset, DifferentEnum] + if isinstance(_some_enum, Unset): + some_enum = UNSET + else: + some_enum = DifferentEnum(_some_enum) + + body_upload_file_tests_upload_post = cls( + some_file=some_file, + some_required_number=some_required_number, + some_object=some_object, + some_nullable_object=some_nullable_object, + some_optional_file=some_optional_file, + some_string=some_string, + a_datetime=a_datetime, + a_date=a_date, + some_number=some_number, + some_nullable_number=some_nullable_number, + some_int_array=some_int_array, + some_array=some_array, + some_optional_object=some_optional_object, + some_enum=some_enum, + ) + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + body_upload_file_tests_upload_post.additional_properties = additional_properties + return body_upload_file_tests_upload_post + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "BodyUploadFileTestsUploadPostAdditionalProperty": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "BodyUploadFileTestsUploadPostAdditionalProperty") -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py new file mode 100644 index 000000000..a97c825ca --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BodyUploadFileTestsUploadPostAdditionalProperty") + + +@_attrs_define +class BodyUploadFileTestsUploadPostAdditionalProperty: + foo: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + foo = self.foo + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if foo is not UNSET: + field_dict["foo"] = foo + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + foo = d.pop("foo", UNSET) + + body_upload_file_tests_upload_post_additional_property = cls( + foo=foo, + ) + + body_upload_file_tests_upload_post_additional_property.additional_properties = d + return body_upload_file_tests_upload_post_additional_property + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py new file mode 100644 index 000000000..de2642c84 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeNullableObject") + + +@_attrs_define +class BodyUploadFileTestsUploadPostSomeNullableObject: + bar: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + bar = self.bar + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if bar is not UNSET: + field_dict["bar"] = bar + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + bar = d.pop("bar", UNSET) + + body_upload_file_tests_upload_post_some_nullable_object = cls( + bar=bar, + ) + + body_upload_file_tests_upload_post_some_nullable_object.additional_properties = d + return body_upload_file_tests_upload_post_some_nullable_object + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py new file mode 100644 index 000000000..4a978cd7e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py @@ -0,0 +1,60 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeObject") + + +@_attrs_define +class BodyUploadFileTestsUploadPostSomeObject: + num: float + text: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + num = self.num + + text = self.text + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "num": num, + "text": text, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + num = d.pop("num") + + text = d.pop("text") + + body_upload_file_tests_upload_post_some_object = cls( + num=num, + text=text, + ) + + body_upload_file_tests_upload_post_some_object.additional_properties = d + return body_upload_file_tests_upload_post_some_object + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py new file mode 100644 index 000000000..56230f597 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeOptionalObject") + + +@_attrs_define +class BodyUploadFileTestsUploadPostSomeOptionalObject: + foo: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + foo = self.foo + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "foo": foo, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + foo = d.pop("foo") + + body_upload_file_tests_upload_post_some_optional_object = cls( + foo=foo, + ) + + body_upload_file_tests_upload_post_some_optional_object.additional_properties = d + return body_upload_file_tests_upload_post_some_optional_object + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py new file mode 100644 index 000000000..6c167f25c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class DifferentEnum(str, Enum): + DIFFERENT = "DIFFERENT" + OTHER = "OTHER" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py new file mode 100644 index 000000000..c615e5a2c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py @@ -0,0 +1,534 @@ +import datetime +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.an_all_of_enum import AnAllOfEnum +from ..models.an_enum import AnEnum +from ..models.different_enum import DifferentEnum +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + +T = TypeVar("T", bound="Extended") + + +@_attrs_define +class Extended: + an_enum_value: AnEnum + """ For testing Enums in all the ways they can be used """ + a_camel_date_time: Union[datetime.date, datetime.datetime] + a_date: datetime.date + a_nullable_date: Union[None, datetime.date] + a_uuid: UUID + required_nullable: Union[None, str] + required_not_nullable: str + one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Any] + nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None] + model: "ModelWithUnionProperty" + nullable_model: Union["ModelWithUnionProperty", None] + an_allof_enum_with_overridden_default: AnAllOfEnum = AnAllOfEnum.OVERRIDDEN_DEFAULT + a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") + any_value: Union[Unset, Any] = "default" + an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET + a_not_required_date: Union[Unset, datetime.date] = UNSET + a_not_required_uuid: Union[Unset, UUID] = UNSET + attr_1_leading_digit: Union[Unset, str] = UNSET + attr_leading_underscore: Union[Unset, str] = UNSET + not_required_nullable: Union[None, Unset, str] = UNSET + not_required_not_nullable: Union[Unset, str] = UNSET + not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET + not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET + not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET + not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET + from_extended: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + an_enum_value = self.an_enum_value.value + + an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value + + a_camel_date_time: str + if isinstance(self.a_camel_date_time, datetime.datetime): + a_camel_date_time = self.a_camel_date_time.isoformat() + else: + a_camel_date_time = self.a_camel_date_time.isoformat() + + a_date = self.a_date.isoformat() + + a_nullable_date: Union[None, str] + if isinstance(self.a_nullable_date, datetime.date): + a_nullable_date = self.a_nullable_date.isoformat() + else: + a_nullable_date = self.a_nullable_date + + a_uuid = str(self.a_uuid) + + a_nullable_uuid: Union[None, str] + if isinstance(self.a_nullable_uuid, UUID): + a_nullable_uuid = str(self.a_nullable_uuid) + else: + a_nullable_uuid = self.a_nullable_uuid + + required_nullable: Union[None, str] + required_nullable = self.required_nullable + + required_not_nullable = self.required_not_nullable + + one_of_models: Union[Any, dict[str, Any]] + if isinstance(self.one_of_models, FreeFormModel): + one_of_models = self.one_of_models.to_dict() + elif isinstance(self.one_of_models, ModelWithUnionProperty): + one_of_models = self.one_of_models.to_dict() + else: + one_of_models = self.one_of_models + + nullable_one_of_models: Union[None, dict[str, Any]] + if isinstance(self.nullable_one_of_models, FreeFormModel): + nullable_one_of_models = self.nullable_one_of_models.to_dict() + elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): + nullable_one_of_models = self.nullable_one_of_models.to_dict() + else: + nullable_one_of_models = self.nullable_one_of_models + + model = self.model.to_dict() + + nullable_model: Union[None, dict[str, Any]] + if isinstance(self.nullable_model, ModelWithUnionProperty): + nullable_model = self.nullable_model.to_dict() + else: + nullable_model = self.nullable_model + + any_value = self.any_value + + an_optional_allof_enum: Union[Unset, str] = UNSET + if not isinstance(self.an_optional_allof_enum, Unset): + an_optional_allof_enum = self.an_optional_allof_enum.value + + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET + if not isinstance(self.nested_list_of_enums, Unset): + nested_list_of_enums = [] + for nested_list_of_enums_item_data in self.nested_list_of_enums: + nested_list_of_enums_item = [] + for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: + nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value + nested_list_of_enums_item.append(nested_list_of_enums_item_item) + + nested_list_of_enums.append(nested_list_of_enums_item) + + a_not_required_date: Union[Unset, str] = UNSET + if not isinstance(self.a_not_required_date, Unset): + a_not_required_date = self.a_not_required_date.isoformat() + + a_not_required_uuid: Union[Unset, str] = UNSET + if not isinstance(self.a_not_required_uuid, Unset): + a_not_required_uuid = str(self.a_not_required_uuid) + + attr_1_leading_digit = self.attr_1_leading_digit + + attr_leading_underscore = self.attr_leading_underscore + + not_required_nullable: Union[None, Unset, str] + if isinstance(self.not_required_nullable, Unset): + not_required_nullable = UNSET + else: + not_required_nullable = self.not_required_nullable + + not_required_not_nullable = self.not_required_not_nullable + + not_required_one_of_models: Union[Unset, dict[str, Any]] + if isinstance(self.not_required_one_of_models, Unset): + not_required_one_of_models = UNSET + elif isinstance(self.not_required_one_of_models, FreeFormModel): + not_required_one_of_models = self.not_required_one_of_models.to_dict() + else: + not_required_one_of_models = self.not_required_one_of_models.to_dict() + + not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] + if isinstance(self.not_required_nullable_one_of_models, Unset): + not_required_nullable_one_of_models = UNSET + elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + else: + not_required_nullable_one_of_models = self.not_required_nullable_one_of_models + + not_required_model: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.not_required_model, Unset): + not_required_model = self.not_required_model.to_dict() + + not_required_nullable_model: Union[None, Unset, dict[str, Any]] + if isinstance(self.not_required_nullable_model, Unset): + not_required_nullable_model = UNSET + elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): + not_required_nullable_model = self.not_required_nullable_model.to_dict() + else: + not_required_nullable_model = self.not_required_nullable_model + + from_extended = self.from_extended + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "an_enum_value": an_enum_value, + "an_allof_enum_with_overridden_default": an_allof_enum_with_overridden_default, + "aCamelDateTime": a_camel_date_time, + "a_date": a_date, + "a_nullable_date": a_nullable_date, + "a_uuid": a_uuid, + "a_nullable_uuid": a_nullable_uuid, + "required_nullable": required_nullable, + "required_not_nullable": required_not_nullable, + "one_of_models": one_of_models, + "nullable_one_of_models": nullable_one_of_models, + "model": model, + "nullable_model": nullable_model, + } + ) + if any_value is not UNSET: + field_dict["any_value"] = any_value + if an_optional_allof_enum is not UNSET: + field_dict["an_optional_allof_enum"] = an_optional_allof_enum + if nested_list_of_enums is not UNSET: + field_dict["nested_list_of_enums"] = nested_list_of_enums + if a_not_required_date is not UNSET: + field_dict["a_not_required_date"] = a_not_required_date + if a_not_required_uuid is not UNSET: + field_dict["a_not_required_uuid"] = a_not_required_uuid + if attr_1_leading_digit is not UNSET: + field_dict["1_leading_digit"] = attr_1_leading_digit + if attr_leading_underscore is not UNSET: + field_dict["_leading_underscore"] = attr_leading_underscore + if not_required_nullable is not UNSET: + field_dict["not_required_nullable"] = not_required_nullable + if not_required_not_nullable is not UNSET: + field_dict["not_required_not_nullable"] = not_required_not_nullable + if not_required_one_of_models is not UNSET: + field_dict["not_required_one_of_models"] = not_required_one_of_models + if not_required_nullable_one_of_models is not UNSET: + field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models + if not_required_model is not UNSET: + field_dict["not_required_model"] = not_required_model + if not_required_nullable_model is not UNSET: + field_dict["not_required_nullable_model"] = not_required_nullable_model + if from_extended is not UNSET: + field_dict["fromExtended"] = from_extended + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.free_form_model import FreeFormModel + from ..models.model_with_union_property import ModelWithUnionProperty + + d = src_dict.copy() + an_enum_value = AnEnum(d.pop("an_enum_value")) + + an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) + + def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: + try: + if not isinstance(data, str): + raise TypeError() + a_camel_date_time_type_0 = isoparse(data) + + return a_camel_date_time_type_0 + except: # noqa: E722 + pass + if not isinstance(data, str): + raise TypeError() + a_camel_date_time_type_1 = isoparse(data).date() + + return a_camel_date_time_type_1 + + a_camel_date_time = _parse_a_camel_date_time(d.pop("aCamelDateTime")) + + a_date = isoparse(d.pop("a_date")).date() + + def _parse_a_nullable_date(data: object) -> Union[None, datetime.date]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + a_nullable_date_type_0 = isoparse(data).date() + + return a_nullable_date_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.date], data) + + a_nullable_date = _parse_a_nullable_date(d.pop("a_nullable_date")) + + a_uuid = UUID(d.pop("a_uuid")) + + def _parse_a_nullable_uuid(data: object) -> Union[None, UUID]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + a_nullable_uuid_type_0 = UUID(data) + + return a_nullable_uuid_type_0 + except: # noqa: E722 + pass + return cast(Union[None, UUID], data) + + a_nullable_uuid = _parse_a_nullable_uuid(d.pop("a_nullable_uuid")) + + def _parse_required_nullable(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + required_nullable = _parse_required_nullable(d.pop("required_nullable")) + + required_not_nullable = d.pop("required_not_nullable") + + def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: + try: + if not isinstance(data, dict): + raise TypeError() + one_of_models_type_0 = FreeFormModel.from_dict(data) + + return one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", Any], data) + + one_of_models = _parse_one_of_models(d.pop("one_of_models")) + + def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return nullable_one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return nullable_one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) + + nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) + + model = ModelWithUnionProperty.from_dict(d.pop("model")) + + def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + + return nullable_model_type_1 + except: # noqa: E722 + pass + return cast(Union["ModelWithUnionProperty", None], data) + + nullable_model = _parse_nullable_model(d.pop("nullable_model")) + + any_value = d.pop("any_value", UNSET) + + _an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET) + an_optional_allof_enum: Union[Unset, AnAllOfEnum] + if isinstance(_an_optional_allof_enum, Unset): + an_optional_allof_enum = UNSET + else: + an_optional_allof_enum = AnAllOfEnum(_an_optional_allof_enum) + + nested_list_of_enums = [] + _nested_list_of_enums = d.pop("nested_list_of_enums", UNSET) + for nested_list_of_enums_item_data in _nested_list_of_enums or []: + nested_list_of_enums_item = [] + _nested_list_of_enums_item = nested_list_of_enums_item_data + for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: + nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) + + nested_list_of_enums_item.append(nested_list_of_enums_item_item) + + nested_list_of_enums.append(nested_list_of_enums_item) + + _a_not_required_date = d.pop("a_not_required_date", UNSET) + a_not_required_date: Union[Unset, datetime.date] + if isinstance(_a_not_required_date, Unset): + a_not_required_date = UNSET + else: + a_not_required_date = isoparse(_a_not_required_date).date() + + _a_not_required_uuid = d.pop("a_not_required_uuid", UNSET) + a_not_required_uuid: Union[Unset, UUID] + if isinstance(_a_not_required_uuid, Unset): + a_not_required_uuid = UNSET + else: + a_not_required_uuid = UUID(_a_not_required_uuid) + + attr_1_leading_digit = d.pop("1_leading_digit", UNSET) + + attr_leading_underscore = d.pop("_leading_underscore", UNSET) + + def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) + + not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) + + def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return not_required_one_of_models_type_0 + except: # noqa: E722 + pass + if not isinstance(data, dict): + raise TypeError() + not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_one_of_models_type_1 + + not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) + + def _parse_not_required_nullable_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + + return not_required_nullable_one_of_models_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_nullable_one_of_models_type_1 + except: # noqa: E722 + pass + return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) + + not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( + d.pop("not_required_nullable_one_of_models", UNSET) + ) + + _not_required_model = d.pop("not_required_model", UNSET) + not_required_model: Union[Unset, ModelWithUnionProperty] + if isinstance(_not_required_model, Unset): + not_required_model = UNSET + else: + not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) + + def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + + return not_required_nullable_model_type_1 + except: # noqa: E722 + pass + return cast(Union["ModelWithUnionProperty", None, Unset], data) + + not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) + + from_extended = d.pop("fromExtended", UNSET) + + extended = cls( + an_enum_value=an_enum_value, + an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, + a_camel_date_time=a_camel_date_time, + a_date=a_date, + a_nullable_date=a_nullable_date, + a_uuid=a_uuid, + a_nullable_uuid=a_nullable_uuid, + required_nullable=required_nullable, + required_not_nullable=required_not_nullable, + one_of_models=one_of_models, + nullable_one_of_models=nullable_one_of_models, + model=model, + nullable_model=nullable_model, + any_value=any_value, + an_optional_allof_enum=an_optional_allof_enum, + nested_list_of_enums=nested_list_of_enums, + a_not_required_date=a_not_required_date, + a_not_required_uuid=a_not_required_uuid, + attr_1_leading_digit=attr_1_leading_digit, + attr_leading_underscore=attr_leading_underscore, + not_required_nullable=not_required_nullable, + not_required_not_nullable=not_required_not_nullable, + not_required_one_of_models=not_required_one_of_models, + not_required_nullable_one_of_models=not_required_nullable_one_of_models, + not_required_model=not_required_model, + not_required_nullable_model=not_required_nullable_model, + from_extended=from_extended, + ) + + extended.additional_properties = d + return extended + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py new file mode 100644 index 000000000..02b85bb19 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FreeFormModel") + + +@_attrs_define +class FreeFormModel: + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + free_form_model = cls() + + free_form_model.additional_properties = d + return free_form_model + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py new file mode 100644 index 000000000..d3c23f16b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py @@ -0,0 +1,10 @@ +from enum import IntEnum + + +class GetLocationHeaderTypesIntEnumHeader(IntEnum): + VALUE_1 = 1 + VALUE_2 = 2 + VALUE_3 = 3 + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py new file mode 100644 index 000000000..cce92dcde --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class GetLocationHeaderTypesStringEnumHeader(str, Enum): + ONE = "one" + THREE = "three" + TWO = "two" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py new file mode 100644 index 000000000..a3793ec9a --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py @@ -0,0 +1,100 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.a_model import AModel + from ..models.extended import Extended + + +T = TypeVar("T", bound="GetModelsAllofResponse200") + + +@_attrs_define +class GetModelsAllofResponse200: + aliased: Union[Unset, "AModel"] = UNSET + """ A Model for testing all the ways custom objects can be used """ + extended: Union[Unset, "Extended"] = UNSET + model: Union[Unset, "AModel"] = UNSET + """ A Model for testing all the ways custom objects can be used """ + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + aliased: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.aliased, Unset): + aliased = self.aliased.to_dict() + + extended: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.extended, Unset): + extended = self.extended.to_dict() + + model: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.model, Unset): + model = self.model.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if aliased is not UNSET: + field_dict["aliased"] = aliased + if extended is not UNSET: + field_dict["extended"] = extended + if model is not UNSET: + field_dict["model"] = model + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.a_model import AModel + from ..models.extended import Extended + + d = src_dict.copy() + _aliased = d.pop("aliased", UNSET) + aliased: Union[Unset, AModel] + if isinstance(_aliased, Unset): + aliased = UNSET + else: + aliased = AModel.from_dict(_aliased) + + _extended = d.pop("extended", UNSET) + extended: Union[Unset, Extended] + if isinstance(_extended, Unset): + extended = UNSET + else: + extended = Extended.from_dict(_extended) + + _model = d.pop("model", UNSET) + model: Union[Unset, AModel] + if isinstance(_model, Unset): + model = UNSET + else: + model = AModel.from_dict(_model) + + get_models_allof_response_200 = cls( + aliased=aliased, + extended=extended, + model=model, + ) + + get_models_allof_response_200.additional_properties = d + return get_models_allof_response_200 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py new file mode 100644 index 000000000..ed3a89e3b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py @@ -0,0 +1,65 @@ +from typing import Any, Literal, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="GetModelsOneofWithRequiredConstResponse200Type0") + + +@_attrs_define +class GetModelsOneofWithRequiredConstResponse200Type0: + type_: Literal["alpha"] + color: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + type_ = self.type_ + + color = self.color + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "type": type_, + } + ) + if color is not UNSET: + field_dict["color"] = color + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + type_ = cast(Literal["alpha"], d.pop("type")) + if type_ != "alpha": + raise ValueError(f"type must match const 'alpha', got '{type_}'") + + color = d.pop("color", UNSET) + + get_models_oneof_with_required_const_response_200_type_0 = cls( + type_=type_, + color=color, + ) + + get_models_oneof_with_required_const_response_200_type_0.additional_properties = d + return get_models_oneof_with_required_const_response_200_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py new file mode 100644 index 000000000..7d96cc6bf --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py @@ -0,0 +1,65 @@ +from typing import Any, Literal, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="GetModelsOneofWithRequiredConstResponse200Type1") + + +@_attrs_define +class GetModelsOneofWithRequiredConstResponse200Type1: + type_: Literal["beta"] + texture: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + type_ = self.type_ + + texture = self.texture + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "type": type_, + } + ) + if texture is not UNSET: + field_dict["texture"] = texture + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + type_ = cast(Literal["beta"], d.pop("type")) + if type_ != "beta": + raise ValueError(f"type must match const 'beta', got '{type_}'") + + texture = d.pop("texture", UNSET) + + get_models_oneof_with_required_const_response_200_type_1 = cls( + type_=type_, + texture=texture, + ) + + get_models_oneof_with_required_const_response_200_type_1.additional_properties = d + return get_models_oneof_with_required_const_response_200_type_1 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py new file mode 100644 index 000000000..97476a53d --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py @@ -0,0 +1,49 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.validation_error import ValidationError + + +T = TypeVar("T", bound="HTTPValidationError") + + +@_attrs_define +class HTTPValidationError: + detail: Union[Unset, list["ValidationError"]] = UNSET + + def to_dict(self) -> dict[str, Any]: + detail: Union[Unset, list[dict[str, Any]]] = UNSET + if not isinstance(self.detail, Unset): + detail = [] + for detail_item_data in self.detail: + detail_item = detail_item_data.to_dict() + detail.append(detail_item) + + field_dict: dict[str, Any] = {} + field_dict.update({}) + if detail is not UNSET: + field_dict["detail"] = detail + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.validation_error import ValidationError + + d = src_dict.copy() + detail = [] + _detail = d.pop("detail", UNSET) + for detail_item_data in _detail or []: + detail_item = ValidationError.from_dict(detail_item_data) + + detail.append(detail_item) + + http_validation_error = cls( + detail=detail, + ) + + return http_validation_error diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py new file mode 100644 index 000000000..84c8d9798 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="Import") + + +@_attrs_define +class Import: + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + import_ = cls() + + import_.additional_properties = d + return import_ + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py new file mode 100644 index 000000000..9b1ac6d7e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="JsonLikeBody") + + +@_attrs_define +class JsonLikeBody: + a: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a = self.a + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a is not UNSET: + field_dict["a"] = a + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a = d.pop("a", UNSET) + + json_like_body = cls( + a=a, + ) + + json_like_body.additional_properties = d + return json_like_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py new file mode 100644 index 000000000..1fdf2f20d --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py @@ -0,0 +1,61 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MixedCaseResponse200") + + +@_attrs_define +class MixedCaseResponse200: + mixed_case: Union[Unset, str] = UNSET + mixedCase: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + mixed_case = self.mixed_case + + mixedCase = self.mixedCase + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if mixed_case is not UNSET: + field_dict["mixed_case"] = mixed_case + if mixedCase is not UNSET: + field_dict["mixedCase"] = mixedCase + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + mixed_case = d.pop("mixed_case", UNSET) + + mixedCase = d.pop("mixedCase", UNSET) + + mixed_case_response_200 = cls( + mixed_case=mixed_case, + mixedCase=mixedCase, + ) + + mixed_case_response_200.additional_properties = d + return mixed_case_response_200 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py new file mode 100644 index 000000000..1ef05db69 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py @@ -0,0 +1,93 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.another_all_of_sub_model_type import AnotherAllOfSubModelType +from ..models.another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelFromAllOf") + + +@_attrs_define +class ModelFromAllOf: + a_sub_property: Union[Unset, str] = UNSET + type_: Union[Unset, AnotherAllOfSubModelType] = UNSET + type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET + another_sub_property: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a_sub_property = self.a_sub_property + + type_: Union[Unset, str] = UNSET + if not isinstance(self.type_, Unset): + type_ = self.type_.value + + type_enum: Union[Unset, int] = UNSET + if not isinstance(self.type_enum, Unset): + type_enum = self.type_enum.value + + another_sub_property = self.another_sub_property + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a_sub_property is not UNSET: + field_dict["a_sub_property"] = a_sub_property + if type_ is not UNSET: + field_dict["type"] = type_ + if type_enum is not UNSET: + field_dict["type_enum"] = type_enum + if another_sub_property is not UNSET: + field_dict["another_sub_property"] = another_sub_property + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_sub_property = d.pop("a_sub_property", UNSET) + + _type_ = d.pop("type", UNSET) + type_: Union[Unset, AnotherAllOfSubModelType] + if isinstance(_type_, Unset): + type_ = UNSET + else: + type_ = AnotherAllOfSubModelType(_type_) + + _type_enum = d.pop("type_enum", UNSET) + type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] + if isinstance(_type_enum, Unset): + type_enum = UNSET + else: + type_enum = AnotherAllOfSubModelTypeEnum(_type_enum) + + another_sub_property = d.pop("another_sub_property", UNSET) + + model_from_all_of = cls( + a_sub_property=a_sub_property, + type_=type_, + type_enum=type_enum, + another_sub_property=another_sub_property, + ) + + model_from_all_of.additional_properties = d + return model_from_all_of + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py new file mode 100644 index 000000000..aec25aa25 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelName") + + +@_attrs_define +class ModelName: + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_name = cls() + + model_name.additional_properties = d + return model_name + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py new file mode 100644 index 000000000..004ed9b20 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py @@ -0,0 +1,43 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelReferenceWithPeriods") + + +@_attrs_define +class ModelReferenceWithPeriods: + """A Model with periods in its reference""" + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_reference_with_periods = cls() + + model_reference_with_periods.additional_properties = d + return model_reference_with_periods + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py new file mode 100644 index 000000000..21e5d5b62 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py @@ -0,0 +1,72 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_with_additional_properties_inlined_additional_property import ( + ModelWithAdditionalPropertiesInlinedAdditionalProperty, + ) + + +T = TypeVar("T", bound="ModelWithAdditionalPropertiesInlined") + + +@_attrs_define +class ModelWithAdditionalPropertiesInlined: + a_number: Union[Unset, float] = UNSET + additional_properties: dict[str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty"] = _attrs_field( + init=False, factory=dict + ) + + def to_dict(self) -> dict[str, Any]: + a_number = self.a_number + + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.to_dict() + field_dict.update({}) + if a_number is not UNSET: + field_dict["a_number"] = a_number + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_additional_properties_inlined_additional_property import ( + ModelWithAdditionalPropertiesInlinedAdditionalProperty, + ) + + d = src_dict.copy() + a_number = d.pop("a_number", UNSET) + + model_with_additional_properties_inlined = cls( + a_number=a_number, + ) + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_additional_properties_inlined.additional_properties = additional_properties + return model_with_additional_properties_inlined + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "ModelWithAdditionalPropertiesInlinedAdditionalProperty": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "ModelWithAdditionalPropertiesInlinedAdditionalProperty") -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py new file mode 100644 index 000000000..08d29f18f --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithAdditionalPropertiesInlinedAdditionalProperty") + + +@_attrs_define +class ModelWithAdditionalPropertiesInlinedAdditionalProperty: + extra_props_prop: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + extra_props_prop = self.extra_props_prop + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if extra_props_prop is not UNSET: + field_dict["extra_props_prop"] = extra_props_prop + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + extra_props_prop = d.pop("extra_props_prop", UNSET) + + model_with_additional_properties_inlined_additional_property = cls( + extra_props_prop=extra_props_prop, + ) + + model_with_additional_properties_inlined_additional_property.additional_properties = d + return model_with_additional_properties_inlined_additional_property + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py new file mode 100644 index 000000000..e2d2b37c1 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py @@ -0,0 +1,50 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.an_enum import AnEnum + +T = TypeVar("T", bound="ModelWithAdditionalPropertiesRefed") + + +@_attrs_define +class ModelWithAdditionalPropertiesRefed: + additional_properties: dict[str, AnEnum] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.value + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_with_additional_properties_refed = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = AnEnum(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_additional_properties_refed.additional_properties = additional_properties + return model_with_additional_properties_refed + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> AnEnum: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: AnEnum) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py new file mode 100644 index 000000000..eef2dccad --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py @@ -0,0 +1,100 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.model_with_any_json_properties_additional_property_type_0 import ( + ModelWithAnyJsonPropertiesAdditionalPropertyType0, + ) + + +T = TypeVar("T", bound="ModelWithAnyJsonProperties") + + +@_attrs_define +class ModelWithAnyJsonProperties: + additional_properties: dict[ + str, Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str] + ] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.model_with_any_json_properties_additional_property_type_0 import ( + ModelWithAnyJsonPropertiesAdditionalPropertyType0, + ) + + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + if isinstance(prop, ModelWithAnyJsonPropertiesAdditionalPropertyType0): + field_dict[prop_name] = prop.to_dict() + elif isinstance(prop, list): + field_dict[prop_name] = prop + + else: + field_dict[prop_name] = prop + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_any_json_properties_additional_property_type_0 import ( + ModelWithAnyJsonPropertiesAdditionalPropertyType0, + ) + + d = src_dict.copy() + model_with_any_json_properties = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + + def _parse_additional_property( + data: object, + ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: + try: + if not isinstance(data, dict): + raise TypeError() + additional_property_type_0 = ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict(data) + + return additional_property_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, list): + raise TypeError() + additional_property_type_1 = cast(list[str], data) + + return additional_property_type_1 + except: # noqa: E722 + pass + return cast( + Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], data + ) + + additional_property = _parse_additional_property(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_any_json_properties.additional_properties = additional_properties + return model_with_any_json_properties + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__( + self, key: str + ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: + return self.additional_properties[key] + + def __setitem__( + self, + key: str, + value: Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], + ) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py new file mode 100644 index 000000000..ecd9b4e57 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelWithAnyJsonPropertiesAdditionalPropertyType0") + + +@_attrs_define +class ModelWithAnyJsonPropertiesAdditionalPropertyType0: + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_with_any_json_properties_additional_property_type_0 = cls() + + model_with_any_json_properties_additional_property_type_0.additional_properties = d + return model_with_any_json_properties_additional_property_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py new file mode 100644 index 000000000..0b5dfc3b5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py @@ -0,0 +1,45 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelWithBackslashInDescription") + + +@_attrs_define +class ModelWithBackslashInDescription: + r""" Description with special character: \ + + """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_with_backslash_in_description = cls() + + model_with_backslash_in_description.additional_properties = d + return model_with_backslash_in_description + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py new file mode 100644 index 000000000..2df72cc86 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py @@ -0,0 +1,66 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_with_circular_ref_b import ModelWithCircularRefB + + +T = TypeVar("T", bound="ModelWithCircularRefA") + + +@_attrs_define +class ModelWithCircularRefA: + circular: Union[Unset, "ModelWithCircularRefB"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.circular, Unset): + circular = self.circular.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if circular is not UNSET: + field_dict["circular"] = circular + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_circular_ref_b import ModelWithCircularRefB + + d = src_dict.copy() + _circular = d.pop("circular", UNSET) + circular: Union[Unset, ModelWithCircularRefB] + if isinstance(_circular, Unset): + circular = UNSET + else: + circular = ModelWithCircularRefB.from_dict(_circular) + + model_with_circular_ref_a = cls( + circular=circular, + ) + + model_with_circular_ref_a.additional_properties = d + return model_with_circular_ref_a + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py new file mode 100644 index 000000000..789da806e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py @@ -0,0 +1,66 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_with_circular_ref_a import ModelWithCircularRefA + + +T = TypeVar("T", bound="ModelWithCircularRefB") + + +@_attrs_define +class ModelWithCircularRefB: + circular: Union[Unset, "ModelWithCircularRefA"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.circular, Unset): + circular = self.circular.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if circular is not UNSET: + field_dict["circular"] = circular + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_circular_ref_a import ModelWithCircularRefA + + d = src_dict.copy() + _circular = d.pop("circular", UNSET) + circular: Union[Unset, ModelWithCircularRefA] + if isinstance(_circular, Unset): + circular = UNSET + else: + circular = ModelWithCircularRefA.from_dict(_circular) + + model_with_circular_ref_b = cls( + circular=circular, + ) + + model_with_circular_ref_b.additional_properties = d + return model_with_circular_ref_b + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py new file mode 100644 index 000000000..5b7755a22 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py @@ -0,0 +1,58 @@ +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB + + +T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesA") + + +@_attrs_define +class ModelWithCircularRefInAdditionalPropertiesA: + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = _attrs_field( + init=False, factory=dict + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_circular_ref_in_additional_properties_b import ( + ModelWithCircularRefInAdditionalPropertiesB, + ) + + d = src_dict.copy() + model_with_circular_ref_in_additional_properties_a = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = ModelWithCircularRefInAdditionalPropertiesB.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_circular_ref_in_additional_properties_a.additional_properties = additional_properties + return model_with_circular_ref_in_additional_properties_a + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesB": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesB") -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py new file mode 100644 index 000000000..906794ccf --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py @@ -0,0 +1,58 @@ +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA + + +T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesB") + + +@_attrs_define +class ModelWithCircularRefInAdditionalPropertiesB: + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = _attrs_field( + init=False, factory=dict + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_circular_ref_in_additional_properties_a import ( + ModelWithCircularRefInAdditionalPropertiesA, + ) + + d = src_dict.copy() + model_with_circular_ref_in_additional_properties_b = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = ModelWithCircularRefInAdditionalPropertiesA.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_circular_ref_in_additional_properties_b.additional_properties = additional_properties + return model_with_circular_ref_in_additional_properties_b + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesA": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesA") -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py new file mode 100644 index 000000000..d39dd2879 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py @@ -0,0 +1,62 @@ +import datetime +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithDateTimeProperty") + + +@_attrs_define +class ModelWithDateTimeProperty: + datetime_: Union[Unset, datetime.datetime] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + datetime_: Union[Unset, str] = UNSET + if not isinstance(self.datetime_, Unset): + datetime_ = self.datetime_.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if datetime_ is not UNSET: + field_dict["datetime"] = datetime_ + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + _datetime_ = d.pop("datetime", UNSET) + datetime_: Union[Unset, datetime.datetime] + if isinstance(_datetime_, Unset): + datetime_ = UNSET + else: + datetime_ = isoparse(_datetime_) + + model_with_date_time_property = cls( + datetime_=datetime_, + ) + + model_with_date_time_property.additional_properties = d + return model_with_date_time_property + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py new file mode 100644 index 000000000..709b0a045 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py @@ -0,0 +1,98 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 + from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 + + +T = TypeVar("T", bound="ModelWithDiscriminatedUnion") + + +@_attrs_define +class ModelWithDiscriminatedUnion: + discriminated_union: Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 + from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 + + discriminated_union: Union[None, Unset, dict[str, Any]] + if isinstance(self.discriminated_union, Unset): + discriminated_union = UNSET + elif isinstance(self.discriminated_union, ADiscriminatedUnionType1): + discriminated_union = self.discriminated_union.to_dict() + elif isinstance(self.discriminated_union, ADiscriminatedUnionType2): + discriminated_union = self.discriminated_union.to_dict() + else: + discriminated_union = self.discriminated_union + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if discriminated_union is not UNSET: + field_dict["discriminated_union"] = discriminated_union + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 + from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 + + d = src_dict.copy() + + def _parse_discriminated_union( + data: object, + ) -> Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + componentsschemas_a_discriminated_union_type_0 = ADiscriminatedUnionType1.from_dict(data) + + return componentsschemas_a_discriminated_union_type_0 + except: # noqa: E722 + pass + try: + if not isinstance(data, dict): + raise TypeError() + componentsschemas_a_discriminated_union_type_1 = ADiscriminatedUnionType2.from_dict(data) + + return componentsschemas_a_discriminated_union_type_1 + except: # noqa: E722 + pass + return cast(Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset], data) + + discriminated_union = _parse_discriminated_union(d.pop("discriminated_union", UNSET)) + + model_with_discriminated_union = cls( + discriminated_union=discriminated_union, + ) + + model_with_discriminated_union.additional_properties = d + return model_with_discriminated_union + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py new file mode 100644 index 000000000..40e5c8f38 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py @@ -0,0 +1,103 @@ +import datetime +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithMergedProperties") + + +@_attrs_define +class ModelWithMergedProperties: + simple_string: Union[Unset, str] = "new default" + """ extended simpleString description """ + string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] = ModelWithMergedPropertiesStringToEnum.A + string_to_date: Union[Unset, datetime.date] = UNSET + number_to_int: Union[Unset, int] = UNSET + any_to_string: Union[Unset, str] = "x" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + simple_string = self.simple_string + + string_to_enum: Union[Unset, str] = UNSET + if not isinstance(self.string_to_enum, Unset): + string_to_enum = self.string_to_enum.value + + string_to_date: Union[Unset, str] = UNSET + if not isinstance(self.string_to_date, Unset): + string_to_date = self.string_to_date.isoformat() + + number_to_int = self.number_to_int + + any_to_string = self.any_to_string + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if simple_string is not UNSET: + field_dict["simpleString"] = simple_string + if string_to_enum is not UNSET: + field_dict["stringToEnum"] = string_to_enum + if string_to_date is not UNSET: + field_dict["stringToDate"] = string_to_date + if number_to_int is not UNSET: + field_dict["numberToInt"] = number_to_int + if any_to_string is not UNSET: + field_dict["anyToString"] = any_to_string + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + simple_string = d.pop("simpleString", UNSET) + + _string_to_enum = d.pop("stringToEnum", UNSET) + string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] + if isinstance(_string_to_enum, Unset): + string_to_enum = UNSET + else: + string_to_enum = ModelWithMergedPropertiesStringToEnum(_string_to_enum) + + _string_to_date = d.pop("stringToDate", UNSET) + string_to_date: Union[Unset, datetime.date] + if isinstance(_string_to_date, Unset): + string_to_date = UNSET + else: + string_to_date = isoparse(_string_to_date).date() + + number_to_int = d.pop("numberToInt", UNSET) + + any_to_string = d.pop("anyToString", UNSET) + + model_with_merged_properties = cls( + simple_string=simple_string, + string_to_enum=string_to_enum, + string_to_date=string_to_date, + number_to_int=number_to_int, + any_to_string=any_to_string, + ) + + model_with_merged_properties.additional_properties = d + return model_with_merged_properties + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py new file mode 100644 index 000000000..5e146c5eb --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class ModelWithMergedPropertiesStringToEnum(str, Enum): + A = "a" + B = "b" + + def __str__(self) -> str: + return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py new file mode 100644 index 000000000..a1261f931 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py @@ -0,0 +1,19 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="ModelWithNoProperties") + + +@_attrs_define +class ModelWithNoProperties: + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + model_with_no_properties = cls() + + return model_with_no_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py new file mode 100644 index 000000000..5410886e4 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py @@ -0,0 +1,70 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_with_primitive_additional_properties_a_date_holder import ( + ModelWithPrimitiveAdditionalPropertiesADateHolder, + ) + + +T = TypeVar("T", bound="ModelWithPrimitiveAdditionalProperties") + + +@_attrs_define +class ModelWithPrimitiveAdditionalProperties: + a_date_holder: Union[Unset, "ModelWithPrimitiveAdditionalPropertiesADateHolder"] = UNSET + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a_date_holder: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.a_date_holder, Unset): + a_date_holder = self.a_date_holder.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a_date_holder is not UNSET: + field_dict["a_date_holder"] = a_date_holder + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_primitive_additional_properties_a_date_holder import ( + ModelWithPrimitiveAdditionalPropertiesADateHolder, + ) + + d = src_dict.copy() + _a_date_holder = d.pop("a_date_holder", UNSET) + a_date_holder: Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder] + if isinstance(_a_date_holder, Unset): + a_date_holder = UNSET + else: + a_date_holder = ModelWithPrimitiveAdditionalPropertiesADateHolder.from_dict(_a_date_holder) + + model_with_primitive_additional_properties = cls( + a_date_holder=a_date_holder, + ) + + model_with_primitive_additional_properties.additional_properties = d + return model_with_primitive_additional_properties + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py new file mode 100644 index 000000000..cc322bcfd --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py @@ -0,0 +1,50 @@ +import datetime +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="ModelWithPrimitiveAdditionalPropertiesADateHolder") + + +@_attrs_define +class ModelWithPrimitiveAdditionalPropertiesADateHolder: + additional_properties: dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.isoformat() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_with_primitive_additional_properties_a_date_holder = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = isoparse(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_primitive_additional_properties_a_date_holder.additional_properties = additional_properties + return model_with_primitive_additional_properties_a_date_holder + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> datetime.datetime: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: datetime.datetime) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py new file mode 100644 index 000000000..d82d0d7eb --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py @@ -0,0 +1,66 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_name import ModelName + + +T = TypeVar("T", bound="ModelWithPropertyRef") + + +@_attrs_define +class ModelWithPropertyRef: + inner: Union[Unset, "ModelName"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + inner: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.inner, Unset): + inner = self.inner.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if inner is not UNSET: + field_dict["inner"] = inner + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_name import ModelName + + d = src_dict.copy() + _inner = d.pop("inner", UNSET) + inner: Union[Unset, ModelName] + if isinstance(_inner, Unset): + inner = UNSET + else: + inner = ModelName.from_dict(_inner) + + model_with_property_ref = cls( + inner=inner, + ) + + model_with_property_ref.additional_properties = d + return model_with_property_ref + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py new file mode 100644 index 000000000..b97c8c68b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py @@ -0,0 +1,60 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithRecursiveRef") + + +@_attrs_define +class ModelWithRecursiveRef: + recursive: Union[Unset, "ModelWithRecursiveRef"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + recursive: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.recursive, Unset): + recursive = self.recursive.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if recursive is not UNSET: + field_dict["recursive"] = recursive + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + _recursive = d.pop("recursive", UNSET) + recursive: Union[Unset, ModelWithRecursiveRef] + if isinstance(_recursive, Unset): + recursive = UNSET + else: + recursive = ModelWithRecursiveRef.from_dict(_recursive) + + model_with_recursive_ref = cls( + recursive=recursive, + ) + + model_with_recursive_ref.additional_properties = d + return model_with_recursive_ref + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py new file mode 100644 index 000000000..15bf5c7ba --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py @@ -0,0 +1,50 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelWithRecursiveRefInAdditionalProperties") + + +@_attrs_define +class ModelWithRecursiveRefInAdditionalProperties: + additional_properties: dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = _attrs_field( + init=False, factory=dict + ) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + model_with_recursive_ref_in_additional_properties = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = ModelWithRecursiveRefInAdditionalProperties.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + model_with_recursive_ref_in_additional_properties.additional_properties = additional_properties + return model_with_recursive_ref_in_additional_properties + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "ModelWithRecursiveRefInAdditionalProperties": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "ModelWithRecursiveRefInAdditionalProperties") -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py new file mode 100644 index 000000000..25c5a6d01 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py @@ -0,0 +1,59 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define + +from ..models.an_enum import AnEnum +from ..models.an_int_enum import AnIntEnum +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithUnionProperty") + + +@_attrs_define +class ModelWithUnionProperty: + a_property: Union[AnEnum, AnIntEnum, Unset] = UNSET + + def to_dict(self) -> dict[str, Any]: + a_property: Union[Unset, int, str] + if isinstance(self.a_property, Unset): + a_property = UNSET + elif isinstance(self.a_property, AnEnum): + a_property = self.a_property.value + else: + a_property = self.a_property.value + + field_dict: dict[str, Any] = {} + field_dict.update({}) + if a_property is not UNSET: + field_dict["a_property"] = a_property + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + + def _parse_a_property(data: object) -> Union[AnEnum, AnIntEnum, Unset]: + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + a_property_type_0 = AnEnum(data) + + return a_property_type_0 + except: # noqa: E722 + pass + if not isinstance(data, int): + raise TypeError() + a_property_type_1 = AnIntEnum(data) + + return a_property_type_1 + + a_property = _parse_a_property(d.pop("a_property", UNSET)) + + model_with_union_property = cls( + a_property=a_property, + ) + + return model_with_union_property diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py new file mode 100644 index 000000000..466c64e76 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py @@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 + from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 + + +T = TypeVar("T", bound="ModelWithUnionPropertyInlined") + + +@_attrs_define +class ModelWithUnionPropertyInlined: + fruit: Union["ModelWithUnionPropertyInlinedFruitType0", "ModelWithUnionPropertyInlinedFruitType1", Unset] = UNSET + + def to_dict(self) -> dict[str, Any]: + from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 + + fruit: Union[Unset, dict[str, Any]] + if isinstance(self.fruit, Unset): + fruit = UNSET + elif isinstance(self.fruit, ModelWithUnionPropertyInlinedFruitType0): + fruit = self.fruit.to_dict() + else: + fruit = self.fruit.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update({}) + if fruit is not UNSET: + field_dict["fruit"] = fruit + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 + from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 + + d = src_dict.copy() + + def _parse_fruit( + data: object, + ) -> Union["ModelWithUnionPropertyInlinedFruitType0", "ModelWithUnionPropertyInlinedFruitType1", Unset]: + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + fruit_type_0 = ModelWithUnionPropertyInlinedFruitType0.from_dict(data) + + return fruit_type_0 + except: # noqa: E722 + pass + if not isinstance(data, dict): + raise TypeError() + fruit_type_1 = ModelWithUnionPropertyInlinedFruitType1.from_dict(data) + + return fruit_type_1 + + fruit = _parse_fruit(d.pop("fruit", UNSET)) + + model_with_union_property_inlined = cls( + fruit=fruit, + ) + + return model_with_union_property_inlined diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py new file mode 100644 index 000000000..48b19e4bc --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithUnionPropertyInlinedFruitType0") + + +@_attrs_define +class ModelWithUnionPropertyInlinedFruitType0: + apples: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + apples = self.apples + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if apples is not UNSET: + field_dict["apples"] = apples + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + apples = d.pop("apples", UNSET) + + model_with_union_property_inlined_fruit_type_0 = cls( + apples=apples, + ) + + model_with_union_property_inlined_fruit_type_0.additional_properties = d + return model_with_union_property_inlined_fruit_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py new file mode 100644 index 000000000..e5f1f16f5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithUnionPropertyInlinedFruitType1") + + +@_attrs_define +class ModelWithUnionPropertyInlinedFruitType1: + bananas: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + bananas = self.bananas + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if bananas is not UNSET: + field_dict["bananas"] = bananas + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + bananas = d.pop("bananas", UNSET) + + model_with_union_property_inlined_fruit_type_1 = cls( + bananas=bananas, + ) + + model_with_union_property_inlined_fruit_type_1.additional_properties = d + return model_with_union_property_inlined_fruit_type_1 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py new file mode 100644 index 000000000..f17e0919b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="None_") + + +@_attrs_define +class None_: + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + none = cls() + + none.additional_properties = d + return none + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py new file mode 100644 index 000000000..b6a3b72c5 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostBodiesMultipleDataBody") + + +@_attrs_define +class PostBodiesMultipleDataBody: + a: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a = self.a + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a is not UNSET: + field_dict["a"] = a + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a = d.pop("a", UNSET) + + post_bodies_multiple_data_body = cls( + a=a, + ) + + post_bodies_multiple_data_body.additional_properties = d + return post_bodies_multiple_data_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py new file mode 100644 index 000000000..dea65306c --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py @@ -0,0 +1,66 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostBodiesMultipleFilesBody") + + +@_attrs_define +class PostBodiesMultipleFilesBody: + a: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a = self.a + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a is not UNSET: + field_dict["a"] = a + + return field_dict + + def to_multipart(self) -> dict[str, Any]: + a = self.a if isinstance(self.a, Unset) else (None, str(self.a).encode(), "text/plain") + + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = (None, str(prop).encode(), "text/plain") + + field_dict.update({}) + if a is not UNSET: + field_dict["a"] = a + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a = d.pop("a", UNSET) + + post_bodies_multiple_files_body = cls( + a=a, + ) + + post_bodies_multiple_files_body.additional_properties = d + return post_bodies_multiple_files_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py new file mode 100644 index 000000000..e764bec2e --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py @@ -0,0 +1,53 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostBodiesMultipleJsonBody") + + +@_attrs_define +class PostBodiesMultipleJsonBody: + a: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a = self.a + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if a is not UNSET: + field_dict["a"] = a + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a = d.pop("a", UNSET) + + post_bodies_multiple_json_body = cls( + a=a, + ) + + post_bodies_multiple_json_body.additional_properties = d + return post_bodies_multiple_json_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py new file mode 100644 index 000000000..c1abf6b6b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py @@ -0,0 +1,63 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostFormDataInlineBody") + + +@_attrs_define +class PostFormDataInlineBody: + a_required_field: str + an_optional_field: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + a_required_field = self.a_required_field + + an_optional_field = self.an_optional_field + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "a_required_field": a_required_field, + } + ) + if an_optional_field is not UNSET: + field_dict["an_optional_field"] = an_optional_field + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_required_field = d.pop("a_required_field") + + an_optional_field = d.pop("an_optional_field", UNSET) + + post_form_data_inline_body = cls( + a_required_field=a_required_field, + an_optional_field=an_optional_field, + ) + + post_form_data_inline_body.additional_properties = d + return post_form_data_inline_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py new file mode 100644 index 000000000..dadb2c9c2 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py @@ -0,0 +1,63 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostNamingPropertyConflictWithImportBody") + + +@_attrs_define +class PostNamingPropertyConflictWithImportBody: + field: Union[Unset, str] = UNSET + """ A python_name of field should not interfere with attrs field """ + define: Union[Unset, str] = UNSET + """ A python_name of define should not interfere with attrs define """ + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field = self.field + + define = self.define + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if field is not UNSET: + field_dict["Field"] = field + if define is not UNSET: + field_dict["Define"] = define + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + field = d.pop("Field", UNSET) + + define = d.pop("Define", UNSET) + + post_naming_property_conflict_with_import_body = cls( + field=field, + define=define, + ) + + post_naming_property_conflict_with_import_body.additional_properties = d + return post_naming_property_conflict_with_import_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py new file mode 100644 index 000000000..3fb02dd44 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py @@ -0,0 +1,63 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PostNamingPropertyConflictWithImportResponse200") + + +@_attrs_define +class PostNamingPropertyConflictWithImportResponse200: + field: Union[Unset, str] = UNSET + """ A python_name of field should not interfere with attrs field """ + define: Union[Unset, str] = UNSET + """ A python_name of define should not interfere with attrs define """ + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field = self.field + + define = self.define + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if field is not UNSET: + field_dict["Field"] = field + if define is not UNSET: + field_dict["Define"] = define + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + field = d.pop("Field", UNSET) + + define = d.pop("Define", UNSET) + + post_naming_property_conflict_with_import_response_200 = cls( + field=field, + define=define, + ) + + post_naming_property_conflict_with_import_response_200.additional_properties = d + return post_naming_property_conflict_with_import_response_200 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py new file mode 100644 index 000000000..1685d1471 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py @@ -0,0 +1,83 @@ +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, + ) + + +T = TypeVar("T", bound="PostResponsesUnionsSimpleBeforeComplexResponse200") + + +@_attrs_define +class PostResponsesUnionsSimpleBeforeComplexResponse200: + a: Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, + ) + + a: Union[dict[str, Any], str] + if isinstance(self.a, PostResponsesUnionsSimpleBeforeComplexResponse200AType1): + a = self.a.to_dict() + else: + a = self.a + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "a": a, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, + ) + + d = src_dict.copy() + + def _parse_a(data: object) -> Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str]: + try: + if not isinstance(data, dict): + raise TypeError() + a_type_1 = PostResponsesUnionsSimpleBeforeComplexResponse200AType1.from_dict(data) + + return a_type_1 + except: # noqa: E722 + pass + return cast(Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str], data) + + a = _parse_a(d.pop("a")) + + post_responses_unions_simple_before_complex_response_200 = cls( + a=a, + ) + + post_responses_unions_simple_before_complex_response_200.additional_properties = d + return post_responses_unions_simple_before_complex_response_200 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py new file mode 100644 index 000000000..74b4c03e4 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py @@ -0,0 +1,41 @@ +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="PostResponsesUnionsSimpleBeforeComplexResponse200AType1") + + +@_attrs_define +class PostResponsesUnionsSimpleBeforeComplexResponse200AType1: + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + post_responses_unions_simple_before_complex_response_200a_type_1 = cls() + + post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = d + return post_responses_unions_simple_before_complex_response_200a_type_1 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py new file mode 100644 index 000000000..9b794752b --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py @@ -0,0 +1,33 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="TestInlineObjectsBody") + + +@_attrs_define +class TestInlineObjectsBody: + a_property: Union[Unset, str] = UNSET + + def to_dict(self) -> dict[str, Any]: + a_property = self.a_property + + field_dict: dict[str, Any] = {} + field_dict.update({}) + if a_property is not UNSET: + field_dict["a_property"] = a_property + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_property = d.pop("a_property", UNSET) + + test_inline_objects_body = cls( + a_property=a_property, + ) + + return test_inline_objects_body diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py new file mode 100644 index 000000000..91a46fea2 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py @@ -0,0 +1,33 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="TestInlineObjectsResponse200") + + +@_attrs_define +class TestInlineObjectsResponse200: + a_property: Union[Unset, str] = UNSET + + def to_dict(self) -> dict[str, Any]: + a_property = self.a_property + + field_dict: dict[str, Any] = {} + field_dict.update({}) + if a_property is not UNSET: + field_dict["a_property"] = a_property + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + a_property = d.pop("a_property", UNSET) + + test_inline_objects_response_200 = cls( + a_property=a_property, + ) + + return test_inline_objects_response_200 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py new file mode 100644 index 000000000..ff52e8669 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py @@ -0,0 +1,47 @@ +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="ValidationError") + + +@_attrs_define +class ValidationError: + loc: list[str] + msg: str + type_: str + + def to_dict(self) -> dict[str, Any]: + loc = self.loc + + msg = self.msg + + type_ = self.type_ + + field_dict: dict[str, Any] = {} + field_dict.update( + { + "loc": loc, + "msg": msg, + "type": type_, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + loc = cast(list[str], d.pop("loc")) + + msg = d.pop("msg") + + type_ = d.pop("type") + + validation_error = cls( + loc=loc, + msg=msg, + type_=type_, + ) + + return validation_error diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/py.typed b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/py.typed new file mode 100644 index 000000000..1aad32711 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py new file mode 100644 index 000000000..b9ed58b8a --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py @@ -0,0 +1,46 @@ +"""Contains some shared types for properties""" + +from collections.abc import MutableMapping +from http import HTTPStatus +from typing import BinaryIO, Generic, Literal, Optional, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: Optional[str] = None + mime_type: Optional[str] = None + + def to_tuple(self) -> FileJsonType: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: Optional[T] + + +__all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"] diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/pyproject.toml b/end_to_end_tests/docstrings-on-attributes-golden-record/pyproject.toml new file mode 100644 index 000000000..feca06dbd --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/pyproject.toml @@ -0,0 +1,27 @@ +[tool.poetry] +name = "my-test-api-client" +version = "0.1.0" +description = "A client library for accessing My Test API" +authors = [] +readme = "README.md" +packages = [ + {include = "my_test_api_client"}, +] +include = ["CHANGELOG.md", "my_test_api_client/py.typed"] + + +[tool.poetry.dependencies] +python = "^3.9" +httpx = ">=0.20.0,<0.29.0" +attrs = ">=22.2.0" +python-dateutil = "^2.8.0" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "I", "UP"] diff --git a/end_to_end_tests/docstrings_on_attributes.config.yml b/end_to_end_tests/docstrings_on_attributes.config.yml new file mode 100644 index 000000000..6341692d5 --- /dev/null +++ b/end_to_end_tests/docstrings_on_attributes.config.yml @@ -0,0 +1,15 @@ +class_overrides: + _ABCResponse: + class_name: ABCResponse + module_name: abc_response + AnEnumValueItem: + class_name: AnEnumValue + module_name: an_enum_value + NestedListOfEnumsItemItem: + class_name: AnEnumValue + module_name: an_enum_value +field_prefix: attr_ +content_type_overrides: + openapi/python/client: application/json +generate_all_tags: true +docstrings_on_attributes: true diff --git a/end_to_end_tests/regen_golden_record.py b/end_to_end_tests/regen_golden_record.py index 2471e1340..f8b95486b 100644 --- a/end_to_end_tests/regen_golden_record.py +++ b/end_to_end_tests/regen_golden_record.py @@ -4,93 +4,96 @@ import shutil import tempfile from pathlib import Path +from typing import Optional from typer.testing import CliRunner from openapi_python_client.cli import app -def regen_golden_record(): +def _regenerate( + *, + spec_file_name: str, + output_dir: str = "my-test-api-client", + golden_record_dir: Optional[str] = None, + config_file_name: str = "config.yml", + extra_args: Optional[list[str]] = None +) -> None: + end_to_end_tests_base_path = Path(__file__).parent + project_base_path = end_to_end_tests_base_path.parent runner = CliRunner() - openapi_path = Path(__file__).parent / "baseline_openapi_3.0.json" - - gr_path = Path(__file__).parent / "golden-record" - output_path = Path.cwd() / "my-test-api-client" - config_path = Path(__file__).parent / "config.yml" + openapi_path = end_to_end_tests_base_path / spec_file_name - shutil.rmtree(gr_path, ignore_errors=True) + output_path = project_base_path / output_dir shutil.rmtree(output_path, ignore_errors=True) - result = runner.invoke( - app, ["generate", f"--config={config_path}", f"--path={openapi_path}"] - ) - - if result.stdout: - print(result.stdout) - if result.exception: - raise result.exception - output_path.rename(gr_path) - - -def regen_golden_record_3_1_features(): - runner = CliRunner() - openapi_path = Path(__file__).parent / "3.1_specific.openapi.yaml" - - gr_path = Path(__file__).parent / "test-3-1-golden-record" - output_path = Path.cwd() / "test-3-1-features-client" - - shutil.rmtree(gr_path, ignore_errors=True) - shutil.rmtree(output_path, ignore_errors=True) + args = ["generate", f"--path={openapi_path}"] + if config_file_name: + config_path = end_to_end_tests_base_path / config_file_name + args.append(f"--config={config_path}") + if extra_args: + args.extend(extra_args) + print(f"Using {spec_file_name}{f' and {config_file_name}' if config_file_name else ''}") - result = runner.invoke(app, ["generate", f"--path={openapi_path}"]) + result = runner.invoke(app, args) if result.stdout: print(result.stdout) if result.exception: raise result.exception - output_path.rename(gr_path) + if golden_record_dir: + gr_path = end_to_end_tests_base_path / golden_record_dir + shutil.rmtree(gr_path, ignore_errors=True) + output_path.rename(gr_path) -def regen_literal_enums_golden_record(): - runner = CliRunner() - openapi_path = Path(__file__).parent / "openapi_3.1_enums.yaml" +def regen_golden_record(): + _regenerate( + spec_file_name="baseline_openapi_3.0.json", + golden_record_dir="golden-record", + ) - gr_path = Path(__file__).parent / "literal-enums-golden-record" - output_path = Path.cwd() / "my-enum-api-client" - config_path = Path(__file__).parent / "literal_enums.config.yml" - shutil.rmtree(gr_path, ignore_errors=True) - shutil.rmtree(output_path, ignore_errors=True) +def regen_golden_record_3_1_features(): + _regenerate( + spec_file_name="3.1_specific.openapi.yaml", + output_dir="test-3-1-features-client", + golden_record_dir="test-3-1-golden-record", + ) - result = runner.invoke(app, ["generate", f"--path={openapi_path}", f"--config={config_path}"]) - if result.stdout: - print(result.stdout) - if result.exception: - raise result.exception - output_path.rename(gr_path) +def regen_literal_enums_golden_record(): + _regenerate( + spec_file_name="openapi_3.1_enums.yaml", + output_dir="my-enum-api-client", + golden_record_dir="literal-enums-golden-record", + config_file_name="literal_enums.config.yml", + ) def regen_metadata_snapshots(): - runner = CliRunner() - openapi_path = Path(__file__).parent / "3.1_specific.openapi.yaml" output_path = Path.cwd() / "test-3-1-features-client" snapshots_dir = Path(__file__).parent / "metadata_snapshots" for (meta, file, rename_to) in (("setup", "setup.py", "setup.py"), ("pdm", "pyproject.toml", "pdm.pyproject.toml"), ("poetry", "pyproject.toml", "poetry.pyproject.toml")): - shutil.rmtree(output_path, ignore_errors=True) - result = runner.invoke(app, ["generate", f"--path={openapi_path}", f"--meta={meta}"]) - - if result.stdout: - print(result.stdout) - if result.exception: - raise result.exception - + _regenerate( + spec_file_name="3.1_specific.openapi.yaml", + output_dir="test-3-1-features-client", + extra_args=[f"--meta={meta}"], + ) (output_path / file).rename(snapshots_dir / rename_to) shutil.rmtree(output_path, ignore_errors=True) +def regen_docstrings_on_attributes_golden_record(): + _regenerate( + spec_file_name="baseline_openapi_3.0.json", + golden_record_dir="docstrings-on-attributes-golden-record", + config_file_name="docstrings_on_attributes.config.yml", + ) + + def regen_custom_template_golden_record(): runner = CliRunner() openapi_path = Path(__file__).parent / "baseline_openapi_3.0.json" @@ -143,5 +146,6 @@ def regen_custom_template_golden_record(): regen_golden_record() regen_golden_record_3_1_features() regen_metadata_snapshots() + regen_docstrings_on_attributes_golden_record() regen_custom_template_golden_record() regen_literal_enums_golden_record() diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index 124b801d2..efa8da4f3 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -192,6 +192,16 @@ def test_none_meta(): ) +def test_docstrings_on_attributes(): + config_path = Path(__file__).parent / "docstrings_on_attributes.config.yml" + run_e2e_test( + "baseline_openapi_3.1.yaml", + [f"--config={config_path}"], + {}, + "docstrings-on-attributes-golden-record", + ) + + def test_custom_templates(): expected_differences = ( {} diff --git a/integration-tests/pyproject.toml b/integration-tests/pyproject.toml index cbcff74c6..6052a3d70 100644 --- a/integration-tests/pyproject.toml +++ b/integration-tests/pyproject.toml @@ -14,19 +14,12 @@ dependencies = [ [tool.pdm] distribution = true -[tool.pdm.dev-dependencies] -dev = [ - "pytest", - "mypy", - "pytest-asyncio>=0.23.5", -] - [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" - + [tool.ruff] line-length = 120 [tool.ruff.lint] -select = ["F", "I"] +select = ["F", "I", "UP"] diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index af6944ae4..ba6380cd5 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -90,6 +90,7 @@ def __init__( self.env.filters.update(TEMPLATE_FILTERS) self.env.globals.update( + config=config, utils=utils, python_identifier=lambda x: utils.PythonIdentifier(x, config.field_prefix), class_name=lambda x: utils.ClassName(x, config.field_prefix), diff --git a/openapi_python_client/config.py b/openapi_python_client/config.py index 9cc002d12..1616ac785 100644 --- a/openapi_python_client/config.py +++ b/openapi_python_client/config.py @@ -41,6 +41,7 @@ class ConfigFile(BaseModel): package_version_override: Optional[str] = None use_path_prefixes_for_title_model_names: bool = True post_hooks: Optional[list[str]] = None + docstrings_on_attributes: bool = False field_prefix: str = "field_" generate_all_tags: bool = False http_timeout: int = 5 @@ -70,6 +71,7 @@ class Config: package_version_override: Optional[str] use_path_prefixes_for_title_model_names: bool post_hooks: list[str] + docstrings_on_attributes: bool field_prefix: str generate_all_tags: bool http_timeout: int @@ -111,6 +113,7 @@ def from_sources( package_version_override=config_file.package_version_override, use_path_prefixes_for_title_model_names=config_file.use_path_prefixes_for_title_model_names, post_hooks=post_hooks, + docstrings_on_attributes=config_file.docstrings_on_attributes, field_prefix=config_file.field_prefix, generate_all_tags=config_file.generate_all_tags, http_timeout=config_file.http_timeout, diff --git a/openapi_python_client/templates/helpers.jinja b/openapi_python_client/templates/helpers.jinja index 180613c02..fd5c3ec86 100644 --- a/openapi_python_client/templates/helpers.jinja +++ b/openapi_python_client/templates/helpers.jinja @@ -1,8 +1,10 @@ -{% macro safe_docstring(content) %} +{% macro safe_docstring(content, omit_if_empty=False) %} {# This macro returns the provided content as a docstring, set to a raw string if it contains a backslash #} +{% if (not omit_if_empty) or (content | trim) %} {% if '\\' in content -%} r""" {{ content }} """ {%- else -%} """ {{ content }} """ {%- endif -%} +{% endif %} {% endmacro %} \ No newline at end of file diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 739f68962..6cd3fca5e 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -47,25 +47,34 @@ T = TypeVar("T", bound="{{ class_name }}") {{ model.example | string | wordwrap(112) | indent(12) }} {% endif %} - {% if model.required_properties or model.optional_properties %} + {% if (not config.docstrings_on_attributes) and (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 %} {% endmacro %} +{% macro declare_property(property) %} +{%- if config.docstrings_on_attributes and property.description -%} +{{ property.to_string() }} +{{ safe_docstring(property.description, omit_if_empty=True) | wordwrap(112) }} +{%- else -%} +{{ property.to_string() }} +{%- endif -%} +{% endmacro %} + @_attrs_define class {{ class_name }}: - {{ safe_docstring(class_docstring_content(model)) | indent(4) }} + {{ safe_docstring(class_docstring_content(model), omit_if_empty=config.docstrings_on_attributes) | indent(4) }} {% for property in model.required_properties + model.optional_properties %} {% if property.default is none and property.required %} - {{ property.to_string() }} + {{ declare_property(property) | indent(4) }} {% endif %} {% endfor %} {% for property in model.required_properties + model.optional_properties %} {% if property.default is not none or not property.required %} - {{ property.to_string() }} + {{ declare_property(property) | indent(4) }} {% endif %} {% endfor %} {% if model.additional_properties %} From 6ee7af7011fa12e1b5c86fdcc18c3ffe50c3228b Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 10:11:20 -0800 Subject: [PATCH 2/9] changeset --- .changeset/docstrings-on-attributes.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/docstrings-on-attributes.md diff --git a/.changeset/docstrings-on-attributes.md b/.changeset/docstrings-on-attributes.md new file mode 100644 index 000000000..b87bcee11 --- /dev/null +++ b/.changeset/docstrings-on-attributes.md @@ -0,0 +1,7 @@ +--- +default: minor +--- + +# Add `docstrings_on_attributes` config setting + +Setting this option to `true` changes the docstring behavior in model classes: for any attribute that have a non-empty `description`, instead of describing the attribute as part of the class's docstring, the description will appear in an individual docstring for that attribute. From 1333a3a54ecf95cf65b1e89533957ec46fc74ae5 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 10:17:20 -0800 Subject: [PATCH 3/9] revert unintended change --- integration-tests/pyproject.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/integration-tests/pyproject.toml b/integration-tests/pyproject.toml index 6052a3d70..559c07f8a 100644 --- a/integration-tests/pyproject.toml +++ b/integration-tests/pyproject.toml @@ -14,6 +14,13 @@ dependencies = [ [tool.pdm] distribution = true +[tool.pdm.dev-dependencies] +dev = [ + "pytest", + "mypy", + "pytest-asyncio>=0.23.5", +] + [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" @@ -22,4 +29,4 @@ build-backend = "pdm.backend" line-length = 120 [tool.ruff.lint] -select = ["F", "I", "UP"] +select = ["F", "I"] From ad3e68fd0aca4cc487e6f8b4b37bc7eaff8df094 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 10:19:36 -0800 Subject: [PATCH 4/9] rm unused imports --- end_to_end_tests/regen_golden_record.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/end_to_end_tests/regen_golden_record.py b/end_to_end_tests/regen_golden_record.py index f8b95486b..8ae805ed1 100644 --- a/end_to_end_tests/regen_golden_record.py +++ b/end_to_end_tests/regen_golden_record.py @@ -1,8 +1,6 @@ """ Regenerate golden-record """ import filecmp -import os import shutil -import tempfile from pathlib import Path from typing import Optional From 0c733078f224c2157bbd3d31d4db1313992bce2c Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 12:35:20 -0800 Subject: [PATCH 5/9] use minimal spec for new end-to-end test case --- .../my_test_api_client/api/bodies/__init__.py | 0 .../api/bodies/json_like.py | 103 ---- .../api/bodies/post_bodies_multiple.py | 142 ----- .../my_test_api_client/api/bodies/refs.py | 103 ---- .../my_test_api_client/api/config/__init__.py | 0 .../api/config/content_type_override.py | 153 ----- .../api/default/__init__.py | 0 .../api/default/get_common_parameters.py | 99 ---- .../api/default/get_models_allof.py | 122 ---- .../get_models_oneof_with_required_const.py | 159 ------ .../api/default/post_common_parameters.py | 99 ---- .../api/default/reserved_parameters.py | 108 ---- .../api/defaults/__init__.py | 0 .../defaults/defaults_tests_defaults_post.py | 363 ------------ .../my_test_api_client/api/enums/__init__.py | 0 .../enums/bool_enum_tests_bool_enum_post.py | 101 ---- .../api/enums/int_enum_tests_int_enum_post.py | 103 ---- .../api/location/__init__.py | 0 .../api/location/get_location_header_types.py | 149 ----- .../get_location_query_optionality.py | 143 ----- .../my_test_api_client/api/naming/__init__.py | 0 .../api/naming/hyphen_in_path.py | 91 --- .../api/naming/mixed_case.py | 169 ------ ...st_naming_property_conflict_with_import.py | 158 ------ .../api/parameter_references/__init__.py | 0 .../get_parameter_references_path_param.py | 141 ----- .../api/parameters/__init__.py | 0 ...lete_common_parameters_overriding_param.py | 106 ---- .../get_common_parameters_overriding_param.py | 110 ---- .../get_same_name_multiple_locations_param.py | 130 ----- .../parameters/multiple_path_parameters.py | 112 ---- .../api/responses/__init__.py | 0 ..._responses_unions_simple_before_complex.py | 128 ----- .../api/responses/text_response.py | 120 ---- .../my_test_api_client/api/tag1/__init__.py | 0 .../api/tag1/get_tag_with_number.py | 77 --- .../my_test_api_client/api/tag2/__init__.py | 0 .../api/tag2/get_tag_with_number.py | 77 --- .../my_test_api_client/api/tests/__init__.py | 0 .../api/tests/callback_test.py | 171 ------ .../api/tests/description_with_backslash.py | 83 --- .../api/tests/get_basic_list_of_booleans.py | 129 ----- .../api/tests/get_basic_list_of_floats.py | 129 ----- .../api/tests/get_basic_list_of_integers.py | 129 ----- .../api/tests/get_basic_list_of_strings.py | 129 ----- .../api/tests/get_user_list.py | 250 -------- .../tests/json_body_tests_json_body_post.py | 171 ------ .../no_response_tests_no_response_get.py | 79 --- .../octet_stream_tests_octet_stream_get.py | 122 ---- .../octet_stream_tests_octet_stream_post.py | 162 ------ .../api/tests/post_form_data.py | 107 ---- .../api/tests/post_form_data_inline.py | 107 ---- .../api/tests/post_tests_json_body_string.py | 162 ------ .../api/tests/test_inline_objects.py | 160 ------ ..._with_cookie_auth_token_with_cookie_get.py | 104 ---- ...d_content_tests_unsupported_content_get.py | 79 --- .../tests/upload_file_tests_upload_post.py | 170 ------ ...upload_multiple_files_tests_upload_post.py | 173 ------ .../my_test_api_client/api/true_/__init__.py | 0 .../my_test_api_client/api/true_/false_.py | 99 ---- .../my_test_api_client/models/__init__.py | 170 +----- .../models/a_discriminated_union_type_1.py | 53 -- .../models/a_discriminated_union_type_2.py | 53 -- .../my_test_api_client/models/a_form_data.py | 63 --- .../my_test_api_client/models/a_model.py | 508 ----------------- ...roperties_reference_that_are_not_object.py | 343 ----------- .../all_of_has_properties_but_no_type.py | 77 --- ...of_has_properties_but_no_type_type_enum.py | 9 - .../models/all_of_sub_model.py | 77 --- .../models/all_of_sub_model_type_enum.py | 9 - .../models/an_all_of_enum.py | 11 - ...h_a_circular_ref_in_items_object_a_item.py | 77 --- ...ems_object_additional_properties_a_item.py | 84 --- ...ems_object_additional_properties_b_item.py | 84 --- ...h_a_circular_ref_in_items_object_b_item.py | 77 --- ...items_object_additional_properties_item.py | 72 --- ...th_a_recursive_ref_in_items_object_item.py | 69 --- .../my_test_api_client/models/an_enum.py | 9 - .../models/an_enum_with_null.py | 9 - .../my_test_api_client/models/an_int_enum.py | 10 - .../models/another_all_of_sub_model.py | 85 --- .../models/another_all_of_sub_model_type.py | 8 - .../another_all_of_sub_model_type_enum.py | 8 - .../body_upload_file_tests_upload_post.py | 422 -------------- ...e_tests_upload_post_additional_property.py | 53 -- ..._tests_upload_post_some_nullable_object.py | 53 -- ...load_file_tests_upload_post_some_object.py | 60 -- ..._tests_upload_post_some_optional_object.py | 53 -- .../models/different_enum.py | 9 - .../my_test_api_client/models/extended.py | 534 ------------------ .../models/free_form_model.py | 41 -- ...t_location_header_types_int_enum_header.py | 10 - ...ocation_header_types_string_enum_header.py | 10 - .../models/get_models_allof_response_200.py | 100 ---- ...with_required_const_response_200_type_0.py | 65 --- ...with_required_const_response_200_type_1.py | 65 --- .../models/http_validation_error.py | 49 -- .../my_test_api_client/models/import_.py | 41 -- .../models/json_like_body.py | 53 -- .../models/model_from_all_of.py | 93 --- .../my_test_api_client/models/model_name.py | 41 -- .../models/model_reference_with_periods.py | 43 -- ...odel_with_additional_properties_inlined.py | 72 --- ..._properties_inlined_additional_property.py | 53 -- .../model_with_additional_properties_refed.py | 50 -- .../models/model_with_any_json_properties.py | 100 ---- ...n_properties_additional_property_type_0.py | 41 -- .../model_with_backslash_in_description.py | 45 -- .../models/model_with_circular_ref_a.py | 66 --- .../models/model_with_circular_ref_b.py | 66 --- ...circular_ref_in_additional_properties_a.py | 58 -- ...circular_ref_in_additional_properties_b.py | 58 -- .../models/model_with_date_time_property.py | 62 -- .../models/model_with_description.py | 77 +++ .../models/model_with_discriminated_union.py | 98 ---- .../models/model_with_merged_properties.py | 103 ---- ...l_with_merged_properties_string_to_enum.py | 9 - ...se_200.py => model_with_no_description.py} | 35 +- .../models/model_with_no_properties.py | 19 - ...el_with_primitive_additional_properties.py | 70 --- ...ive_additional_properties_a_date_holder.py | 50 -- .../models/model_with_property_ref.py | 66 --- .../models/model_with_recursive_ref.py | 60 -- ..._recursive_ref_in_additional_properties.py | 50 -- .../models/model_with_union_property.py | 59 -- .../model_with_union_property_inlined.py | 69 --- ...ith_union_property_inlined_fruit_type_0.py | 53 -- ...ith_union_property_inlined_fruit_type_1.py | 53 -- .../my_test_api_client/models/none.py | 41 -- .../models/post_bodies_multiple_data_body.py | 53 -- .../models/post_bodies_multiple_files_body.py | 66 --- .../models/post_bodies_multiple_json_body.py | 53 -- .../models/post_form_data_inline_body.py | 63 --- ...ming_property_conflict_with_import_body.py | 63 --- ...perty_conflict_with_import_response_200.py | 63 --- ...ions_simple_before_complex_response_200.py | 83 --- ...ple_before_complex_response_200a_type_1.py | 41 -- .../models/test_inline_objects_body.py | 33 -- .../test_inline_objects_response_200.py | 33 -- .../models/validation_error.py | 47 -- end_to_end_tests/docstrings_on_attributes.yml | 32 ++ end_to_end_tests/regen_golden_record.py | 2 +- integration-tests/pyproject.toml | 2 +- 143 files changed, 133 insertions(+), 11925 deletions(-) delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py create mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py rename end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/{mixed_case_response_200.py => model_with_no_description.py} (55%) delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py delete mode 100644 end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py create mode 100644 end_to_end_tests/docstrings_on_attributes.yml diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py deleted file mode 100644 index 626bacfa6..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/json_like.py +++ /dev/null @@ -1,103 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.json_like_body import JsonLikeBody -from ...types import Response - - -def _get_kwargs( - *, - body: JsonLikeBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/bodies/json-like", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/vnd+json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: JsonLikeBody, -) -> Response[Any]: - """A content type that works like json but isn't application/json - - Args: - body (JsonLikeBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: JsonLikeBody, -) -> Response[Any]: - """A content type that works like json but isn't application/json - - Args: - body (JsonLikeBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py deleted file mode 100644 index 84ec8eee0..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py +++ /dev/null @@ -1,142 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.post_bodies_multiple_data_body import PostBodiesMultipleDataBody -from ...models.post_bodies_multiple_files_body import PostBodiesMultipleFilesBody -from ...models.post_bodies_multiple_json_body import PostBodiesMultipleJsonBody -from ...types import File, Response - - -def _get_kwargs( - *, - body: Union[ - PostBodiesMultipleJsonBody, - File, - PostBodiesMultipleDataBody, - PostBodiesMultipleFilesBody, - ], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/bodies/multiple", - } - - if isinstance(body, PostBodiesMultipleJsonBody): - _json_body = body.to_dict() - - _kwargs["json"] = _json_body - headers["Content-Type"] = "application/json" - if isinstance(body, File): - _content_body = body.payload - - _kwargs["content"] = _content_body - headers["Content-Type"] = "application/octet-stream" - if isinstance(body, PostBodiesMultipleDataBody): - _data_body = body.to_dict() - - _kwargs["data"] = _data_body - headers["Content-Type"] = "application/x-www-form-urlencoded" - if isinstance(body, PostBodiesMultipleFilesBody): - _files_body = body.to_multipart() - - _kwargs["files"] = _files_body - headers["Content-Type"] = "multipart/form-data" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: Union[ - PostBodiesMultipleJsonBody, - File, - PostBodiesMultipleDataBody, - PostBodiesMultipleFilesBody, - ], -) -> Response[Any]: - """Test multiple bodies - - Args: - body (PostBodiesMultipleJsonBody): - body (File): - body (PostBodiesMultipleDataBody): - body (PostBodiesMultipleFilesBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: Union[ - PostBodiesMultipleJsonBody, - File, - PostBodiesMultipleDataBody, - PostBodiesMultipleFilesBody, - ], -) -> Response[Any]: - """Test multiple bodies - - Args: - body (PostBodiesMultipleJsonBody): - body (File): - body (PostBodiesMultipleDataBody): - body (PostBodiesMultipleFilesBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py deleted file mode 100644 index a79cf178a..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/bodies/refs.py +++ /dev/null @@ -1,103 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.a_model import AModel -from ...types import Response - - -def _get_kwargs( - *, - body: AModel, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/bodies/refs", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Any]: - """Test request body defined via ref - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Any]: - """Test request body defined via ref - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py deleted file mode 100644 index 2bd74aac4..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/config/content_type_override.py +++ /dev/null @@ -1,153 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs( - *, - body: str, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/config/content-type-override", - } - - _body = body - - _kwargs["json"] = _body - headers["Content-Type"] = "openapi/python/client" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: - if response.status_code == 200: - response_200 = cast(str, response.json()) - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Response[str]: - """Content Type Override - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[str] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Optional[str]: - """Content Type Override - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - str - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Response[str]: - """Content Type Override - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[str] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Optional[str]: - """Content Type Override - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - str - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py deleted file mode 100644 index 7de222f55..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_common_parameters.py +++ /dev/null @@ -1,99 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - common: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["common"] = common - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/common_parameters", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - common: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - common (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - common=common, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - common: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - common (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - common=common, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py deleted file mode 100644 index 9d837acd6..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_allof.py +++ /dev/null @@ -1,122 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.get_models_allof_response_200 import GetModelsAllofResponse200 -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/models/allof", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[GetModelsAllofResponse200]: - if response.status_code == 200: - response_200 = GetModelsAllofResponse200.from_dict(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[GetModelsAllofResponse200]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetModelsAllofResponse200]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetModelsAllofResponse200] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetModelsAllofResponse200]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetModelsAllofResponse200 - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[GetModelsAllofResponse200]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[GetModelsAllofResponse200] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[GetModelsAllofResponse200]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - GetModelsAllofResponse200 - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py deleted file mode 100644 index 85f68fb7c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py +++ /dev/null @@ -1,159 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.get_models_oneof_with_required_const_response_200_type_0 import ( - GetModelsOneofWithRequiredConstResponse200Type0, -) -from ...models.get_models_oneof_with_required_const_response_200_type_1 import ( - GetModelsOneofWithRequiredConstResponse200Type1, -) -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/models/oneof-with-required-const", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - if response.status_code == 200: - - def _parse_response_200( - data: object, - ) -> Union[ - "GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1" - ]: - try: - if not isinstance(data, dict): - raise TypeError() - response_200_type_0 = GetModelsOneofWithRequiredConstResponse200Type0.from_dict(data) - - return response_200_type_0 - except: # noqa: E722 - pass - if not isinstance(data, dict): - raise TypeError() - response_200_type_1 = GetModelsOneofWithRequiredConstResponse200Type1.from_dict(data) - - return response_200_type_1 - - response_200 = _parse_response_200(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1'] - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] -]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1'] - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py deleted file mode 100644 index 5bd941c69..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/post_common_parameters.py +++ /dev/null @@ -1,99 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - common: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["common"] = common - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/common_parameters", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - common: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - common (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - common=common, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - common: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - common (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - common=common, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py deleted file mode 100644 index fe7adf04c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/default/reserved_parameters.py +++ /dev/null @@ -1,108 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response - - -def _get_kwargs( - *, - client_query: str, - url_query: str, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["client"] = client_query - - params["url"] = url_query - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/naming/reserved-parameters", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - client_query: str, - url_query: str, -) -> Response[Any]: - """ - Args: - client_query (str): - url_query (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - client_query=client_query, - url_query=url_query, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - client_query: str, - url_query: str, -) -> Response[Any]: - """ - Args: - client_query (str): - url_query (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - client_query=client_query, - url_query=url_query, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py deleted file mode 100644 index ffc9b535e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py +++ /dev/null @@ -1,363 +0,0 @@ -import datetime -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx -from dateutil.parser import isoparse - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.an_enum import AnEnum -from ...models.http_validation_error import HTTPValidationError -from ...models.model_with_union_property import ModelWithUnionProperty -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - string_prop: str = "the default string", - string_with_num: str = "1", - date_prop: datetime.date = isoparse("1010-10-10").date(), - float_prop: float = 3.14, - float_with_int: float = 3.0, - int_prop: int = 7, - boolean_prop: bool = False, - list_prop: list[AnEnum], - union_prop: Union[float, str] = "not a float", - union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, - enum_prop: AnEnum, - model_prop: "ModelWithUnionProperty", - required_model_prop: "ModelWithUnionProperty", -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["string_prop"] = string_prop - - params["string with num"] = string_with_num - - json_date_prop = date_prop.isoformat() - params["date_prop"] = json_date_prop - - params["float_prop"] = float_prop - - params["float_with_int"] = float_with_int - - params["int_prop"] = int_prop - - params["boolean_prop"] = boolean_prop - - json_list_prop = [] - for list_prop_item_data in list_prop: - list_prop_item = list_prop_item_data.value - json_list_prop.append(list_prop_item) - - params["list_prop"] = json_list_prop - - json_union_prop: Union[float, str] - json_union_prop = union_prop - params["union_prop"] = json_union_prop - - json_union_prop_with_ref: Union[Unset, float, str] - if isinstance(union_prop_with_ref, Unset): - json_union_prop_with_ref = UNSET - elif isinstance(union_prop_with_ref, AnEnum): - json_union_prop_with_ref = union_prop_with_ref.value - else: - json_union_prop_with_ref = union_prop_with_ref - params["union_prop_with_ref"] = json_union_prop_with_ref - - json_enum_prop = enum_prop.value - params["enum_prop"] = json_enum_prop - - json_model_prop = model_prop.to_dict() - params.update(json_model_prop) - - json_required_model_prop = required_model_prop.to_dict() - params.update(json_required_model_prop) - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/defaults", - "params": params, - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == 200: - response_200 = response.json() - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - string_prop: str = "the default string", - string_with_num: str = "1", - date_prop: datetime.date = isoparse("1010-10-10").date(), - float_prop: float = 3.14, - float_with_int: float = 3.0, - int_prop: int = 7, - boolean_prop: bool = False, - list_prop: list[AnEnum], - union_prop: Union[float, str] = "not a float", - union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, - enum_prop: AnEnum, - model_prop: "ModelWithUnionProperty", - required_model_prop: "ModelWithUnionProperty", -) -> Response[Union[Any, HTTPValidationError]]: - """Defaults - - Args: - string_prop (str): Default: 'the default string'. - string_with_num (str): Default: '1'. - date_prop (datetime.date): Default: isoparse('1010-10-10').date(). - float_prop (float): Default: 3.14. - float_with_int (float): Default: 3.0. - int_prop (int): Default: 7. - boolean_prop (bool): Default: False. - list_prop (list[AnEnum]): - union_prop (Union[float, str]): Default: 'not a float'. - union_prop_with_ref (Union[AnEnum, 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): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - string_prop=string_prop, - string_with_num=string_with_num, - date_prop=date_prop, - float_prop=float_prop, - float_with_int=float_with_int, - int_prop=int_prop, - boolean_prop=boolean_prop, - list_prop=list_prop, - union_prop=union_prop, - union_prop_with_ref=union_prop_with_ref, - enum_prop=enum_prop, - model_prop=model_prop, - required_model_prop=required_model_prop, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - string_prop: str = "the default string", - string_with_num: str = "1", - date_prop: datetime.date = isoparse("1010-10-10").date(), - float_prop: float = 3.14, - float_with_int: float = 3.0, - int_prop: int = 7, - boolean_prop: bool = False, - list_prop: list[AnEnum], - union_prop: Union[float, str] = "not a float", - union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, - enum_prop: AnEnum, - model_prop: "ModelWithUnionProperty", - required_model_prop: "ModelWithUnionProperty", -) -> Optional[Union[Any, HTTPValidationError]]: - """Defaults - - Args: - string_prop (str): Default: 'the default string'. - string_with_num (str): Default: '1'. - date_prop (datetime.date): Default: isoparse('1010-10-10').date(). - float_prop (float): Default: 3.14. - float_with_int (float): Default: 3.0. - int_prop (int): Default: 7. - boolean_prop (bool): Default: False. - list_prop (list[AnEnum]): - union_prop (Union[float, str]): Default: 'not a float'. - union_prop_with_ref (Union[AnEnum, 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): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return sync_detailed( - client=client, - string_prop=string_prop, - string_with_num=string_with_num, - date_prop=date_prop, - float_prop=float_prop, - float_with_int=float_with_int, - int_prop=int_prop, - boolean_prop=boolean_prop, - list_prop=list_prop, - union_prop=union_prop, - union_prop_with_ref=union_prop_with_ref, - enum_prop=enum_prop, - model_prop=model_prop, - required_model_prop=required_model_prop, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - string_prop: str = "the default string", - string_with_num: str = "1", - date_prop: datetime.date = isoparse("1010-10-10").date(), - float_prop: float = 3.14, - float_with_int: float = 3.0, - int_prop: int = 7, - boolean_prop: bool = False, - list_prop: list[AnEnum], - union_prop: Union[float, str] = "not a float", - union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, - enum_prop: AnEnum, - model_prop: "ModelWithUnionProperty", - required_model_prop: "ModelWithUnionProperty", -) -> Response[Union[Any, HTTPValidationError]]: - """Defaults - - Args: - string_prop (str): Default: 'the default string'. - string_with_num (str): Default: '1'. - date_prop (datetime.date): Default: isoparse('1010-10-10').date(). - float_prop (float): Default: 3.14. - float_with_int (float): Default: 3.0. - int_prop (int): Default: 7. - boolean_prop (bool): Default: False. - list_prop (list[AnEnum]): - union_prop (Union[float, str]): Default: 'not a float'. - union_prop_with_ref (Union[AnEnum, 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): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - string_prop=string_prop, - string_with_num=string_with_num, - date_prop=date_prop, - float_prop=float_prop, - float_with_int=float_with_int, - int_prop=int_prop, - boolean_prop=boolean_prop, - list_prop=list_prop, - union_prop=union_prop, - union_prop_with_ref=union_prop_with_ref, - enum_prop=enum_prop, - model_prop=model_prop, - required_model_prop=required_model_prop, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - string_prop: str = "the default string", - string_with_num: str = "1", - date_prop: datetime.date = isoparse("1010-10-10").date(), - float_prop: float = 3.14, - float_with_int: float = 3.0, - int_prop: int = 7, - boolean_prop: bool = False, - list_prop: list[AnEnum], - union_prop: Union[float, str] = "not a float", - union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, - enum_prop: AnEnum, - model_prop: "ModelWithUnionProperty", - required_model_prop: "ModelWithUnionProperty", -) -> Optional[Union[Any, HTTPValidationError]]: - """Defaults - - Args: - string_prop (str): Default: 'the default string'. - string_with_num (str): Default: '1'. - date_prop (datetime.date): Default: isoparse('1010-10-10').date(). - float_prop (float): Default: 3.14. - float_with_int (float): Default: 3.0. - int_prop (int): Default: 7. - boolean_prop (bool): Default: False. - list_prop (list[AnEnum]): - union_prop (Union[float, str]): Default: 'not a float'. - union_prop_with_ref (Union[AnEnum, 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): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return ( - await asyncio_detailed( - client=client, - string_prop=string_prop, - string_with_num=string_with_num, - date_prop=date_prop, - float_prop=float_prop, - float_with_int=float_with_int, - int_prop=int_prop, - boolean_prop=boolean_prop, - list_prop=list_prop, - union_prop=union_prop, - union_prop_with_ref=union_prop_with_ref, - enum_prop=enum_prop, - model_prop=model_prop, - required_model_prop=required_model_prop, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py deleted file mode 100644 index 52385855c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ /dev/null @@ -1,101 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response - - -def _get_kwargs( - *, - bool_enum: bool, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["bool_enum"] = bool_enum - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/enum/bool", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - bool_enum: bool, -) -> Response[Any]: - """Bool Enum - - Args: - bool_enum (bool): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - bool_enum=bool_enum, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - bool_enum: bool, -) -> Response[Any]: - """Bool Enum - - Args: - bool_enum (bool): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - bool_enum=bool_enum, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py deleted file mode 100644 index 26c3729fe..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py +++ /dev/null @@ -1,103 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.an_int_enum import AnIntEnum -from ...types import UNSET, Response - - -def _get_kwargs( - *, - int_enum: AnIntEnum, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - json_int_enum = int_enum.value - params["int_enum"] = json_int_enum - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/enum/int", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - int_enum: AnIntEnum, -) -> Response[Any]: - """Int Enum - - Args: - int_enum (AnIntEnum): An enumeration. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - int_enum=int_enum, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - int_enum: AnIntEnum, -) -> Response[Any]: - """Int Enum - - Args: - int_enum (AnIntEnum): An enumeration. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - int_enum=int_enum, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py deleted file mode 100644 index ad9428a72..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_header_types.py +++ /dev/null @@ -1,149 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - boolean_header: Union[Unset, bool] = UNSET, - string_header: Union[Unset, str] = UNSET, - number_header: Union[Unset, float] = UNSET, - integer_header: Union[Unset, int] = UNSET, - int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, - string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - if not isinstance(boolean_header, Unset): - headers["Boolean-Header"] = "true" if boolean_header else "false" - - if not isinstance(string_header, Unset): - headers["String-Header"] = string_header - - if not isinstance(number_header, Unset): - headers["Number-Header"] = str(number_header) - - if not isinstance(integer_header, Unset): - headers["Integer-Header"] = str(integer_header) - - if not isinstance(int_enum_header, Unset): - headers["Int-Enum-Header"] = str(int_enum_header) - - if not isinstance(string_enum_header, Unset): - headers["String-Enum-Header"] = str(string_enum_header) - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/location/header/types", - } - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - boolean_header: Union[Unset, bool] = UNSET, - string_header: Union[Unset, str] = UNSET, - number_header: Union[Unset, float] = UNSET, - integer_header: Union[Unset, int] = UNSET, - int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, - string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, -) -> Response[Any]: - """ - Args: - boolean_header (Union[Unset, bool]): - string_header (Union[Unset, str]): - number_header (Union[Unset, float]): - integer_header (Union[Unset, int]): - int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): - string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - boolean_header=boolean_header, - string_header=string_header, - number_header=number_header, - integer_header=integer_header, - int_enum_header=int_enum_header, - string_enum_header=string_enum_header, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - boolean_header: Union[Unset, bool] = UNSET, - string_header: Union[Unset, str] = UNSET, - number_header: Union[Unset, float] = UNSET, - integer_header: Union[Unset, int] = UNSET, - int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, - string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, -) -> Response[Any]: - """ - Args: - boolean_header (Union[Unset, bool]): - string_header (Union[Unset, str]): - number_header (Union[Unset, float]): - integer_header (Union[Unset, int]): - int_enum_header (Union[Unset, GetLocationHeaderTypesIntEnumHeader]): - string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - boolean_header=boolean_header, - string_header=string_header, - number_header=number_header, - integer_header=integer_header, - int_enum_header=int_enum_header, - string_enum_header=string_enum_header, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py deleted file mode 100644 index e28e37a36..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ /dev/null @@ -1,143 +0,0 @@ -import datetime -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - *, - not_null_required: datetime.datetime, - null_required: Union[None, datetime.datetime], - null_not_required: Union[None, Unset, datetime.datetime] = UNSET, - not_null_not_required: Union[Unset, datetime.datetime] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - json_not_null_required = not_null_required.isoformat() - params["not_null_required"] = json_not_null_required - - json_null_required: Union[None, str] - if isinstance(null_required, datetime.datetime): - json_null_required = null_required.isoformat() - else: - json_null_required = null_required - params["null_required"] = json_null_required - - json_null_not_required: Union[None, Unset, str] - if isinstance(null_not_required, Unset): - json_null_not_required = UNSET - elif isinstance(null_not_required, datetime.datetime): - json_null_not_required = null_not_required.isoformat() - else: - json_null_not_required = null_not_required - params["null_not_required"] = json_null_not_required - - json_not_null_not_required: Union[Unset, str] = UNSET - if not isinstance(not_null_not_required, Unset): - json_not_null_not_required = not_null_not_required.isoformat() - params["not_null_not_required"] = json_not_null_not_required - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/location/query/optionality", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - not_null_required: datetime.datetime, - null_required: Union[None, datetime.datetime], - null_not_required: Union[None, Unset, datetime.datetime] = UNSET, - not_null_not_required: Union[Unset, datetime.datetime] = UNSET, -) -> Response[Any]: - """ - Args: - not_null_required (datetime.datetime): - null_required (Union[None, datetime.datetime]): - null_not_required (Union[None, Unset, datetime.datetime]): - not_null_not_required (Union[Unset, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - not_null_required=not_null_required, - null_required=null_required, - null_not_required=null_not_required, - not_null_not_required=not_null_not_required, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - not_null_required: datetime.datetime, - null_required: Union[None, datetime.datetime], - null_not_required: Union[None, Unset, datetime.datetime] = UNSET, - not_null_not_required: Union[Unset, datetime.datetime] = UNSET, -) -> Response[Any]: - """ - Args: - not_null_required (datetime.datetime): - null_required (Union[None, datetime.datetime]): - null_not_required (Union[None, Unset, datetime.datetime]): - not_null_not_required (Union[Unset, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - not_null_required=not_null_required, - null_required=null_required, - null_not_required=null_not_required, - not_null_not_required=not_null_not_required, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py deleted file mode 100644 index a0caba2d6..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/hyphen_in_path.py +++ /dev/null @@ -1,91 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs( - hyphen_in_path: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/naming/{hyphen_in_path}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - hyphen_in_path: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Args: - hyphen_in_path (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - hyphen_in_path=hyphen_in_path, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - hyphen_in_path: str, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Args: - hyphen_in_path (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - hyphen_in_path=hyphen_in_path, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py deleted file mode 100644 index 7df2d318f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/mixed_case.py +++ /dev/null @@ -1,169 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.mixed_case_response_200 import MixedCaseResponse200 -from ...types import UNSET, Response - - -def _get_kwargs( - *, - mixed_case: str, - mixedCase: str, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["mixed_case"] = mixed_case - - params["mixedCase"] = mixedCase - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/naming/mixed-case", - "params": params, - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[MixedCaseResponse200]: - if response.status_code == 200: - response_200 = MixedCaseResponse200.from_dict(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[MixedCaseResponse200]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - mixed_case: str, - mixedCase: str, -) -> Response[MixedCaseResponse200]: - """ - Args: - mixed_case (str): - mixedCase (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MixedCaseResponse200] - """ - - kwargs = _get_kwargs( - mixed_case=mixed_case, - mixedCase=mixedCase, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - mixed_case: str, - mixedCase: str, -) -> Optional[MixedCaseResponse200]: - """ - Args: - mixed_case (str): - mixedCase (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MixedCaseResponse200 - """ - - return sync_detailed( - client=client, - mixed_case=mixed_case, - mixedCase=mixedCase, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - mixed_case: str, - mixedCase: str, -) -> Response[MixedCaseResponse200]: - """ - Args: - mixed_case (str): - mixedCase (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MixedCaseResponse200] - """ - - kwargs = _get_kwargs( - mixed_case=mixed_case, - mixedCase=mixedCase, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - mixed_case: str, - mixedCase: str, -) -> Optional[MixedCaseResponse200]: - """ - Args: - mixed_case (str): - mixedCase (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MixedCaseResponse200 - """ - - return ( - await asyncio_detailed( - client=client, - mixed_case=mixed_case, - mixedCase=mixedCase, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py deleted file mode 100644 index 3bb8b698b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py +++ /dev/null @@ -1,158 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody -from ...models.post_naming_property_conflict_with_import_response_200 import ( - PostNamingPropertyConflictWithImportResponse200, -) -from ...types import Response - - -def _get_kwargs( - *, - body: PostNamingPropertyConflictWithImportBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/naming/property-conflict-with-import", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PostNamingPropertyConflictWithImportResponse200]: - if response.status_code == 200: - response_200 = PostNamingPropertyConflictWithImportResponse200.from_dict(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PostNamingPropertyConflictWithImportResponse200]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: PostNamingPropertyConflictWithImportBody, -) -> Response[PostNamingPropertyConflictWithImportResponse200]: - """ - Args: - body (PostNamingPropertyConflictWithImportBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[PostNamingPropertyConflictWithImportResponse200] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: PostNamingPropertyConflictWithImportBody, -) -> Optional[PostNamingPropertyConflictWithImportResponse200]: - """ - Args: - body (PostNamingPropertyConflictWithImportBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - PostNamingPropertyConflictWithImportResponse200 - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: PostNamingPropertyConflictWithImportBody, -) -> Response[PostNamingPropertyConflictWithImportResponse200]: - """ - Args: - body (PostNamingPropertyConflictWithImportBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[PostNamingPropertyConflictWithImportResponse200] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: PostNamingPropertyConflictWithImportBody, -) -> Optional[PostNamingPropertyConflictWithImportResponse200]: - """ - Args: - body (PostNamingPropertyConflictWithImportBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - PostNamingPropertyConflictWithImportResponse200 - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py deleted file mode 100644 index e7a8e2712..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ /dev/null @@ -1,141 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - path_param: str, - *, - string_param: Union[Unset, str] = UNSET, - integer_param: Union[Unset, int] = 0, - header_param: Union[None, Unset, str] = UNSET, - cookie_param: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - if not isinstance(header_param, Unset): - headers["header param"] = header_param - - cookies = {} - if cookie_param is not UNSET: - cookies["cookie param"] = cookie_param - - params: dict[str, Any] = {} - - params["string param"] = string_param - - params["integer param"] = integer_param - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/parameter-references/{path_param}", - "params": params, - "cookies": cookies, - } - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - path_param: str, - *, - client: Union[AuthenticatedClient, Client], - string_param: Union[Unset, str] = UNSET, - integer_param: Union[Unset, int] = 0, - header_param: Union[None, Unset, str] = UNSET, - cookie_param: Union[Unset, str] = UNSET, -) -> Response[Any]: - """Test different types of parameter references - - Args: - path_param (str): - string_param (Union[Unset, str]): - integer_param (Union[Unset, int]): Default: 0. - header_param (Union[None, Unset, str]): - cookie_param (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - path_param=path_param, - string_param=string_param, - integer_param=integer_param, - header_param=header_param, - cookie_param=cookie_param, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - path_param: str, - *, - client: Union[AuthenticatedClient, Client], - string_param: Union[Unset, str] = UNSET, - integer_param: Union[Unset, int] = 0, - header_param: Union[None, Unset, str] = UNSET, - cookie_param: Union[Unset, str] = UNSET, -) -> Response[Any]: - """Test different types of parameter references - - Args: - path_param (str): - string_param (Union[Unset, str]): - integer_param (Union[Unset, int]): Default: 0. - header_param (Union[None, Unset, str]): - cookie_param (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - path_param=path_param, - string_param=string_param, - integer_param=integer_param, - header_param=header_param, - cookie_param=cookie_param, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py deleted file mode 100644 index 704996107..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ /dev/null @@ -1,106 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - param_path: str, - *, - param_query: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["param"] = param_query - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "delete", - "url": f"/common_parameters_overriding/{param_path}", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - param_query: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - param_path (str): - param_query (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - param_query: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - param_path (str): - param_query (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py deleted file mode 100644 index b6efbba9b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ /dev/null @@ -1,110 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response - - -def _get_kwargs( - param_path: str, - *, - param_query: str = "overridden_in_GET", -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["param"] = param_query - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/common_parameters_overriding/{param_path}", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - 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. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - 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. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py deleted file mode 100644 index 6a7ed7fd5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ /dev/null @@ -1,130 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response, Unset - - -def _get_kwargs( - param_path: str, - *, - param_query: Union[Unset, str] = UNSET, - param_header: Union[Unset, str] = UNSET, - param_cookie: Union[Unset, str] = UNSET, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - if not isinstance(param_header, Unset): - headers["param"] = param_header - - cookies = {} - if param_cookie is not UNSET: - cookies["param"] = param_cookie - - params: dict[str, Any] = {} - - params["param"] = param_query - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/same-name-multiple-locations/{param_path}", - "params": params, - "cookies": cookies, - } - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - param_query: Union[Unset, str] = UNSET, - param_header: Union[Unset, str] = UNSET, - param_cookie: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - param_path (str): - param_query (Union[Unset, str]): - param_header (Union[Unset, str]): - param_cookie (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - param_header=param_header, - param_cookie=param_cookie, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - param_path: str, - *, - client: Union[AuthenticatedClient, Client], - param_query: Union[Unset, str] = UNSET, - param_header: Union[Unset, str] = UNSET, - param_cookie: Union[Unset, str] = UNSET, -) -> Response[Any]: - """ - Args: - param_path (str): - param_query (Union[Unset, str]): - param_header (Union[Unset, str]): - param_cookie (Union[Unset, str]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param_path=param_path, - param_query=param_query, - param_header=param_header, - param_cookie=param_cookie, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py deleted file mode 100644 index 44345aa26..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ /dev/null @@ -1,112 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs( - param4: str, - param2: int, - param1: str, - param3: int, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - param4: str, - param2: int, - param1: str, - param3: int, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Args: - param4 (str): - param2 (int): - param1 (str): - param3 (int): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param4=param4, - param2=param2, - param1=param1, - param3=param3, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - param4: str, - param2: int, - param1: str, - param3: int, - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Args: - param4 (str): - param2 (int): - param1 (str): - param3 (int): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - param4=param4, - param2=param2, - param1=param1, - param3=param3, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py deleted file mode 100644 index cf0599306..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ /dev/null @@ -1,128 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.post_responses_unions_simple_before_complex_response_200 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200, -) -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/responses/unions/simple_before_complex", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: - if response.status_code == 200: - response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: - """Regression test for #603 - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[PostResponsesUnionsSimpleBeforeComplexResponse200] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: - """Regression test for #603 - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - PostResponsesUnionsSimpleBeforeComplexResponse200 - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]: - """Regression test for #603 - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[PostResponsesUnionsSimpleBeforeComplexResponse200] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: - """Regression test for #603 - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - PostResponsesUnionsSimpleBeforeComplexResponse200 - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py deleted file mode 100644 index 057ceb2de..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/responses/text_response.py +++ /dev/null @@ -1,120 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/responses/text", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: - if response.status_code == 200: - response_200 = response.text - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[str]: - """Text Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[str] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[str]: - """Text Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - str - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[str]: - """Text Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[str] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[str]: - """Text Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - str - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py deleted file mode 100644 index 62631355f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ /dev/null @@ -1,77 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tag_with_number", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py deleted file mode 100644 index 62631355f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tag2/get_tag_with_number.py +++ /dev/null @@ -1,77 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tag_with_number", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """ - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py deleted file mode 100644 index 0852815d2..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/callback_test.py +++ /dev/null @@ -1,171 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.a_model import AModel -from ...models.http_validation_error import HTTPValidationError -from ...types import Response - - -def _get_kwargs( - *, - body: AModel, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/callback", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == 200: - response_200 = response.json() - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Union[Any, HTTPValidationError]]: - """Path with callback - - Try sending a request related to a callback - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Optional[Union[Any, HTTPValidationError]]: - """Path with callback - - Try sending a request related to a callback - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Union[Any, HTTPValidationError]]: - """Path with callback - - Try sending a request related to a callback - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Optional[Union[Any, HTTPValidationError]]: - """Path with callback - - Try sending a request related to a callback - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py deleted file mode 100644 index e7cd44f70..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ /dev/null @@ -1,83 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/description-with-backslash", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - r""" Test description with \ - - Test description with \ - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - r""" Test description with \ - - Test description with \ - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py deleted file mode 100644 index 147eed3a7..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ /dev/null @@ -1,129 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/basic_lists/booleans", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[bool]]: - if response.status_code == 200: - response_200 = cast(list[bool], response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[bool]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[bool]]: - """Get Basic List Of Booleans - - Get a list of booleans - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[bool]] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[bool]]: - """Get Basic List Of Booleans - - Get a list of booleans - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[bool] - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[bool]]: - """Get Basic List Of Booleans - - Get a list of booleans - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[bool]] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[bool]]: - """Get Basic List Of Booleans - - Get a list of booleans - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[bool] - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py deleted file mode 100644 index 02b3abb1f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ /dev/null @@ -1,129 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/basic_lists/floats", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[float]]: - if response.status_code == 200: - response_200 = cast(list[float], response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[float]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[float]]: - """Get Basic List Of Floats - - Get a list of floats - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[float]] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[float]]: - """Get Basic List Of Floats - - Get a list of floats - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[float] - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[float]]: - """Get Basic List Of Floats - - Get a list of floats - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[float]] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[float]]: - """Get Basic List Of Floats - - Get a list of floats - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[float] - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py deleted file mode 100644 index e71537363..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ /dev/null @@ -1,129 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/basic_lists/integers", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[int]]: - if response.status_code == 200: - response_200 = cast(list[int], response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[int]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[int]]: - """Get Basic List Of Integers - - Get a list of integers - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[int]] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[int]]: - """Get Basic List Of Integers - - Get a list of integers - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[int] - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[int]]: - """Get Basic List Of Integers - - Get a list of integers - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[int]] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[int]]: - """Get Basic List Of Integers - - Get a list of integers - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[int] - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py deleted file mode 100644 index 70f153829..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ /dev/null @@ -1,129 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/basic_lists/strings", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: - if response.status_code == 200: - response_200 = cast(list[str], response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[str]]: - """Get Basic List Of Strings - - Get a list of strings - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[str]] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[str]]: - """Get Basic List Of Strings - - Get a list of strings - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[str] - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[list[str]]: - """Get Basic List Of Strings - - Get a list of strings - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[list[str]] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[list[str]]: - """Get Basic List Of Strings - - Get a list of strings - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - list[str] - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py deleted file mode 100644 index a708cf71d..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/get_user_list.py +++ /dev/null @@ -1,250 +0,0 @@ -import datetime -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.a_model import AModel -from ...models.an_enum import AnEnum -from ...models.an_enum_with_null import AnEnumWithNull -from ...models.http_validation_error import HTTPValidationError -from ...types import UNSET, Response - - -def _get_kwargs( - *, - an_enum_value: list[AnEnum], - an_enum_value_with_null: list[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: list[None], - some_date: Union[datetime.date, datetime.datetime], -) -> dict[str, Any]: - params: dict[str, Any] = {} - - json_an_enum_value = [] - for an_enum_value_item_data in an_enum_value: - an_enum_value_item = an_enum_value_item_data.value - json_an_enum_value.append(an_enum_value_item) - - params["an_enum_value"] = json_an_enum_value - - json_an_enum_value_with_null = [] - for an_enum_value_with_null_item_data in an_enum_value_with_null: - an_enum_value_with_null_item: Union[None, str] - if isinstance(an_enum_value_with_null_item_data, AnEnumWithNull): - an_enum_value_with_null_item = an_enum_value_with_null_item_data.value - else: - an_enum_value_with_null_item = an_enum_value_with_null_item_data - json_an_enum_value_with_null.append(an_enum_value_with_null_item) - - params["an_enum_value_with_null"] = json_an_enum_value_with_null - - json_an_enum_value_with_only_null = an_enum_value_with_only_null - - params["an_enum_value_with_only_null"] = json_an_enum_value_with_only_null - - json_some_date: str - if isinstance(some_date, datetime.date): - json_some_date = some_date.isoformat() - else: - json_some_date = some_date.isoformat() - - params["some_date"] = json_some_date - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/", - "params": params, - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[HTTPValidationError, list["AModel"]]]: - if response.status_code == 200: - response_200 = [] - _response_200 = response.json() - for response_200_item_data in _response_200: - response_200_item = AModel.from_dict(response_200_item_data) - - response_200.append(response_200_item) - - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if response.status_code == 423: - response_423 = HTTPValidationError.from_dict(response.json()) - - return response_423 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[HTTPValidationError, list["AModel"]]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - an_enum_value: list[AnEnum], - an_enum_value_with_null: list[Union[AnEnumWithNull, None]], - 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[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (list[None]): - some_date (Union[datetime.date, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, list['AModel']]] - """ - - kwargs = _get_kwargs( - an_enum_value=an_enum_value, - an_enum_value_with_null=an_enum_value_with_null, - an_enum_value_with_only_null=an_enum_value_with_only_null, - some_date=some_date, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - an_enum_value: list[AnEnum], - an_enum_value_with_null: list[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: list[None], - some_date: Union[datetime.date, datetime.datetime], -) -> Optional[Union[HTTPValidationError, list["AModel"]]]: - """Get List - - Get a list of things - - Args: - an_enum_value (list[AnEnum]): - an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (list[None]): - some_date (Union[datetime.date, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, list['AModel']] - """ - - return sync_detailed( - client=client, - an_enum_value=an_enum_value, - an_enum_value_with_null=an_enum_value_with_null, - an_enum_value_with_only_null=an_enum_value_with_only_null, - some_date=some_date, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - an_enum_value: list[AnEnum], - an_enum_value_with_null: list[Union[AnEnumWithNull, None]], - 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[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (list[None]): - some_date (Union[datetime.date, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, list['AModel']]] - """ - - kwargs = _get_kwargs( - an_enum_value=an_enum_value, - an_enum_value_with_null=an_enum_value_with_null, - an_enum_value_with_only_null=an_enum_value_with_only_null, - some_date=some_date, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - an_enum_value: list[AnEnum], - an_enum_value_with_null: list[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: list[None], - some_date: Union[datetime.date, datetime.datetime], -) -> Optional[Union[HTTPValidationError, list["AModel"]]]: - """Get List - - Get a list of things - - Args: - an_enum_value (list[AnEnum]): - an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (list[None]): - some_date (Union[datetime.date, datetime.datetime]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, list['AModel']] - """ - - return ( - await asyncio_detailed( - client=client, - an_enum_value=an_enum_value, - an_enum_value_with_null=an_enum_value_with_null, - an_enum_value_with_only_null=an_enum_value_with_only_null, - some_date=some_date, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py deleted file mode 100644 index f33a23dc7..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ /dev/null @@ -1,171 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.a_model import AModel -from ...models.http_validation_error import HTTPValidationError -from ...types import Response - - -def _get_kwargs( - *, - body: AModel, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/json_body", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == 200: - response_200 = response.json() - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Union[Any, HTTPValidationError]]: - """Json Body - - Try sending a JSON body - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Optional[Union[Any, HTTPValidationError]]: - """Json Body - - Try sending a JSON body - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Response[Union[Any, HTTPValidationError]]: - """Json Body - - Try sending a JSON body - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: AModel, -) -> Optional[Union[Any, HTTPValidationError]]: - """Json Body - - Try sending a JSON body - - Args: - body (AModel): A Model for testing all the ways custom objects can be used - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py deleted file mode 100644 index 586947f49..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ /dev/null @@ -1,79 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/no_response", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """No Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """No Response - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py deleted file mode 100644 index efb0f4ae5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ /dev/null @@ -1,122 +0,0 @@ -from http import HTTPStatus -from io import BytesIO -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import File, Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/octet_stream", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[File]: - if response.status_code == 200: - response_200 = File(payload=BytesIO(response.content)) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[File]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[File]: - """Octet Stream - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[File] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[File]: - """Octet Stream - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - File - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[File]: - """Octet Stream - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[File] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], -) -> Optional[File]: - """Octet Stream - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - File - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py deleted file mode 100644 index ea0cbd65a..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py +++ /dev/null @@ -1,162 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError -from ...types import File, Response - - -def _get_kwargs( - *, - body: File, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/octet_stream", - } - - _body = body.payload - - _kwargs["content"] = _body - headers["Content-Type"] = "application/octet-stream" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: - if response.status_code == 200: - response_200 = cast(str, response.json()) - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: File, -) -> Response[Union[HTTPValidationError, str]]: - """Binary (octet stream) request body - - Args: - body (File): A file to upload - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, str]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: File, -) -> Optional[Union[HTTPValidationError, str]]: - """Binary (octet stream) request body - - Args: - body (File): A file to upload - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, str] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: File, -) -> Response[Union[HTTPValidationError, str]]: - """Binary (octet stream) request body - - Args: - body (File): A file to upload - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, str]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: File, -) -> Optional[Union[HTTPValidationError, str]]: - """Binary (octet stream) request body - - Args: - body (File): A file to upload - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, str] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py deleted file mode 100644 index ec65d0363..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data.py +++ /dev/null @@ -1,107 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.a_form_data import AFormData -from ...types import Response - - -def _get_kwargs( - *, - body: AFormData, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/post_form_data", - } - - _body = body.to_dict() - - _kwargs["data"] = _body - headers["Content-Type"] = "application/x-www-form-urlencoded" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AFormData, -) -> Response[Any]: - """Post form data - - Post form data - - Args: - body (AFormData): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: AFormData, -) -> Response[Any]: - """Post form data - - Post form data - - Args: - body (AFormData): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py deleted file mode 100644 index bc5ad7cc4..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ /dev/null @@ -1,107 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.post_form_data_inline_body import PostFormDataInlineBody -from ...types import Response - - -def _get_kwargs( - *, - body: PostFormDataInlineBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/post_form_data_inline", - } - - _body = body.to_dict() - - _kwargs["data"] = _body - headers["Content-Type"] = "application/x-www-form-urlencoded" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: PostFormDataInlineBody, -) -> Response[Any]: - """Post form data (inline schema) - - Post form data (inline schema) - - Args: - body (PostFormDataInlineBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: PostFormDataInlineBody, -) -> Response[Any]: - """Post form data (inline schema) - - Post form data (inline schema) - - Args: - body (PostFormDataInlineBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py deleted file mode 100644 index ba40de26f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ /dev/null @@ -1,162 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union, cast - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError -from ...types import Response - - -def _get_kwargs( - *, - body: str, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/json_body/string", - } - - _body = body - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[HTTPValidationError, str]]: - if response.status_code == 200: - response_200 = cast(str, response.json()) - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[HTTPValidationError, str]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Response[Union[HTTPValidationError, str]]: - """Json Body Which is String - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, str]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Optional[Union[HTTPValidationError, str]]: - """Json Body Which is String - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, str] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Response[Union[HTTPValidationError, str]]: - """Json Body Which is String - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[HTTPValidationError, str]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: str, -) -> Optional[Union[HTTPValidationError, str]]: - """Json Body Which is String - - Args: - body (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[HTTPValidationError, str] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py deleted file mode 100644 index 287ea4a1a..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ /dev/null @@ -1,160 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.test_inline_objects_body import TestInlineObjectsBody -from ...models.test_inline_objects_response_200 import TestInlineObjectsResponse200 -from ...types import Response - - -def _get_kwargs( - *, - body: TestInlineObjectsBody, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/inline_objects", - } - - _body = body.to_dict() - - _kwargs["json"] = _body - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[TestInlineObjectsResponse200]: - if response.status_code == 200: - response_200 = TestInlineObjectsResponse200.from_dict(response.json()) - - return response_200 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[TestInlineObjectsResponse200]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: TestInlineObjectsBody, -) -> Response[TestInlineObjectsResponse200]: - """Test Inline Objects - - Args: - body (TestInlineObjectsBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[TestInlineObjectsResponse200] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: TestInlineObjectsBody, -) -> Optional[TestInlineObjectsResponse200]: - """Test Inline Objects - - Args: - body (TestInlineObjectsBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - TestInlineObjectsResponse200 - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: TestInlineObjectsBody, -) -> Response[TestInlineObjectsResponse200]: - """Test Inline Objects - - Args: - body (TestInlineObjectsBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[TestInlineObjectsResponse200] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: TestInlineObjectsBody, -) -> Optional[TestInlineObjectsResponse200]: - """Test Inline Objects - - Args: - body (TestInlineObjectsBody): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - TestInlineObjectsResponse200 - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py deleted file mode 100644 index 22ac00650..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ /dev/null @@ -1,104 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs( - *, - my_token: str, -) -> dict[str, Any]: - cookies = {} - cookies["MyToken"] = my_token - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/auth/token_with_cookie", - "cookies": cookies, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if response.status_code == 401: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - my_token: str, -) -> Response[Any]: - """TOKEN_WITH_COOKIE - - Test optional cookie parameters - - Args: - my_token (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - my_token=my_token, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - my_token: str, -) -> Response[Any]: - """TOKEN_WITH_COOKIE - - Test optional cookie parameters - - Args: - my_token (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - my_token=my_token, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py deleted file mode 100644 index 61e8434e6..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ /dev/null @@ -1,79 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/tests/unsupported_content", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """Unsupported Content - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], -) -> Response[Any]: - """Unsupported Content - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py deleted file mode 100644 index 9f1864ec3..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ /dev/null @@ -1,170 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost -from ...models.http_validation_error import HTTPValidationError -from ...types import Response - - -def _get_kwargs( - *, - body: BodyUploadFileTestsUploadPost, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/upload", - } - - _body = body.to_multipart() - - _kwargs["files"] = _body - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == 200: - response_200 = response.json() - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: BodyUploadFileTestsUploadPost, -) -> Response[Union[Any, HTTPValidationError]]: - """Upload File - - Upload a file - - Args: - body (BodyUploadFileTestsUploadPost): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: BodyUploadFileTestsUploadPost, -) -> Optional[Union[Any, HTTPValidationError]]: - """Upload File - - Upload a file - - Args: - body (BodyUploadFileTestsUploadPost): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: BodyUploadFileTestsUploadPost, -) -> Response[Union[Any, HTTPValidationError]]: - """Upload File - - Upload a file - - Args: - body (BodyUploadFileTestsUploadPost): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: BodyUploadFileTestsUploadPost, -) -> Optional[Union[Any, HTTPValidationError]]: - """Upload File - - Upload a file - - Args: - body (BodyUploadFileTestsUploadPost): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py deleted file mode 100644 index 3f8edc817..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ /dev/null @@ -1,173 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError -from ...types import File, Response - - -def _get_kwargs( - *, - body: list[File], -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/tests/upload/multiple", - } - - _body = [] - for body_item_data in body: - body_item = body_item_data.to_tuple() - - _body.append(body_item) - - _kwargs["files"] = _body - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, HTTPValidationError]]: - if response.status_code == 200: - response_200 = response.json() - return response_200 - if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) - - return response_422 - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, HTTPValidationError]]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list[File], -) -> Response[Union[Any, HTTPValidationError]]: - """Upload multiple files - - Upload several files in the same request - - Args: - body (list[File]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: Union[AuthenticatedClient, Client], - body: list[File], -) -> Optional[Union[Any, HTTPValidationError]]: - """Upload multiple files - - Upload several files in the same request - - Args: - body (list[File]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - body: list[File], -) -> Response[Union[Any, HTTPValidationError]]: - """Upload multiple files - - Upload several files in the same request - - Args: - body (list[File]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Union[Any, HTTPValidationError]] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: Union[AuthenticatedClient, Client], - body: list[File], -) -> Optional[Union[Any, HTTPValidationError]]: - """Upload multiple files - - Upload several files in the same request - - Args: - body (list[File]): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Union[Any, HTTPValidationError] - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py deleted file mode 100644 index b46550153..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/api/true_/false_.py +++ /dev/null @@ -1,99 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...types import UNSET, Response - - -def _get_kwargs( - *, - import_: str, -) -> dict[str, Any]: - params: dict[str, Any] = {} - - params["import"] = import_ - - params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/naming/keywords", - "params": params, - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: - if response.status_code == 200: - return None - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: Union[AuthenticatedClient, Client], - import_: str, -) -> Response[Any]: - """ - Args: - import_ (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - import_=import_, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -async def asyncio_detailed( - *, - client: Union[AuthenticatedClient, Client], - import_: str, -) -> Response[Any]: - """ - Args: - import_ (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Any] - """ - - kwargs = _get_kwargs( - import_=import_, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py index f354c31c7..3f5aca91f 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/__init__.py @@ -1,171 +1,9 @@ """Contains all the data models used in inputs/outputs""" -from .a_discriminated_union_type_1 import ADiscriminatedUnionType1 -from .a_discriminated_union_type_2 import ADiscriminatedUnionType2 -from .a_form_data import AFormData -from .a_model import AModel -from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject -from .all_of_has_properties_but_no_type import AllOfHasPropertiesButNoType -from .all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum -from .all_of_sub_model import AllOfSubModel -from .all_of_sub_model_type_enum import AllOfSubModelTypeEnum -from .an_all_of_enum import AnAllOfEnum -from .an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem -from .an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, -) -from .an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, -) -from .an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem -from .an_array_with_a_recursive_ref_in_items_object_additional_properties_item import ( - AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem, -) -from .an_array_with_a_recursive_ref_in_items_object_item import AnArrayWithARecursiveRefInItemsObjectItem -from .an_enum import AnEnum -from .an_enum_with_null import AnEnumWithNull -from .an_int_enum import AnIntEnum -from .another_all_of_sub_model import AnotherAllOfSubModel -from .another_all_of_sub_model_type import AnotherAllOfSubModelType -from .another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum -from .body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost -from .body_upload_file_tests_upload_post_additional_property import BodyUploadFileTestsUploadPostAdditionalProperty -from .body_upload_file_tests_upload_post_some_nullable_object import BodyUploadFileTestsUploadPostSomeNullableObject -from .body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject -from .body_upload_file_tests_upload_post_some_optional_object import BodyUploadFileTestsUploadPostSomeOptionalObject -from .different_enum import DifferentEnum -from .extended import Extended -from .free_form_model import FreeFormModel -from .get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from .get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader -from .get_models_allof_response_200 import GetModelsAllofResponse200 -from .get_models_oneof_with_required_const_response_200_type_0 import GetModelsOneofWithRequiredConstResponse200Type0 -from .get_models_oneof_with_required_const_response_200_type_1 import GetModelsOneofWithRequiredConstResponse200Type1 -from .http_validation_error import HTTPValidationError -from .import_ import Import -from .json_like_body import JsonLikeBody -from .mixed_case_response_200 import MixedCaseResponse200 -from .model_from_all_of import ModelFromAllOf -from .model_name import ModelName -from .model_reference_with_periods import ModelReferenceWithPeriods -from .model_with_additional_properties_inlined import ModelWithAdditionalPropertiesInlined -from .model_with_additional_properties_inlined_additional_property import ( - ModelWithAdditionalPropertiesInlinedAdditionalProperty, -) -from .model_with_additional_properties_refed import ModelWithAdditionalPropertiesRefed -from .model_with_any_json_properties import ModelWithAnyJsonProperties -from .model_with_any_json_properties_additional_property_type_0 import ModelWithAnyJsonPropertiesAdditionalPropertyType0 -from .model_with_backslash_in_description import ModelWithBackslashInDescription -from .model_with_circular_ref_a import ModelWithCircularRefA -from .model_with_circular_ref_b import ModelWithCircularRefB -from .model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA -from .model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB -from .model_with_date_time_property import ModelWithDateTimeProperty -from .model_with_discriminated_union import ModelWithDiscriminatedUnion -from .model_with_merged_properties import ModelWithMergedProperties -from .model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum -from .model_with_no_properties import ModelWithNoProperties -from .model_with_primitive_additional_properties import ModelWithPrimitiveAdditionalProperties -from .model_with_primitive_additional_properties_a_date_holder import ModelWithPrimitiveAdditionalPropertiesADateHolder -from .model_with_property_ref import ModelWithPropertyRef -from .model_with_recursive_ref import ModelWithRecursiveRef -from .model_with_recursive_ref_in_additional_properties import ModelWithRecursiveRefInAdditionalProperties -from .model_with_union_property import ModelWithUnionProperty -from .model_with_union_property_inlined import ModelWithUnionPropertyInlined -from .model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 -from .model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 -from .none import None_ -from .post_bodies_multiple_data_body import PostBodiesMultipleDataBody -from .post_bodies_multiple_files_body import PostBodiesMultipleFilesBody -from .post_bodies_multiple_json_body import PostBodiesMultipleJsonBody -from .post_form_data_inline_body import PostFormDataInlineBody -from .post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody -from .post_naming_property_conflict_with_import_response_200 import PostNamingPropertyConflictWithImportResponse200 -from .post_responses_unions_simple_before_complex_response_200 import PostResponsesUnionsSimpleBeforeComplexResponse200 -from .post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, -) -from .test_inline_objects_body import TestInlineObjectsBody -from .test_inline_objects_response_200 import TestInlineObjectsResponse200 -from .validation_error import ValidationError +from .model_with_description import ModelWithDescription +from .model_with_no_description import ModelWithNoDescription __all__ = ( - "ADiscriminatedUnionType1", - "ADiscriminatedUnionType2", - "AFormData", - "AllOfHasPropertiesButNoType", - "AllOfHasPropertiesButNoTypeTypeEnum", - "AllOfSubModel", - "AllOfSubModelTypeEnum", - "AModel", - "AModelWithPropertiesReferenceThatAreNotObject", - "AnAllOfEnum", - "AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem", - "AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem", - "AnArrayWithACircularRefInItemsObjectAItem", - "AnArrayWithACircularRefInItemsObjectBItem", - "AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem", - "AnArrayWithARecursiveRefInItemsObjectItem", - "AnEnum", - "AnEnumWithNull", - "AnIntEnum", - "AnotherAllOfSubModel", - "AnotherAllOfSubModelType", - "AnotherAllOfSubModelTypeEnum", - "BodyUploadFileTestsUploadPost", - "BodyUploadFileTestsUploadPostAdditionalProperty", - "BodyUploadFileTestsUploadPostSomeNullableObject", - "BodyUploadFileTestsUploadPostSomeObject", - "BodyUploadFileTestsUploadPostSomeOptionalObject", - "DifferentEnum", - "Extended", - "FreeFormModel", - "GetLocationHeaderTypesIntEnumHeader", - "GetLocationHeaderTypesStringEnumHeader", - "GetModelsAllofResponse200", - "GetModelsOneofWithRequiredConstResponse200Type0", - "GetModelsOneofWithRequiredConstResponse200Type1", - "HTTPValidationError", - "Import", - "JsonLikeBody", - "MixedCaseResponse200", - "ModelFromAllOf", - "ModelName", - "ModelReferenceWithPeriods", - "ModelWithAdditionalPropertiesInlined", - "ModelWithAdditionalPropertiesInlinedAdditionalProperty", - "ModelWithAdditionalPropertiesRefed", - "ModelWithAnyJsonProperties", - "ModelWithAnyJsonPropertiesAdditionalPropertyType0", - "ModelWithBackslashInDescription", - "ModelWithCircularRefA", - "ModelWithCircularRefB", - "ModelWithCircularRefInAdditionalPropertiesA", - "ModelWithCircularRefInAdditionalPropertiesB", - "ModelWithDateTimeProperty", - "ModelWithDiscriminatedUnion", - "ModelWithMergedProperties", - "ModelWithMergedPropertiesStringToEnum", - "ModelWithNoProperties", - "ModelWithPrimitiveAdditionalProperties", - "ModelWithPrimitiveAdditionalPropertiesADateHolder", - "ModelWithPropertyRef", - "ModelWithRecursiveRef", - "ModelWithRecursiveRefInAdditionalProperties", - "ModelWithUnionProperty", - "ModelWithUnionPropertyInlined", - "ModelWithUnionPropertyInlinedFruitType0", - "ModelWithUnionPropertyInlinedFruitType1", - "None_", - "PostBodiesMultipleDataBody", - "PostBodiesMultipleFilesBody", - "PostBodiesMultipleJsonBody", - "PostFormDataInlineBody", - "PostNamingPropertyConflictWithImportBody", - "PostNamingPropertyConflictWithImportResponse200", - "PostResponsesUnionsSimpleBeforeComplexResponse200", - "PostResponsesUnionsSimpleBeforeComplexResponse200AType1", - "TestInlineObjectsBody", - "TestInlineObjectsResponse200", - "ValidationError", + "ModelWithDescription", + "ModelWithNoDescription", ) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py deleted file mode 100644 index 3fdcc28f9..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_1.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ADiscriminatedUnionType1") - - -@_attrs_define -class ADiscriminatedUnionType1: - model_type: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - model_type = self.model_type - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if model_type is not UNSET: - field_dict["modelType"] = model_type - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_type = d.pop("modelType", UNSET) - - a_discriminated_union_type_1 = cls( - model_type=model_type, - ) - - a_discriminated_union_type_1.additional_properties = d - return a_discriminated_union_type_1 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py deleted file mode 100644 index c2175cb92..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_discriminated_union_type_2.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ADiscriminatedUnionType2") - - -@_attrs_define -class ADiscriminatedUnionType2: - model_type: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - model_type = self.model_type - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if model_type is not UNSET: - field_dict["modelType"] = model_type - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_type = d.pop("modelType", UNSET) - - a_discriminated_union_type_2 = cls( - model_type=model_type, - ) - - a_discriminated_union_type_2.additional_properties = d - return a_discriminated_union_type_2 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py deleted file mode 100644 index dfe24eda5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_form_data.py +++ /dev/null @@ -1,63 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AFormData") - - -@_attrs_define -class AFormData: - an_required_field: str - an_optional_field: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - an_required_field = self.an_required_field - - an_optional_field = self.an_optional_field - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "an_required_field": an_required_field, - } - ) - if an_optional_field is not UNSET: - field_dict["an_optional_field"] = an_optional_field - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - an_required_field = d.pop("an_required_field") - - an_optional_field = d.pop("an_optional_field", UNSET) - - a_form_data = cls( - an_required_field=an_required_field, - an_optional_field=an_optional_field, - ) - - a_form_data.additional_properties = d - return a_form_data - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py deleted file mode 100644 index d819efeb0..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model.py +++ /dev/null @@ -1,508 +0,0 @@ -import datetime -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast -from uuid import UUID - -from attrs import define as _attrs_define -from dateutil.parser import isoparse - -from ..models.an_all_of_enum import AnAllOfEnum -from ..models.an_enum import AnEnum -from ..models.different_enum import DifferentEnum -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - -T = TypeVar("T", bound="AModel") - - -@_attrs_define -class AModel: - """A Model for testing all the ways custom objects can be used""" - - an_enum_value: AnEnum - """ For testing Enums in all the ways they can be used """ - a_camel_date_time: Union[datetime.date, datetime.datetime] - a_date: datetime.date - a_nullable_date: Union[None, datetime.date] - a_uuid: UUID - required_nullable: Union[None, str] - required_not_nullable: str - one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Any] - nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None] - model: "ModelWithUnionProperty" - nullable_model: Union["ModelWithUnionProperty", None] - an_allof_enum_with_overridden_default: AnAllOfEnum = AnAllOfEnum.OVERRIDDEN_DEFAULT - a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") - any_value: Union[Unset, Any] = "default" - an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET - a_not_required_date: Union[Unset, datetime.date] = UNSET - a_not_required_uuid: Union[Unset, UUID] = UNSET - attr_1_leading_digit: Union[Unset, str] = UNSET - attr_leading_underscore: Union[Unset, str] = UNSET - not_required_nullable: Union[None, Unset, str] = UNSET - not_required_not_nullable: Union[Unset, str] = UNSET - not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET - not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET - not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET - not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET - - def to_dict(self) -> dict[str, Any]: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - an_enum_value = self.an_enum_value.value - - an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value - - a_camel_date_time: str - if isinstance(self.a_camel_date_time, datetime.datetime): - a_camel_date_time = self.a_camel_date_time.isoformat() - else: - a_camel_date_time = self.a_camel_date_time.isoformat() - - a_date = self.a_date.isoformat() - - a_nullable_date: Union[None, str] - if isinstance(self.a_nullable_date, datetime.date): - a_nullable_date = self.a_nullable_date.isoformat() - else: - a_nullable_date = self.a_nullable_date - - a_uuid = str(self.a_uuid) - - a_nullable_uuid: Union[None, str] - if isinstance(self.a_nullable_uuid, UUID): - a_nullable_uuid = str(self.a_nullable_uuid) - else: - a_nullable_uuid = self.a_nullable_uuid - - required_nullable: Union[None, str] - required_nullable = self.required_nullable - - required_not_nullable = self.required_not_nullable - - one_of_models: Union[Any, dict[str, Any]] - if isinstance(self.one_of_models, FreeFormModel): - one_of_models = self.one_of_models.to_dict() - elif isinstance(self.one_of_models, ModelWithUnionProperty): - one_of_models = self.one_of_models.to_dict() - else: - one_of_models = self.one_of_models - - nullable_one_of_models: Union[None, dict[str, Any]] - if isinstance(self.nullable_one_of_models, FreeFormModel): - nullable_one_of_models = self.nullable_one_of_models.to_dict() - elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): - nullable_one_of_models = self.nullable_one_of_models.to_dict() - else: - nullable_one_of_models = self.nullable_one_of_models - - model = self.model.to_dict() - - nullable_model: Union[None, dict[str, Any]] - if isinstance(self.nullable_model, ModelWithUnionProperty): - nullable_model = self.nullable_model.to_dict() - else: - nullable_model = self.nullable_model - - any_value = self.any_value - - an_optional_allof_enum: Union[Unset, str] = UNSET - if not isinstance(self.an_optional_allof_enum, Unset): - an_optional_allof_enum = self.an_optional_allof_enum.value - - nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET - if not isinstance(self.nested_list_of_enums, Unset): - nested_list_of_enums = [] - for nested_list_of_enums_item_data in self.nested_list_of_enums: - nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value - nested_list_of_enums_item.append(nested_list_of_enums_item_item) - - nested_list_of_enums.append(nested_list_of_enums_item) - - a_not_required_date: Union[Unset, str] = UNSET - if not isinstance(self.a_not_required_date, Unset): - a_not_required_date = self.a_not_required_date.isoformat() - - a_not_required_uuid: Union[Unset, str] = UNSET - if not isinstance(self.a_not_required_uuid, Unset): - a_not_required_uuid = str(self.a_not_required_uuid) - - attr_1_leading_digit = self.attr_1_leading_digit - - attr_leading_underscore = self.attr_leading_underscore - - not_required_nullable: Union[None, Unset, str] - if isinstance(self.not_required_nullable, Unset): - not_required_nullable = UNSET - else: - not_required_nullable = self.not_required_nullable - - not_required_not_nullable = self.not_required_not_nullable - - not_required_one_of_models: Union[Unset, dict[str, Any]] - if isinstance(self.not_required_one_of_models, Unset): - not_required_one_of_models = UNSET - elif isinstance(self.not_required_one_of_models, FreeFormModel): - not_required_one_of_models = self.not_required_one_of_models.to_dict() - else: - not_required_one_of_models = self.not_required_one_of_models.to_dict() - - not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] - if isinstance(self.not_required_nullable_one_of_models, Unset): - not_required_nullable_one_of_models = UNSET - elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - else: - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models - - not_required_model: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.not_required_model, Unset): - not_required_model = self.not_required_model.to_dict() - - not_required_nullable_model: Union[None, Unset, dict[str, Any]] - if isinstance(self.not_required_nullable_model, Unset): - not_required_nullable_model = UNSET - elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): - not_required_nullable_model = self.not_required_nullable_model.to_dict() - else: - not_required_nullable_model = self.not_required_nullable_model - - field_dict: dict[str, Any] = {} - field_dict.update( - { - "an_enum_value": an_enum_value, - "an_allof_enum_with_overridden_default": an_allof_enum_with_overridden_default, - "aCamelDateTime": a_camel_date_time, - "a_date": a_date, - "a_nullable_date": a_nullable_date, - "a_uuid": a_uuid, - "a_nullable_uuid": a_nullable_uuid, - "required_nullable": required_nullable, - "required_not_nullable": required_not_nullable, - "one_of_models": one_of_models, - "nullable_one_of_models": nullable_one_of_models, - "model": model, - "nullable_model": nullable_model, - } - ) - if any_value is not UNSET: - field_dict["any_value"] = any_value - if an_optional_allof_enum is not UNSET: - field_dict["an_optional_allof_enum"] = an_optional_allof_enum - if nested_list_of_enums is not UNSET: - field_dict["nested_list_of_enums"] = nested_list_of_enums - if a_not_required_date is not UNSET: - field_dict["a_not_required_date"] = a_not_required_date - if a_not_required_uuid is not UNSET: - field_dict["a_not_required_uuid"] = a_not_required_uuid - if attr_1_leading_digit is not UNSET: - field_dict["1_leading_digit"] = attr_1_leading_digit - if attr_leading_underscore is not UNSET: - field_dict["_leading_underscore"] = attr_leading_underscore - if not_required_nullable is not UNSET: - field_dict["not_required_nullable"] = not_required_nullable - if not_required_not_nullable is not UNSET: - field_dict["not_required_not_nullable"] = not_required_not_nullable - if not_required_one_of_models is not UNSET: - field_dict["not_required_one_of_models"] = not_required_one_of_models - if not_required_nullable_one_of_models is not UNSET: - field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models - if not_required_model is not UNSET: - field_dict["not_required_model"] = not_required_model - if not_required_nullable_model is not UNSET: - field_dict["not_required_nullable_model"] = not_required_nullable_model - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - d = src_dict.copy() - an_enum_value = AnEnum(d.pop("an_enum_value")) - - an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) - - def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: - try: - if not isinstance(data, str): - raise TypeError() - a_camel_date_time_type_0 = isoparse(data) - - return a_camel_date_time_type_0 - except: # noqa: E722 - pass - if not isinstance(data, str): - raise TypeError() - a_camel_date_time_type_1 = isoparse(data).date() - - return a_camel_date_time_type_1 - - a_camel_date_time = _parse_a_camel_date_time(d.pop("aCamelDateTime")) - - a_date = isoparse(d.pop("a_date")).date() - - def _parse_a_nullable_date(data: object) -> Union[None, datetime.date]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - a_nullable_date_type_0 = isoparse(data).date() - - return a_nullable_date_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.date], data) - - a_nullable_date = _parse_a_nullable_date(d.pop("a_nullable_date")) - - a_uuid = UUID(d.pop("a_uuid")) - - def _parse_a_nullable_uuid(data: object) -> Union[None, UUID]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - a_nullable_uuid_type_0 = UUID(data) - - return a_nullable_uuid_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID], data) - - a_nullable_uuid = _parse_a_nullable_uuid(d.pop("a_nullable_uuid")) - - def _parse_required_nullable(data: object) -> Union[None, str]: - if data is None: - return data - return cast(Union[None, str], data) - - required_nullable = _parse_required_nullable(d.pop("required_nullable")) - - required_not_nullable = d.pop("required_not_nullable") - - def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: - try: - if not isinstance(data, dict): - raise TypeError() - one_of_models_type_0 = FreeFormModel.from_dict(data) - - return one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", Any], data) - - one_of_models = _parse_one_of_models(d.pop("one_of_models")) - - def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: - if data is None: - return data - try: - if not isinstance(data, dict): - raise TypeError() - nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return nullable_one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return nullable_one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) - - nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) - - model = ModelWithUnionProperty.from_dict(d.pop("model")) - - def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: - if data is None: - return data - try: - if not isinstance(data, dict): - raise TypeError() - nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) - - return nullable_model_type_1 - except: # noqa: E722 - pass - return cast(Union["ModelWithUnionProperty", None], data) - - nullable_model = _parse_nullable_model(d.pop("nullable_model")) - - any_value = d.pop("any_value", UNSET) - - _an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET) - an_optional_allof_enum: Union[Unset, AnAllOfEnum] - if isinstance(_an_optional_allof_enum, Unset): - an_optional_allof_enum = UNSET - else: - an_optional_allof_enum = AnAllOfEnum(_an_optional_allof_enum) - - nested_list_of_enums = [] - _nested_list_of_enums = d.pop("nested_list_of_enums", UNSET) - for nested_list_of_enums_item_data in _nested_list_of_enums or []: - nested_list_of_enums_item = [] - _nested_list_of_enums_item = nested_list_of_enums_item_data - for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) - - nested_list_of_enums_item.append(nested_list_of_enums_item_item) - - nested_list_of_enums.append(nested_list_of_enums_item) - - _a_not_required_date = d.pop("a_not_required_date", UNSET) - a_not_required_date: Union[Unset, datetime.date] - if isinstance(_a_not_required_date, Unset): - a_not_required_date = UNSET - else: - a_not_required_date = isoparse(_a_not_required_date).date() - - _a_not_required_uuid = d.pop("a_not_required_uuid", UNSET) - a_not_required_uuid: Union[Unset, UUID] - if isinstance(_a_not_required_uuid, Unset): - a_not_required_uuid = UNSET - else: - a_not_required_uuid = UUID(_a_not_required_uuid) - - attr_1_leading_digit = d.pop("1_leading_digit", UNSET) - - attr_leading_underscore = d.pop("_leading_underscore", UNSET) - - def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(Union[None, Unset, str], data) - - not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) - - not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) - - def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return not_required_one_of_models_type_0 - except: # noqa: E722 - pass - if not isinstance(data, dict): - raise TypeError() - not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_one_of_models_type_1 - - not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) - - def _parse_not_required_nullable_one_of_models( - data: object, - ) -> Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return not_required_nullable_one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_nullable_one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) - - not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( - d.pop("not_required_nullable_one_of_models", UNSET) - ) - - _not_required_model = d.pop("not_required_model", UNSET) - not_required_model: Union[Unset, ModelWithUnionProperty] - if isinstance(_not_required_model, Unset): - not_required_model = UNSET - else: - not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) - - def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_nullable_model_type_1 - except: # noqa: E722 - pass - return cast(Union["ModelWithUnionProperty", None, Unset], data) - - not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) - - a_model = cls( - an_enum_value=an_enum_value, - an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, - a_camel_date_time=a_camel_date_time, - a_date=a_date, - a_nullable_date=a_nullable_date, - a_uuid=a_uuid, - a_nullable_uuid=a_nullable_uuid, - required_nullable=required_nullable, - required_not_nullable=required_not_nullable, - one_of_models=one_of_models, - nullable_one_of_models=nullable_one_of_models, - model=model, - nullable_model=nullable_model, - any_value=any_value, - an_optional_allof_enum=an_optional_allof_enum, - nested_list_of_enums=nested_list_of_enums, - a_not_required_date=a_not_required_date, - a_not_required_uuid=a_not_required_uuid, - attr_1_leading_digit=attr_1_leading_digit, - attr_leading_underscore=attr_leading_underscore, - not_required_nullable=not_required_nullable, - not_required_not_nullable=not_required_not_nullable, - not_required_one_of_models=not_required_one_of_models, - not_required_nullable_one_of_models=not_required_nullable_one_of_models, - not_required_model=not_required_model, - not_required_nullable_model=not_required_nullable_model, - ) - - return a_model diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py deleted file mode 100644 index 0c338207d..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ /dev/null @@ -1,343 +0,0 @@ -import datetime -from io import BytesIO -from typing import Any, TypeVar, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.an_enum import AnEnum -from ..types import File - -T = TypeVar("T", bound="AModelWithPropertiesReferenceThatAreNotObject") - - -@_attrs_define -class AModelWithPropertiesReferenceThatAreNotObject: - 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 - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - enum_properties_ref = [] - for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: - componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value - enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) - - str_properties_ref = self.str_properties_ref - - date_properties_ref = [] - for componentsschemas_an_other_array_of_date_item_data in self.date_properties_ref: - componentsschemas_an_other_array_of_date_item = ( - componentsschemas_an_other_array_of_date_item_data.isoformat() - ) - date_properties_ref.append(componentsschemas_an_other_array_of_date_item) - - datetime_properties_ref = [] - for componentsschemas_an_other_array_of_date_time_item_data in self.datetime_properties_ref: - componentsschemas_an_other_array_of_date_time_item = ( - componentsschemas_an_other_array_of_date_time_item_data.isoformat() - ) - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) - - int32_properties_ref = self.int32_properties_ref - - int64_properties_ref = self.int64_properties_ref - - float_properties_ref = self.float_properties_ref - - double_properties_ref = self.double_properties_ref - - file_properties_ref = [] - for componentsschemas_an_other_array_of_file_item_data in self.file_properties_ref: - componentsschemas_an_other_array_of_file_item = ( - componentsschemas_an_other_array_of_file_item_data.to_tuple() - ) - - file_properties_ref.append(componentsschemas_an_other_array_of_file_item) - - bytestream_properties_ref = self.bytestream_properties_ref - - enum_properties = [] - for componentsschemas_an_array_of_enum_item_data in self.enum_properties: - componentsschemas_an_array_of_enum_item = componentsschemas_an_array_of_enum_item_data.value - enum_properties.append(componentsschemas_an_array_of_enum_item) - - str_properties = self.str_properties - - date_properties = [] - for componentsschemas_an_array_of_date_item_data in self.date_properties: - componentsschemas_an_array_of_date_item = componentsschemas_an_array_of_date_item_data.isoformat() - date_properties.append(componentsschemas_an_array_of_date_item) - - datetime_properties = [] - for componentsschemas_an_array_of_date_time_item_data in self.datetime_properties: - componentsschemas_an_array_of_date_time_item = componentsschemas_an_array_of_date_time_item_data.isoformat() - datetime_properties.append(componentsschemas_an_array_of_date_time_item) - - int32_properties = self.int32_properties - - int64_properties = self.int64_properties - - float_properties = self.float_properties - - double_properties = self.double_properties - - file_properties = [] - for componentsschemas_an_array_of_file_item_data in self.file_properties: - componentsschemas_an_array_of_file_item = componentsschemas_an_array_of_file_item_data.to_tuple() - - file_properties.append(componentsschemas_an_array_of_file_item) - - bytestream_properties = self.bytestream_properties - - enum_property_ref = self.enum_property_ref.value - - str_property_ref = self.str_property_ref - - date_property_ref = self.date_property_ref.isoformat() - - datetime_property_ref = self.datetime_property_ref.isoformat() - - int32_property_ref = self.int32_property_ref - - int64_property_ref = self.int64_property_ref - - float_property_ref = self.float_property_ref - - double_property_ref = self.double_property_ref - - file_property_ref = self.file_property_ref.to_tuple() - - bytestream_property_ref = self.bytestream_property_ref - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "enum_properties_ref": enum_properties_ref, - "str_properties_ref": str_properties_ref, - "date_properties_ref": date_properties_ref, - "datetime_properties_ref": datetime_properties_ref, - "int32_properties_ref": int32_properties_ref, - "int64_properties_ref": int64_properties_ref, - "float_properties_ref": float_properties_ref, - "double_properties_ref": double_properties_ref, - "file_properties_ref": file_properties_ref, - "bytestream_properties_ref": bytestream_properties_ref, - "enum_properties": enum_properties, - "str_properties": str_properties, - "date_properties": date_properties, - "datetime_properties": datetime_properties, - "int32_properties": int32_properties, - "int64_properties": int64_properties, - "float_properties": float_properties, - "double_properties": double_properties, - "file_properties": file_properties, - "bytestream_properties": bytestream_properties, - "enum_property_ref": enum_property_ref, - "str_property_ref": str_property_ref, - "date_property_ref": date_property_ref, - "datetime_property_ref": datetime_property_ref, - "int32_property_ref": int32_property_ref, - "int64_property_ref": int64_property_ref, - "float_property_ref": float_property_ref, - "double_property_ref": double_property_ref, - "file_property_ref": file_property_ref, - "bytestream_property_ref": bytestream_property_ref, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - enum_properties_ref = [] - _enum_properties_ref = d.pop("enum_properties_ref") - for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref: - componentsschemas_an_other_array_of_enum_item = AnEnum(componentsschemas_an_other_array_of_enum_item_data) - - enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) - - str_properties_ref = cast(list[str], d.pop("str_properties_ref")) - - date_properties_ref = [] - _date_properties_ref = d.pop("date_properties_ref") - for componentsschemas_an_other_array_of_date_item_data in _date_properties_ref: - componentsschemas_an_other_array_of_date_item = isoparse( - componentsschemas_an_other_array_of_date_item_data - ).date() - - date_properties_ref.append(componentsschemas_an_other_array_of_date_item) - - datetime_properties_ref = [] - _datetime_properties_ref = d.pop("datetime_properties_ref") - for componentsschemas_an_other_array_of_date_time_item_data in _datetime_properties_ref: - componentsschemas_an_other_array_of_date_time_item = isoparse( - componentsschemas_an_other_array_of_date_time_item_data - ) - - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) - - int32_properties_ref = cast(list[int], d.pop("int32_properties_ref")) - - int64_properties_ref = cast(list[int], d.pop("int64_properties_ref")) - - float_properties_ref = cast(list[float], d.pop("float_properties_ref")) - - double_properties_ref = cast(list[float], d.pop("double_properties_ref")) - - file_properties_ref = [] - _file_properties_ref = d.pop("file_properties_ref") - for componentsschemas_an_other_array_of_file_item_data in _file_properties_ref: - componentsschemas_an_other_array_of_file_item = File( - payload=BytesIO(componentsschemas_an_other_array_of_file_item_data) - ) - - file_properties_ref.append(componentsschemas_an_other_array_of_file_item) - - bytestream_properties_ref = cast(list[str], d.pop("bytestream_properties_ref")) - - enum_properties = [] - _enum_properties = d.pop("enum_properties") - for componentsschemas_an_array_of_enum_item_data in _enum_properties: - componentsschemas_an_array_of_enum_item = AnEnum(componentsschemas_an_array_of_enum_item_data) - - enum_properties.append(componentsschemas_an_array_of_enum_item) - - str_properties = cast(list[str], d.pop("str_properties")) - - date_properties = [] - _date_properties = d.pop("date_properties") - for componentsschemas_an_array_of_date_item_data in _date_properties: - componentsschemas_an_array_of_date_item = isoparse(componentsschemas_an_array_of_date_item_data).date() - - date_properties.append(componentsschemas_an_array_of_date_item) - - datetime_properties = [] - _datetime_properties = d.pop("datetime_properties") - for componentsschemas_an_array_of_date_time_item_data in _datetime_properties: - componentsschemas_an_array_of_date_time_item = isoparse(componentsschemas_an_array_of_date_time_item_data) - - datetime_properties.append(componentsschemas_an_array_of_date_time_item) - - int32_properties = cast(list[int], d.pop("int32_properties")) - - int64_properties = cast(list[int], d.pop("int64_properties")) - - float_properties = cast(list[float], d.pop("float_properties")) - - double_properties = cast(list[float], d.pop("double_properties")) - - file_properties = [] - _file_properties = d.pop("file_properties") - for componentsschemas_an_array_of_file_item_data in _file_properties: - componentsschemas_an_array_of_file_item = File( - payload=BytesIO(componentsschemas_an_array_of_file_item_data) - ) - - file_properties.append(componentsschemas_an_array_of_file_item) - - bytestream_properties = cast(list[str], d.pop("bytestream_properties")) - - enum_property_ref = AnEnum(d.pop("enum_property_ref")) - - str_property_ref = d.pop("str_property_ref") - - date_property_ref = isoparse(d.pop("date_property_ref")).date() - - datetime_property_ref = isoparse(d.pop("datetime_property_ref")) - - int32_property_ref = d.pop("int32_property_ref") - - int64_property_ref = d.pop("int64_property_ref") - - float_property_ref = d.pop("float_property_ref") - - double_property_ref = d.pop("double_property_ref") - - file_property_ref = File(payload=BytesIO(d.pop("file_property_ref"))) - - bytestream_property_ref = d.pop("bytestream_property_ref") - - a_model_with_properties_reference_that_are_not_object = cls( - enum_properties_ref=enum_properties_ref, - str_properties_ref=str_properties_ref, - date_properties_ref=date_properties_ref, - datetime_properties_ref=datetime_properties_ref, - int32_properties_ref=int32_properties_ref, - int64_properties_ref=int64_properties_ref, - float_properties_ref=float_properties_ref, - double_properties_ref=double_properties_ref, - file_properties_ref=file_properties_ref, - bytestream_properties_ref=bytestream_properties_ref, - enum_properties=enum_properties, - str_properties=str_properties, - date_properties=date_properties, - datetime_properties=datetime_properties, - int32_properties=int32_properties, - int64_properties=int64_properties, - float_properties=float_properties, - double_properties=double_properties, - file_properties=file_properties, - bytestream_properties=bytestream_properties, - enum_property_ref=enum_property_ref, - str_property_ref=str_property_ref, - date_property_ref=date_property_ref, - datetime_property_ref=datetime_property_ref, - int32_property_ref=int32_property_ref, - int64_property_ref=int64_property_ref, - float_property_ref=float_property_ref, - double_property_ref=double_property_ref, - file_property_ref=file_property_ref, - bytestream_property_ref=bytestream_property_ref, - ) - - a_model_with_properties_reference_that_are_not_object.additional_properties = d - return a_model_with_properties_reference_that_are_not_object - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py deleted file mode 100644 index 4869c0f96..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py +++ /dev/null @@ -1,77 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AllOfHasPropertiesButNoType") - - -@_attrs_define -class AllOfHasPropertiesButNoType: - a_sub_property: Union[Unset, str] = UNSET - type_: Union[Unset, str] = UNSET - type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a_sub_property = self.a_sub_property - - type_ = self.type_ - - type_enum: Union[Unset, int] = UNSET - if not isinstance(self.type_enum, Unset): - type_enum = self.type_enum.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a_sub_property is not UNSET: - field_dict["a_sub_property"] = a_sub_property - if type_ is not UNSET: - field_dict["type"] = type_ - if type_enum is not UNSET: - field_dict["type_enum"] = type_enum - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_sub_property = d.pop("a_sub_property", UNSET) - - type_ = d.pop("type", UNSET) - - _type_enum = d.pop("type_enum", UNSET) - type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] - if isinstance(_type_enum, Unset): - type_enum = UNSET - else: - type_enum = AllOfHasPropertiesButNoTypeTypeEnum(_type_enum) - - all_of_has_properties_but_no_type = cls( - a_sub_property=a_sub_property, - type_=type_, - type_enum=type_enum, - ) - - all_of_has_properties_but_no_type.additional_properties = d - return all_of_has_properties_but_no_type - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py deleted file mode 100644 index 4966e1970..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_has_properties_but_no_type_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class AllOfHasPropertiesButNoTypeTypeEnum(IntEnum): - VALUE_0 = 0 - VALUE_1 = 1 - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py deleted file mode 100644 index c44f73a90..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model.py +++ /dev/null @@ -1,77 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.all_of_sub_model_type_enum import AllOfSubModelTypeEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AllOfSubModel") - - -@_attrs_define -class AllOfSubModel: - a_sub_property: Union[Unset, str] = UNSET - type_: Union[Unset, str] = UNSET - type_enum: Union[Unset, AllOfSubModelTypeEnum] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a_sub_property = self.a_sub_property - - type_ = self.type_ - - type_enum: Union[Unset, int] = UNSET - if not isinstance(self.type_enum, Unset): - type_enum = self.type_enum.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a_sub_property is not UNSET: - field_dict["a_sub_property"] = a_sub_property - if type_ is not UNSET: - field_dict["type"] = type_ - if type_enum is not UNSET: - field_dict["type_enum"] = type_enum - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_sub_property = d.pop("a_sub_property", UNSET) - - type_ = d.pop("type", UNSET) - - _type_enum = d.pop("type_enum", UNSET) - type_enum: Union[Unset, AllOfSubModelTypeEnum] - if isinstance(_type_enum, Unset): - type_enum = UNSET - else: - type_enum = AllOfSubModelTypeEnum(_type_enum) - - all_of_sub_model = cls( - a_sub_property=a_sub_property, - type_=type_, - type_enum=type_enum, - ) - - all_of_sub_model.additional_properties = d - return all_of_sub_model - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py deleted file mode 100644 index 817e0eb7c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/all_of_sub_model_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class AllOfSubModelTypeEnum(IntEnum): - VALUE_0 = 0 - VALUE_1 = 1 - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py deleted file mode 100644 index 3aef48f8f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_all_of_enum.py +++ /dev/null @@ -1,11 +0,0 @@ -from enum import Enum - - -class AnAllOfEnum(str, Enum): - A_DEFAULT = "a_default" - BAR = "bar" - FOO = "foo" - OVERRIDDEN_DEFAULT = "overridden_default" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py deleted file mode 100644 index 5d1fdf75e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py +++ /dev/null @@ -1,77 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem - - -T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAItem") - - -@_attrs_define -class AnArrayWithACircularRefInItemsObjectAItem: - circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectBItem"]] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - circular: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.circular, Unset): - circular = [] - for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in self.circular: - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data.to_dict() - ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if circular is not UNSET: - field_dict["circular"] = circular - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.an_array_with_a_circular_ref_in_items_object_b_item import ( - AnArrayWithACircularRefInItemsObjectBItem, - ) - - d = src_dict.copy() - circular = [] - _circular = d.pop("circular", UNSET) - for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in _circular or []: - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( - AnArrayWithACircularRefInItemsObjectBItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data - ) - ) - - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) - - an_array_with_a_circular_ref_in_items_object_a_item = cls( - circular=circular, - ) - - an_array_with_a_circular_ref_in_items_object_a_item.additional_properties = d - return an_array_with_a_circular_ref_in_items_object_a_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py deleted file mode 100644 index be27e601b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, - ) - - -T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem") - - -@_attrs_define -class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem: - additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]] = ( - _attrs_field(init=False, factory=dict) - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = [] - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) in prop: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data.to_dict() - field_dict[prop_name].append( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, - ) - - d = src_dict.copy() - an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = [] - _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) - ) - - additional_property.append( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item - ) - - additional_properties[prop_name] = additional_property - - an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.additional_properties = ( - additional_properties - ) - return an_array_with_a_circular_ref_in_items_object_additional_properties_a_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: - return self.additional_properties[key] - - def __setitem__( - self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] - ) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py deleted file mode 100644 index 0b62f118b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, - ) - - -T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem") - - -@_attrs_define -class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem: - additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]] = ( - _attrs_field(init=False, factory=dict) - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = [] - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) in prop: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data.to_dict() - field_dict[prop_name].append( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, - ) - - d = src_dict.copy() - an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = [] - _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) - ) - - additional_property.append( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item - ) - - additional_properties[prop_name] = additional_property - - an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.additional_properties = ( - additional_properties - ) - return an_array_with_a_circular_ref_in_items_object_additional_properties_b_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: - return self.additional_properties[key] - - def __setitem__( - self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] - ) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py deleted file mode 100644 index de63ba76c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py +++ /dev/null @@ -1,77 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem - - -T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectBItem") - - -@_attrs_define -class AnArrayWithACircularRefInItemsObjectBItem: - circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectAItem"]] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - circular: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.circular, Unset): - circular = [] - for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in self.circular: - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data.to_dict() - ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if circular is not UNSET: - field_dict["circular"] = circular - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.an_array_with_a_circular_ref_in_items_object_a_item import ( - AnArrayWithACircularRefInItemsObjectAItem, - ) - - d = src_dict.copy() - circular = [] - _circular = d.pop("circular", UNSET) - for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in _circular or []: - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( - AnArrayWithACircularRefInItemsObjectAItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data - ) - ) - - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) - - an_array_with_a_circular_ref_in_items_object_b_item = cls( - circular=circular, - ) - - an_array_with_a_circular_ref_in_items_object_b_item.additional_properties = d - return an_array_with_a_circular_ref_in_items_object_b_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py deleted file mode 100644 index e861688d8..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py +++ /dev/null @@ -1,72 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem") - - -@_attrs_define -class AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem: - additional_properties: dict[str, list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]] = ( - _attrs_field(init=False, factory=dict) - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = [] - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in prop: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data.to_dict() - field_dict[prop_name].append( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - an_array_with_a_recursive_ref_in_items_object_additional_properties_item = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = [] - _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = ( - AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.from_dict( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data - ) - ) - - additional_property.append( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item - ) - - additional_properties[prop_name] = additional_property - - an_array_with_a_recursive_ref_in_items_object_additional_properties_item.additional_properties = ( - additional_properties - ) - return an_array_with_a_recursive_ref_in_items_object_additional_properties_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: - return self.additional_properties[key] - - def __setitem__( - self, key: str, value: list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] - ) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py deleted file mode 100644 index a1a89b4fa..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py +++ /dev/null @@ -1,69 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AnArrayWithARecursiveRefInItemsObjectItem") - - -@_attrs_define -class AnArrayWithARecursiveRefInItemsObjectItem: - recursive: Union[Unset, list["AnArrayWithARecursiveRefInItemsObjectItem"]] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - recursive: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.recursive, Unset): - recursive = [] - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in self.recursive: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data.to_dict() - ) - recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if recursive is not UNSET: - field_dict["recursive"] = recursive - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - recursive = [] - _recursive = d.pop("recursive", UNSET) - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in _recursive or []: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( - AnArrayWithARecursiveRefInItemsObjectItem.from_dict( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data - ) - ) - - recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) - - an_array_with_a_recursive_ref_in_items_object_item = cls( - recursive=recursive, - ) - - an_array_with_a_recursive_ref_in_items_object_item.additional_properties = d - return an_array_with_a_recursive_ref_in_items_object_item - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py deleted file mode 100644 index c266d0763..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - - -class AnEnum(str, Enum): - FIRST_VALUE = "FIRST_VALUE" - SECOND_VALUE = "SECOND_VALUE" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py deleted file mode 100644 index b1d6611e0..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_enum_with_null.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - - -class AnEnumWithNull(str, Enum): - FIRST_VALUE = "FIRST_VALUE" - SECOND_VALUE = "SECOND_VALUE" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py deleted file mode 100644 index d7d7a713d..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/an_int_enum.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import IntEnum - - -class AnIntEnum(IntEnum): - VALUE_NEGATIVE_1 = -1 - VALUE_1 = 1 - VALUE_2 = 2 - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py deleted file mode 100644 index d5e26e481..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model.py +++ /dev/null @@ -1,85 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.another_all_of_sub_model_type import AnotherAllOfSubModelType -from ..models.another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="AnotherAllOfSubModel") - - -@_attrs_define -class AnotherAllOfSubModel: - another_sub_property: Union[Unset, str] = UNSET - type_: Union[Unset, AnotherAllOfSubModelType] = UNSET - type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - another_sub_property = self.another_sub_property - - type_: Union[Unset, str] = UNSET - if not isinstance(self.type_, Unset): - type_ = self.type_.value - - type_enum: Union[Unset, int] = UNSET - if not isinstance(self.type_enum, Unset): - type_enum = self.type_enum.value - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if another_sub_property is not UNSET: - field_dict["another_sub_property"] = another_sub_property - if type_ is not UNSET: - field_dict["type"] = type_ - if type_enum is not UNSET: - field_dict["type_enum"] = type_enum - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - another_sub_property = d.pop("another_sub_property", UNSET) - - _type_ = d.pop("type", UNSET) - type_: Union[Unset, AnotherAllOfSubModelType] - if isinstance(_type_, Unset): - type_ = UNSET - else: - type_ = AnotherAllOfSubModelType(_type_) - - _type_enum = d.pop("type_enum", UNSET) - type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] - if isinstance(_type_enum, Unset): - type_enum = UNSET - else: - type_enum = AnotherAllOfSubModelTypeEnum(_type_enum) - - another_all_of_sub_model = cls( - another_sub_property=another_sub_property, - type_=type_, - type_enum=type_enum, - ) - - another_all_of_sub_model.additional_properties = d - return another_all_of_sub_model - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py deleted file mode 100644 index b2e82aa7c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type.py +++ /dev/null @@ -1,8 +0,0 @@ -from enum import Enum - - -class AnotherAllOfSubModelType(str, Enum): - SUBMODEL = "submodel" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py deleted file mode 100644 index d54ed9dde..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/another_all_of_sub_model_type_enum.py +++ /dev/null @@ -1,8 +0,0 @@ -from enum import IntEnum - - -class AnotherAllOfSubModelTypeEnum(IntEnum): - VALUE_0 = 0 - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py deleted file mode 100644 index f26df5faf..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py +++ /dev/null @@ -1,422 +0,0 @@ -import datetime -import json -from io import BytesIO -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.different_enum import DifferentEnum -from ..types import UNSET, File, FileJsonType, Unset - -if TYPE_CHECKING: - from ..models.a_form_data import AFormData - from ..models.body_upload_file_tests_upload_post_additional_property import ( - BodyUploadFileTestsUploadPostAdditionalProperty, - ) - from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, - ) - from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject - from ..models.body_upload_file_tests_upload_post_some_optional_object import ( - BodyUploadFileTestsUploadPostSomeOptionalObject, - ) - - -T = TypeVar("T", bound="BodyUploadFileTestsUploadPost") - - -@_attrs_define -class BodyUploadFileTestsUploadPost: - some_file: File - some_required_number: float - some_object: "BodyUploadFileTestsUploadPostSomeObject" - some_nullable_object: Union["BodyUploadFileTestsUploadPostSomeNullableObject", None] - some_optional_file: Union[Unset, File] = UNSET - some_string: Union[Unset, str] = "some_default_string" - a_datetime: Union[Unset, datetime.datetime] = UNSET - a_date: Union[Unset, datetime.date] = UNSET - some_number: Union[Unset, float] = UNSET - some_nullable_number: Union[None, Unset, float] = UNSET - some_int_array: Union[Unset, list[Union[None, int]]] = UNSET - some_array: Union[None, Unset, list["AFormData"]] = UNSET - some_optional_object: Union[Unset, "BodyUploadFileTestsUploadPostSomeOptionalObject"] = UNSET - some_enum: Union[Unset, DifferentEnum] = UNSET - """ An enumeration. """ - additional_properties: dict[str, "BodyUploadFileTestsUploadPostAdditionalProperty"] = _attrs_field( - init=False, factory=dict - ) - - def to_dict(self) -> dict[str, Any]: - from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, - ) - - some_file = self.some_file.to_tuple() - - some_required_number = self.some_required_number - - some_object = self.some_object.to_dict() - - some_nullable_object: Union[None, dict[str, Any]] - if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): - some_nullable_object = self.some_nullable_object.to_dict() - else: - some_nullable_object = self.some_nullable_object - - some_optional_file: Union[Unset, FileJsonType] = UNSET - if not isinstance(self.some_optional_file, Unset): - some_optional_file = self.some_optional_file.to_tuple() - - some_string = self.some_string - - a_datetime: Union[Unset, str] = UNSET - if not isinstance(self.a_datetime, Unset): - a_datetime = self.a_datetime.isoformat() - - a_date: Union[Unset, str] = UNSET - if not isinstance(self.a_date, Unset): - a_date = self.a_date.isoformat() - - some_number = self.some_number - - some_nullable_number: Union[None, Unset, float] - if isinstance(self.some_nullable_number, Unset): - some_nullable_number = UNSET - else: - some_nullable_number = self.some_nullable_number - - some_int_array: Union[Unset, list[Union[None, int]]] = UNSET - if not isinstance(self.some_int_array, Unset): - some_int_array = [] - for some_int_array_item_data in self.some_int_array: - some_int_array_item: Union[None, int] - some_int_array_item = some_int_array_item_data - some_int_array.append(some_int_array_item) - - some_array: Union[None, Unset, list[dict[str, Any]]] - if isinstance(self.some_array, Unset): - some_array = UNSET - elif isinstance(self.some_array, list): - some_array = [] - for some_array_type_0_item_data in self.some_array: - some_array_type_0_item = some_array_type_0_item_data.to_dict() - some_array.append(some_array_type_0_item) - - else: - some_array = self.some_array - - some_optional_object: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.some_optional_object, Unset): - some_optional_object = self.some_optional_object.to_dict() - - some_enum: Union[Unset, str] = UNSET - if not isinstance(self.some_enum, Unset): - some_enum = self.some_enum.value - - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.to_dict() - field_dict.update( - { - "some_file": some_file, - "some_required_number": some_required_number, - "some_object": some_object, - "some_nullable_object": some_nullable_object, - } - ) - if some_optional_file is not UNSET: - field_dict["some_optional_file"] = some_optional_file - if some_string is not UNSET: - field_dict["some_string"] = some_string - if a_datetime is not UNSET: - field_dict["a_datetime"] = a_datetime - if a_date is not UNSET: - field_dict["a_date"] = a_date - if some_number is not UNSET: - field_dict["some_number"] = some_number - if some_nullable_number is not UNSET: - field_dict["some_nullable_number"] = some_nullable_number - if some_int_array is not UNSET: - field_dict["some_int_array"] = some_int_array - if some_array is not UNSET: - field_dict["some_array"] = some_array - if some_optional_object is not UNSET: - field_dict["some_optional_object"] = some_optional_object - if some_enum is not UNSET: - field_dict["some_enum"] = some_enum - - return field_dict - - def to_multipart(self) -> dict[str, Any]: - some_file = self.some_file.to_tuple() - - some_required_number = (None, str(self.some_required_number).encode(), "text/plain") - - some_object = (None, json.dumps(self.some_object.to_dict()).encode(), "application/json") - - some_nullable_object: tuple[None, bytes, str] - - if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): - some_nullable_object = (None, json.dumps(self.some_nullable_object.to_dict()).encode(), "application/json") - else: - some_nullable_object = (None, str(self.some_nullable_object).encode(), "text/plain") - - some_optional_file: Union[Unset, FileJsonType] = UNSET - if not isinstance(self.some_optional_file, Unset): - some_optional_file = self.some_optional_file.to_tuple() - - some_string = ( - self.some_string - if isinstance(self.some_string, Unset) - else (None, str(self.some_string).encode(), "text/plain") - ) - - a_datetime: Union[Unset, bytes] = UNSET - if not isinstance(self.a_datetime, Unset): - a_datetime = self.a_datetime.isoformat().encode() - - a_date: Union[Unset, bytes] = UNSET - if not isinstance(self.a_date, Unset): - a_date = self.a_date.isoformat().encode() - - some_number = ( - self.some_number - if isinstance(self.some_number, Unset) - else (None, str(self.some_number).encode(), "text/plain") - ) - - some_nullable_number: Union[Unset, tuple[None, bytes, str]] - - if isinstance(self.some_nullable_number, Unset): - some_nullable_number = UNSET - elif isinstance(self.some_nullable_number, float): - some_nullable_number = (None, str(self.some_nullable_number).encode(), "text/plain") - else: - some_nullable_number = (None, str(self.some_nullable_number).encode(), "text/plain") - - some_int_array: Union[Unset, tuple[None, bytes, str]] = UNSET - if not isinstance(self.some_int_array, Unset): - _temp_some_int_array = [] - for some_int_array_item_data in self.some_int_array: - some_int_array_item: Union[None, int] - some_int_array_item = some_int_array_item_data - _temp_some_int_array.append(some_int_array_item) - some_int_array = (None, json.dumps(_temp_some_int_array).encode(), "application/json") - - some_array: Union[Unset, tuple[None, bytes, str]] - - if isinstance(self.some_array, Unset): - some_array = UNSET - elif isinstance(self.some_array, list): - _temp_some_array = [] - for some_array_type_0_item_data in self.some_array: - some_array_type_0_item = some_array_type_0_item_data.to_dict() - _temp_some_array.append(some_array_type_0_item) - some_array = (None, json.dumps(_temp_some_array).encode(), "application/json") - else: - some_array = (None, str(self.some_array).encode(), "text/plain") - - some_optional_object: Union[Unset, tuple[None, bytes, str]] = UNSET - if not isinstance(self.some_optional_object, Unset): - some_optional_object = (None, json.dumps(self.some_optional_object.to_dict()).encode(), "application/json") - - some_enum: Union[Unset, tuple[None, bytes, str]] = UNSET - if not isinstance(self.some_enum, Unset): - some_enum = (None, str(self.some_enum.value).encode(), "text/plain") - - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = (None, json.dumps(prop.to_dict()).encode(), "application/json") - field_dict.update( - { - "some_file": some_file, - "some_required_number": some_required_number, - "some_object": some_object, - "some_nullable_object": some_nullable_object, - } - ) - if some_optional_file is not UNSET: - field_dict["some_optional_file"] = some_optional_file - if some_string is not UNSET: - field_dict["some_string"] = some_string - if a_datetime is not UNSET: - field_dict["a_datetime"] = a_datetime - if a_date is not UNSET: - field_dict["a_date"] = a_date - if some_number is not UNSET: - field_dict["some_number"] = some_number - if some_nullable_number is not UNSET: - field_dict["some_nullable_number"] = some_nullable_number - if some_int_array is not UNSET: - field_dict["some_int_array"] = some_int_array - if some_array is not UNSET: - field_dict["some_array"] = some_array - if some_optional_object is not UNSET: - field_dict["some_optional_object"] = some_optional_object - if some_enum is not UNSET: - field_dict["some_enum"] = some_enum - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.a_form_data import AFormData - from ..models.body_upload_file_tests_upload_post_additional_property import ( - BodyUploadFileTestsUploadPostAdditionalProperty, - ) - from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, - ) - from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject - from ..models.body_upload_file_tests_upload_post_some_optional_object import ( - BodyUploadFileTestsUploadPostSomeOptionalObject, - ) - - d = src_dict.copy() - some_file = File(payload=BytesIO(d.pop("some_file"))) - - some_required_number = d.pop("some_required_number") - - some_object = BodyUploadFileTestsUploadPostSomeObject.from_dict(d.pop("some_object")) - - def _parse_some_nullable_object(data: object) -> Union["BodyUploadFileTestsUploadPostSomeNullableObject", None]: - if data is None: - return data - try: - if not isinstance(data, dict): - raise TypeError() - some_nullable_object_type_0 = BodyUploadFileTestsUploadPostSomeNullableObject.from_dict(data) - - return some_nullable_object_type_0 - except: # noqa: E722 - pass - return cast(Union["BodyUploadFileTestsUploadPostSomeNullableObject", None], data) - - some_nullable_object = _parse_some_nullable_object(d.pop("some_nullable_object")) - - _some_optional_file = d.pop("some_optional_file", UNSET) - some_optional_file: Union[Unset, File] - if isinstance(_some_optional_file, Unset): - some_optional_file = UNSET - else: - some_optional_file = File(payload=BytesIO(_some_optional_file)) - - some_string = d.pop("some_string", UNSET) - - _a_datetime = d.pop("a_datetime", UNSET) - a_datetime: Union[Unset, datetime.datetime] - if isinstance(_a_datetime, Unset): - a_datetime = UNSET - else: - a_datetime = isoparse(_a_datetime) - - _a_date = d.pop("a_date", UNSET) - a_date: Union[Unset, datetime.date] - if isinstance(_a_date, Unset): - a_date = UNSET - else: - a_date = isoparse(_a_date).date() - - some_number = d.pop("some_number", UNSET) - - def _parse_some_nullable_number(data: object) -> Union[None, Unset, float]: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(Union[None, Unset, float], data) - - some_nullable_number = _parse_some_nullable_number(d.pop("some_nullable_number", UNSET)) - - some_int_array = [] - _some_int_array = d.pop("some_int_array", UNSET) - for some_int_array_item_data in _some_int_array or []: - - def _parse_some_int_array_item(data: object) -> Union[None, int]: - if data is None: - return data - return cast(Union[None, int], data) - - some_int_array_item = _parse_some_int_array_item(some_int_array_item_data) - - some_int_array.append(some_int_array_item) - - def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, list): - raise TypeError() - some_array_type_0 = [] - _some_array_type_0 = data - for some_array_type_0_item_data in _some_array_type_0: - some_array_type_0_item = AFormData.from_dict(some_array_type_0_item_data) - - some_array_type_0.append(some_array_type_0_item) - - return some_array_type_0 - except: # noqa: E722 - pass - return cast(Union[None, Unset, list["AFormData"]], data) - - some_array = _parse_some_array(d.pop("some_array", UNSET)) - - _some_optional_object = d.pop("some_optional_object", UNSET) - some_optional_object: Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject] - if isinstance(_some_optional_object, Unset): - some_optional_object = UNSET - else: - some_optional_object = BodyUploadFileTestsUploadPostSomeOptionalObject.from_dict(_some_optional_object) - - _some_enum = d.pop("some_enum", UNSET) - some_enum: Union[Unset, DifferentEnum] - if isinstance(_some_enum, Unset): - some_enum = UNSET - else: - some_enum = DifferentEnum(_some_enum) - - body_upload_file_tests_upload_post = cls( - some_file=some_file, - some_required_number=some_required_number, - some_object=some_object, - some_nullable_object=some_nullable_object, - some_optional_file=some_optional_file, - some_string=some_string, - a_datetime=a_datetime, - a_date=a_date, - some_number=some_number, - some_nullable_number=some_nullable_number, - some_int_array=some_int_array, - some_array=some_array, - some_optional_object=some_optional_object, - some_enum=some_enum, - ) - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - body_upload_file_tests_upload_post.additional_properties = additional_properties - return body_upload_file_tests_upload_post - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> "BodyUploadFileTestsUploadPostAdditionalProperty": - return self.additional_properties[key] - - def __setitem__(self, key: str, value: "BodyUploadFileTestsUploadPostAdditionalProperty") -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py deleted file mode 100644 index a97c825ca..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="BodyUploadFileTestsUploadPostAdditionalProperty") - - -@_attrs_define -class BodyUploadFileTestsUploadPostAdditionalProperty: - foo: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - foo = self.foo - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if foo is not UNSET: - field_dict["foo"] = foo - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - foo = d.pop("foo", UNSET) - - body_upload_file_tests_upload_post_additional_property = cls( - foo=foo, - ) - - body_upload_file_tests_upload_post_additional_property.additional_properties = d - return body_upload_file_tests_upload_post_additional_property - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py deleted file mode 100644 index de2642c84..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeNullableObject") - - -@_attrs_define -class BodyUploadFileTestsUploadPostSomeNullableObject: - bar: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - bar = self.bar - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if bar is not UNSET: - field_dict["bar"] = bar - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - bar = d.pop("bar", UNSET) - - body_upload_file_tests_upload_post_some_nullable_object = cls( - bar=bar, - ) - - body_upload_file_tests_upload_post_some_nullable_object.additional_properties = d - return body_upload_file_tests_upload_post_some_nullable_object - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py deleted file mode 100644 index 4a978cd7e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py +++ /dev/null @@ -1,60 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeObject") - - -@_attrs_define -class BodyUploadFileTestsUploadPostSomeObject: - num: float - text: str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - num = self.num - - text = self.text - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "num": num, - "text": text, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - num = d.pop("num") - - text = d.pop("text") - - body_upload_file_tests_upload_post_some_object = cls( - num=num, - text=text, - ) - - body_upload_file_tests_upload_post_some_object.additional_properties = d - return body_upload_file_tests_upload_post_some_object - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py deleted file mode 100644 index 56230f597..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeOptionalObject") - - -@_attrs_define -class BodyUploadFileTestsUploadPostSomeOptionalObject: - foo: str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - foo = self.foo - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "foo": foo, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - foo = d.pop("foo") - - body_upload_file_tests_upload_post_some_optional_object = cls( - foo=foo, - ) - - body_upload_file_tests_upload_post_some_optional_object.additional_properties = d - return body_upload_file_tests_upload_post_some_optional_object - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py deleted file mode 100644 index 6c167f25c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/different_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - - -class DifferentEnum(str, Enum): - DIFFERENT = "DIFFERENT" - OTHER = "OTHER" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py deleted file mode 100644 index c615e5a2c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/extended.py +++ /dev/null @@ -1,534 +0,0 @@ -import datetime -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.an_all_of_enum import AnAllOfEnum -from ..models.an_enum import AnEnum -from ..models.different_enum import DifferentEnum -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - -T = TypeVar("T", bound="Extended") - - -@_attrs_define -class Extended: - an_enum_value: AnEnum - """ For testing Enums in all the ways they can be used """ - a_camel_date_time: Union[datetime.date, datetime.datetime] - a_date: datetime.date - a_nullable_date: Union[None, datetime.date] - a_uuid: UUID - required_nullable: Union[None, str] - required_not_nullable: str - one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Any] - nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None] - model: "ModelWithUnionProperty" - nullable_model: Union["ModelWithUnionProperty", None] - an_allof_enum_with_overridden_default: AnAllOfEnum = AnAllOfEnum.OVERRIDDEN_DEFAULT - a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") - any_value: Union[Unset, Any] = "default" - an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET - a_not_required_date: Union[Unset, datetime.date] = UNSET - a_not_required_uuid: Union[Unset, UUID] = UNSET - attr_1_leading_digit: Union[Unset, str] = UNSET - attr_leading_underscore: Union[Unset, str] = UNSET - not_required_nullable: Union[None, Unset, str] = UNSET - not_required_not_nullable: Union[Unset, str] = UNSET - not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET - not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET - not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET - not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET - from_extended: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - an_enum_value = self.an_enum_value.value - - an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value - - a_camel_date_time: str - if isinstance(self.a_camel_date_time, datetime.datetime): - a_camel_date_time = self.a_camel_date_time.isoformat() - else: - a_camel_date_time = self.a_camel_date_time.isoformat() - - a_date = self.a_date.isoformat() - - a_nullable_date: Union[None, str] - if isinstance(self.a_nullable_date, datetime.date): - a_nullable_date = self.a_nullable_date.isoformat() - else: - a_nullable_date = self.a_nullable_date - - a_uuid = str(self.a_uuid) - - a_nullable_uuid: Union[None, str] - if isinstance(self.a_nullable_uuid, UUID): - a_nullable_uuid = str(self.a_nullable_uuid) - else: - a_nullable_uuid = self.a_nullable_uuid - - required_nullable: Union[None, str] - required_nullable = self.required_nullable - - required_not_nullable = self.required_not_nullable - - one_of_models: Union[Any, dict[str, Any]] - if isinstance(self.one_of_models, FreeFormModel): - one_of_models = self.one_of_models.to_dict() - elif isinstance(self.one_of_models, ModelWithUnionProperty): - one_of_models = self.one_of_models.to_dict() - else: - one_of_models = self.one_of_models - - nullable_one_of_models: Union[None, dict[str, Any]] - if isinstance(self.nullable_one_of_models, FreeFormModel): - nullable_one_of_models = self.nullable_one_of_models.to_dict() - elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): - nullable_one_of_models = self.nullable_one_of_models.to_dict() - else: - nullable_one_of_models = self.nullable_one_of_models - - model = self.model.to_dict() - - nullable_model: Union[None, dict[str, Any]] - if isinstance(self.nullable_model, ModelWithUnionProperty): - nullable_model = self.nullable_model.to_dict() - else: - nullable_model = self.nullable_model - - any_value = self.any_value - - an_optional_allof_enum: Union[Unset, str] = UNSET - if not isinstance(self.an_optional_allof_enum, Unset): - an_optional_allof_enum = self.an_optional_allof_enum.value - - nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET - if not isinstance(self.nested_list_of_enums, Unset): - nested_list_of_enums = [] - for nested_list_of_enums_item_data in self.nested_list_of_enums: - nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value - nested_list_of_enums_item.append(nested_list_of_enums_item_item) - - nested_list_of_enums.append(nested_list_of_enums_item) - - a_not_required_date: Union[Unset, str] = UNSET - if not isinstance(self.a_not_required_date, Unset): - a_not_required_date = self.a_not_required_date.isoformat() - - a_not_required_uuid: Union[Unset, str] = UNSET - if not isinstance(self.a_not_required_uuid, Unset): - a_not_required_uuid = str(self.a_not_required_uuid) - - attr_1_leading_digit = self.attr_1_leading_digit - - attr_leading_underscore = self.attr_leading_underscore - - not_required_nullable: Union[None, Unset, str] - if isinstance(self.not_required_nullable, Unset): - not_required_nullable = UNSET - else: - not_required_nullable = self.not_required_nullable - - not_required_not_nullable = self.not_required_not_nullable - - not_required_one_of_models: Union[Unset, dict[str, Any]] - if isinstance(self.not_required_one_of_models, Unset): - not_required_one_of_models = UNSET - elif isinstance(self.not_required_one_of_models, FreeFormModel): - not_required_one_of_models = self.not_required_one_of_models.to_dict() - else: - not_required_one_of_models = self.not_required_one_of_models.to_dict() - - not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] - if isinstance(self.not_required_nullable_one_of_models, Unset): - not_required_nullable_one_of_models = UNSET - elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - else: - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models - - not_required_model: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.not_required_model, Unset): - not_required_model = self.not_required_model.to_dict() - - not_required_nullable_model: Union[None, Unset, dict[str, Any]] - if isinstance(self.not_required_nullable_model, Unset): - not_required_nullable_model = UNSET - elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): - not_required_nullable_model = self.not_required_nullable_model.to_dict() - else: - not_required_nullable_model = self.not_required_nullable_model - - from_extended = self.from_extended - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "an_enum_value": an_enum_value, - "an_allof_enum_with_overridden_default": an_allof_enum_with_overridden_default, - "aCamelDateTime": a_camel_date_time, - "a_date": a_date, - "a_nullable_date": a_nullable_date, - "a_uuid": a_uuid, - "a_nullable_uuid": a_nullable_uuid, - "required_nullable": required_nullable, - "required_not_nullable": required_not_nullable, - "one_of_models": one_of_models, - "nullable_one_of_models": nullable_one_of_models, - "model": model, - "nullable_model": nullable_model, - } - ) - if any_value is not UNSET: - field_dict["any_value"] = any_value - if an_optional_allof_enum is not UNSET: - field_dict["an_optional_allof_enum"] = an_optional_allof_enum - if nested_list_of_enums is not UNSET: - field_dict["nested_list_of_enums"] = nested_list_of_enums - if a_not_required_date is not UNSET: - field_dict["a_not_required_date"] = a_not_required_date - if a_not_required_uuid is not UNSET: - field_dict["a_not_required_uuid"] = a_not_required_uuid - if attr_1_leading_digit is not UNSET: - field_dict["1_leading_digit"] = attr_1_leading_digit - if attr_leading_underscore is not UNSET: - field_dict["_leading_underscore"] = attr_leading_underscore - if not_required_nullable is not UNSET: - field_dict["not_required_nullable"] = not_required_nullable - if not_required_not_nullable is not UNSET: - field_dict["not_required_not_nullable"] = not_required_not_nullable - if not_required_one_of_models is not UNSET: - field_dict["not_required_one_of_models"] = not_required_one_of_models - if not_required_nullable_one_of_models is not UNSET: - field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models - if not_required_model is not UNSET: - field_dict["not_required_model"] = not_required_model - if not_required_nullable_model is not UNSET: - field_dict["not_required_nullable_model"] = not_required_nullable_model - if from_extended is not UNSET: - field_dict["fromExtended"] = from_extended - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty - - d = src_dict.copy() - an_enum_value = AnEnum(d.pop("an_enum_value")) - - an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) - - def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: - try: - if not isinstance(data, str): - raise TypeError() - a_camel_date_time_type_0 = isoparse(data) - - return a_camel_date_time_type_0 - except: # noqa: E722 - pass - if not isinstance(data, str): - raise TypeError() - a_camel_date_time_type_1 = isoparse(data).date() - - return a_camel_date_time_type_1 - - a_camel_date_time = _parse_a_camel_date_time(d.pop("aCamelDateTime")) - - a_date = isoparse(d.pop("a_date")).date() - - def _parse_a_nullable_date(data: object) -> Union[None, datetime.date]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - a_nullable_date_type_0 = isoparse(data).date() - - return a_nullable_date_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.date], data) - - a_nullable_date = _parse_a_nullable_date(d.pop("a_nullable_date")) - - a_uuid = UUID(d.pop("a_uuid")) - - def _parse_a_nullable_uuid(data: object) -> Union[None, UUID]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - a_nullable_uuid_type_0 = UUID(data) - - return a_nullable_uuid_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID], data) - - a_nullable_uuid = _parse_a_nullable_uuid(d.pop("a_nullable_uuid")) - - def _parse_required_nullable(data: object) -> Union[None, str]: - if data is None: - return data - return cast(Union[None, str], data) - - required_nullable = _parse_required_nullable(d.pop("required_nullable")) - - required_not_nullable = d.pop("required_not_nullable") - - def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: - try: - if not isinstance(data, dict): - raise TypeError() - one_of_models_type_0 = FreeFormModel.from_dict(data) - - return one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", Any], data) - - one_of_models = _parse_one_of_models(d.pop("one_of_models")) - - def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: - if data is None: - return data - try: - if not isinstance(data, dict): - raise TypeError() - nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return nullable_one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return nullable_one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) - - nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) - - model = ModelWithUnionProperty.from_dict(d.pop("model")) - - def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: - if data is None: - return data - try: - if not isinstance(data, dict): - raise TypeError() - nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) - - return nullable_model_type_1 - except: # noqa: E722 - pass - return cast(Union["ModelWithUnionProperty", None], data) - - nullable_model = _parse_nullable_model(d.pop("nullable_model")) - - any_value = d.pop("any_value", UNSET) - - _an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET) - an_optional_allof_enum: Union[Unset, AnAllOfEnum] - if isinstance(_an_optional_allof_enum, Unset): - an_optional_allof_enum = UNSET - else: - an_optional_allof_enum = AnAllOfEnum(_an_optional_allof_enum) - - nested_list_of_enums = [] - _nested_list_of_enums = d.pop("nested_list_of_enums", UNSET) - for nested_list_of_enums_item_data in _nested_list_of_enums or []: - nested_list_of_enums_item = [] - _nested_list_of_enums_item = nested_list_of_enums_item_data - for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) - - nested_list_of_enums_item.append(nested_list_of_enums_item_item) - - nested_list_of_enums.append(nested_list_of_enums_item) - - _a_not_required_date = d.pop("a_not_required_date", UNSET) - a_not_required_date: Union[Unset, datetime.date] - if isinstance(_a_not_required_date, Unset): - a_not_required_date = UNSET - else: - a_not_required_date = isoparse(_a_not_required_date).date() - - _a_not_required_uuid = d.pop("a_not_required_uuid", UNSET) - a_not_required_uuid: Union[Unset, UUID] - if isinstance(_a_not_required_uuid, Unset): - a_not_required_uuid = UNSET - else: - a_not_required_uuid = UUID(_a_not_required_uuid) - - attr_1_leading_digit = d.pop("1_leading_digit", UNSET) - - attr_leading_underscore = d.pop("_leading_underscore", UNSET) - - def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(Union[None, Unset, str], data) - - not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) - - not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) - - def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return not_required_one_of_models_type_0 - except: # noqa: E722 - pass - if not isinstance(data, dict): - raise TypeError() - not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_one_of_models_type_1 - - not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) - - def _parse_not_required_nullable_one_of_models( - data: object, - ) -> Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) - - return not_required_nullable_one_of_models_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_nullable_one_of_models_type_1 - except: # noqa: E722 - pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) - - not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( - d.pop("not_required_nullable_one_of_models", UNSET) - ) - - _not_required_model = d.pop("not_required_model", UNSET) - not_required_model: Union[Unset, ModelWithUnionProperty] - if isinstance(_not_required_model, Unset): - not_required_model = UNSET - else: - not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) - - def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) - - return not_required_nullable_model_type_1 - except: # noqa: E722 - pass - return cast(Union["ModelWithUnionProperty", None, Unset], data) - - not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) - - from_extended = d.pop("fromExtended", UNSET) - - extended = cls( - an_enum_value=an_enum_value, - an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, - a_camel_date_time=a_camel_date_time, - a_date=a_date, - a_nullable_date=a_nullable_date, - a_uuid=a_uuid, - a_nullable_uuid=a_nullable_uuid, - required_nullable=required_nullable, - required_not_nullable=required_not_nullable, - one_of_models=one_of_models, - nullable_one_of_models=nullable_one_of_models, - model=model, - nullable_model=nullable_model, - any_value=any_value, - an_optional_allof_enum=an_optional_allof_enum, - nested_list_of_enums=nested_list_of_enums, - a_not_required_date=a_not_required_date, - a_not_required_uuid=a_not_required_uuid, - attr_1_leading_digit=attr_1_leading_digit, - attr_leading_underscore=attr_leading_underscore, - not_required_nullable=not_required_nullable, - not_required_not_nullable=not_required_not_nullable, - not_required_one_of_models=not_required_one_of_models, - not_required_nullable_one_of_models=not_required_nullable_one_of_models, - not_required_model=not_required_model, - not_required_nullable_model=not_required_nullable_model, - from_extended=from_extended, - ) - - extended.additional_properties = d - return extended - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py deleted file mode 100644 index 02b85bb19..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/free_form_model.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="FreeFormModel") - - -@_attrs_define -class FreeFormModel: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - free_form_model = cls() - - free_form_model.additional_properties = d - return free_form_model - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py deleted file mode 100644 index d3c23f16b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_int_enum_header.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import IntEnum - - -class GetLocationHeaderTypesIntEnumHeader(IntEnum): - VALUE_1 = 1 - VALUE_2 = 2 - VALUE_3 = 3 - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py deleted file mode 100644 index cce92dcde..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import Enum - - -class GetLocationHeaderTypesStringEnumHeader(str, Enum): - ONE = "one" - THREE = "three" - TWO = "two" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py deleted file mode 100644 index a3793ec9a..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_allof_response_200.py +++ /dev/null @@ -1,100 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.a_model import AModel - from ..models.extended import Extended - - -T = TypeVar("T", bound="GetModelsAllofResponse200") - - -@_attrs_define -class GetModelsAllofResponse200: - aliased: Union[Unset, "AModel"] = UNSET - """ A Model for testing all the ways custom objects can be used """ - extended: Union[Unset, "Extended"] = UNSET - model: Union[Unset, "AModel"] = UNSET - """ A Model for testing all the ways custom objects can be used """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - aliased: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.aliased, Unset): - aliased = self.aliased.to_dict() - - extended: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.extended, Unset): - extended = self.extended.to_dict() - - model: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.model, Unset): - model = self.model.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if aliased is not UNSET: - field_dict["aliased"] = aliased - if extended is not UNSET: - field_dict["extended"] = extended - if model is not UNSET: - field_dict["model"] = model - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.a_model import AModel - from ..models.extended import Extended - - d = src_dict.copy() - _aliased = d.pop("aliased", UNSET) - aliased: Union[Unset, AModel] - if isinstance(_aliased, Unset): - aliased = UNSET - else: - aliased = AModel.from_dict(_aliased) - - _extended = d.pop("extended", UNSET) - extended: Union[Unset, Extended] - if isinstance(_extended, Unset): - extended = UNSET - else: - extended = Extended.from_dict(_extended) - - _model = d.pop("model", UNSET) - model: Union[Unset, AModel] - if isinstance(_model, Unset): - model = UNSET - else: - model = AModel.from_dict(_model) - - get_models_allof_response_200 = cls( - aliased=aliased, - extended=extended, - model=model, - ) - - get_models_allof_response_200.additional_properties = d - return get_models_allof_response_200 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py deleted file mode 100644 index ed3a89e3b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py +++ /dev/null @@ -1,65 +0,0 @@ -from typing import Any, Literal, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetModelsOneofWithRequiredConstResponse200Type0") - - -@_attrs_define -class GetModelsOneofWithRequiredConstResponse200Type0: - type_: Literal["alpha"] - color: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - type_ = self.type_ - - color = self.color - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "type": type_, - } - ) - if color is not UNSET: - field_dict["color"] = color - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - type_ = cast(Literal["alpha"], d.pop("type")) - if type_ != "alpha": - raise ValueError(f"type must match const 'alpha', got '{type_}'") - - color = d.pop("color", UNSET) - - get_models_oneof_with_required_const_response_200_type_0 = cls( - type_=type_, - color=color, - ) - - get_models_oneof_with_required_const_response_200_type_0.additional_properties = d - return get_models_oneof_with_required_const_response_200_type_0 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py deleted file mode 100644 index 7d96cc6bf..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py +++ /dev/null @@ -1,65 +0,0 @@ -from typing import Any, Literal, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="GetModelsOneofWithRequiredConstResponse200Type1") - - -@_attrs_define -class GetModelsOneofWithRequiredConstResponse200Type1: - type_: Literal["beta"] - texture: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - type_ = self.type_ - - texture = self.texture - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "type": type_, - } - ) - if texture is not UNSET: - field_dict["texture"] = texture - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - type_ = cast(Literal["beta"], d.pop("type")) - if type_ != "beta": - raise ValueError(f"type must match const 'beta', got '{type_}'") - - texture = d.pop("texture", UNSET) - - get_models_oneof_with_required_const_response_200_type_1 = cls( - type_=type_, - texture=texture, - ) - - get_models_oneof_with_required_const_response_200_type_1.additional_properties = d - return get_models_oneof_with_required_const_response_200_type_1 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py deleted file mode 100644 index 97476a53d..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/http_validation_error.py +++ /dev/null @@ -1,49 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.validation_error import ValidationError - - -T = TypeVar("T", bound="HTTPValidationError") - - -@_attrs_define -class HTTPValidationError: - detail: Union[Unset, list["ValidationError"]] = UNSET - - def to_dict(self) -> dict[str, Any]: - detail: Union[Unset, list[dict[str, Any]]] = UNSET - if not isinstance(self.detail, Unset): - detail = [] - for detail_item_data in self.detail: - detail_item = detail_item_data.to_dict() - detail.append(detail_item) - - field_dict: dict[str, Any] = {} - field_dict.update({}) - if detail is not UNSET: - field_dict["detail"] = detail - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.validation_error import ValidationError - - d = src_dict.copy() - detail = [] - _detail = d.pop("detail", UNSET) - for detail_item_data in _detail or []: - detail_item = ValidationError.from_dict(detail_item_data) - - detail.append(detail_item) - - http_validation_error = cls( - detail=detail, - ) - - return http_validation_error diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py deleted file mode 100644 index 84c8d9798..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/import_.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="Import") - - -@_attrs_define -class Import: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - import_ = cls() - - import_.additional_properties = d - return import_ - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py deleted file mode 100644 index 9b1ac6d7e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/json_like_body.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="JsonLikeBody") - - -@_attrs_define -class JsonLikeBody: - a: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a = self.a - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a is not UNSET: - field_dict["a"] = a - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a = d.pop("a", UNSET) - - json_like_body = cls( - a=a, - ) - - json_like_body.additional_properties = d - return json_like_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py deleted file mode 100644 index 1ef05db69..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_from_all_of.py +++ /dev/null @@ -1,93 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.another_all_of_sub_model_type import AnotherAllOfSubModelType -from ..models.another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelFromAllOf") - - -@_attrs_define -class ModelFromAllOf: - a_sub_property: Union[Unset, str] = UNSET - type_: Union[Unset, AnotherAllOfSubModelType] = UNSET - type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET - another_sub_property: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a_sub_property = self.a_sub_property - - type_: Union[Unset, str] = UNSET - if not isinstance(self.type_, Unset): - type_ = self.type_.value - - type_enum: Union[Unset, int] = UNSET - if not isinstance(self.type_enum, Unset): - type_enum = self.type_enum.value - - another_sub_property = self.another_sub_property - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a_sub_property is not UNSET: - field_dict["a_sub_property"] = a_sub_property - if type_ is not UNSET: - field_dict["type"] = type_ - if type_enum is not UNSET: - field_dict["type_enum"] = type_enum - if another_sub_property is not UNSET: - field_dict["another_sub_property"] = another_sub_property - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_sub_property = d.pop("a_sub_property", UNSET) - - _type_ = d.pop("type", UNSET) - type_: Union[Unset, AnotherAllOfSubModelType] - if isinstance(_type_, Unset): - type_ = UNSET - else: - type_ = AnotherAllOfSubModelType(_type_) - - _type_enum = d.pop("type_enum", UNSET) - type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] - if isinstance(_type_enum, Unset): - type_enum = UNSET - else: - type_enum = AnotherAllOfSubModelTypeEnum(_type_enum) - - another_sub_property = d.pop("another_sub_property", UNSET) - - model_from_all_of = cls( - a_sub_property=a_sub_property, - type_=type_, - type_enum=type_enum, - another_sub_property=another_sub_property, - ) - - model_from_all_of.additional_properties = d - return model_from_all_of - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py deleted file mode 100644 index aec25aa25..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_name.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ModelName") - - -@_attrs_define -class ModelName: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_name = cls() - - model_name.additional_properties = d - return model_name - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py deleted file mode 100644 index 004ed9b20..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_reference_with_periods.py +++ /dev/null @@ -1,43 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ModelReferenceWithPeriods") - - -@_attrs_define -class ModelReferenceWithPeriods: - """A Model with periods in its reference""" - - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_reference_with_periods = cls() - - model_reference_with_periods.additional_properties = d - return model_reference_with_periods - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py deleted file mode 100644 index 21e5d5b62..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py +++ /dev/null @@ -1,72 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_with_additional_properties_inlined_additional_property import ( - ModelWithAdditionalPropertiesInlinedAdditionalProperty, - ) - - -T = TypeVar("T", bound="ModelWithAdditionalPropertiesInlined") - - -@_attrs_define -class ModelWithAdditionalPropertiesInlined: - a_number: Union[Unset, float] = UNSET - additional_properties: dict[str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty"] = _attrs_field( - init=False, factory=dict - ) - - def to_dict(self) -> dict[str, Any]: - a_number = self.a_number - - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.to_dict() - field_dict.update({}) - if a_number is not UNSET: - field_dict["a_number"] = a_number - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_additional_properties_inlined_additional_property import ( - ModelWithAdditionalPropertiesInlinedAdditionalProperty, - ) - - d = src_dict.copy() - a_number = d.pop("a_number", UNSET) - - model_with_additional_properties_inlined = cls( - a_number=a_number, - ) - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_additional_properties_inlined.additional_properties = additional_properties - return model_with_additional_properties_inlined - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> "ModelWithAdditionalPropertiesInlinedAdditionalProperty": - return self.additional_properties[key] - - def __setitem__(self, key: str, value: "ModelWithAdditionalPropertiesInlinedAdditionalProperty") -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py deleted file mode 100644 index 08d29f18f..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithAdditionalPropertiesInlinedAdditionalProperty") - - -@_attrs_define -class ModelWithAdditionalPropertiesInlinedAdditionalProperty: - extra_props_prop: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - extra_props_prop = self.extra_props_prop - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if extra_props_prop is not UNSET: - field_dict["extra_props_prop"] = extra_props_prop - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - extra_props_prop = d.pop("extra_props_prop", UNSET) - - model_with_additional_properties_inlined_additional_property = cls( - extra_props_prop=extra_props_prop, - ) - - model_with_additional_properties_inlined_additional_property.additional_properties = d - return model_with_additional_properties_inlined_additional_property - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py deleted file mode 100644 index e2d2b37c1..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_additional_properties_refed.py +++ /dev/null @@ -1,50 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..models.an_enum import AnEnum - -T = TypeVar("T", bound="ModelWithAdditionalPropertiesRefed") - - -@_attrs_define -class ModelWithAdditionalPropertiesRefed: - additional_properties: dict[str, AnEnum] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.value - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_with_additional_properties_refed = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = AnEnum(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_additional_properties_refed.additional_properties = additional_properties - return model_with_additional_properties_refed - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> AnEnum: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: AnEnum) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py deleted file mode 100644 index eef2dccad..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties.py +++ /dev/null @@ -1,100 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.model_with_any_json_properties_additional_property_type_0 import ( - ModelWithAnyJsonPropertiesAdditionalPropertyType0, - ) - - -T = TypeVar("T", bound="ModelWithAnyJsonProperties") - - -@_attrs_define -class ModelWithAnyJsonProperties: - additional_properties: dict[ - str, Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str] - ] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - from ..models.model_with_any_json_properties_additional_property_type_0 import ( - ModelWithAnyJsonPropertiesAdditionalPropertyType0, - ) - - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - if isinstance(prop, ModelWithAnyJsonPropertiesAdditionalPropertyType0): - field_dict[prop_name] = prop.to_dict() - elif isinstance(prop, list): - field_dict[prop_name] = prop - - else: - field_dict[prop_name] = prop - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_any_json_properties_additional_property_type_0 import ( - ModelWithAnyJsonPropertiesAdditionalPropertyType0, - ) - - d = src_dict.copy() - model_with_any_json_properties = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - - def _parse_additional_property( - data: object, - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: - try: - if not isinstance(data, dict): - raise TypeError() - additional_property_type_0 = ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict(data) - - return additional_property_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, list): - raise TypeError() - additional_property_type_1 = cast(list[str], data) - - return additional_property_type_1 - except: # noqa: E722 - pass - return cast( - Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], data - ) - - additional_property = _parse_additional_property(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_any_json_properties.additional_properties = additional_properties - return model_with_any_json_properties - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__( - self, key: str - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: - return self.additional_properties[key] - - def __setitem__( - self, - key: str, - value: Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], - ) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py deleted file mode 100644 index ecd9b4e57..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ModelWithAnyJsonPropertiesAdditionalPropertyType0") - - -@_attrs_define -class ModelWithAnyJsonPropertiesAdditionalPropertyType0: - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_with_any_json_properties_additional_property_type_0 = cls() - - model_with_any_json_properties_additional_property_type_0.additional_properties = d - return model_with_any_json_properties_additional_property_type_0 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py deleted file mode 100644 index 0b5dfc3b5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_backslash_in_description.py +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ModelWithBackslashInDescription") - - -@_attrs_define -class ModelWithBackslashInDescription: - r""" Description with special character: \ - - """ - - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_with_backslash_in_description = cls() - - model_with_backslash_in_description.additional_properties = d - return model_with_backslash_in_description - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py deleted file mode 100644 index 2df72cc86..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_a.py +++ /dev/null @@ -1,66 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_with_circular_ref_b import ModelWithCircularRefB - - -T = TypeVar("T", bound="ModelWithCircularRefA") - - -@_attrs_define -class ModelWithCircularRefA: - circular: Union[Unset, "ModelWithCircularRefB"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - circular: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.circular, Unset): - circular = self.circular.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if circular is not UNSET: - field_dict["circular"] = circular - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_circular_ref_b import ModelWithCircularRefB - - d = src_dict.copy() - _circular = d.pop("circular", UNSET) - circular: Union[Unset, ModelWithCircularRefB] - if isinstance(_circular, Unset): - circular = UNSET - else: - circular = ModelWithCircularRefB.from_dict(_circular) - - model_with_circular_ref_a = cls( - circular=circular, - ) - - model_with_circular_ref_a.additional_properties = d - return model_with_circular_ref_a - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py deleted file mode 100644 index 789da806e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_b.py +++ /dev/null @@ -1,66 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_with_circular_ref_a import ModelWithCircularRefA - - -T = TypeVar("T", bound="ModelWithCircularRefB") - - -@_attrs_define -class ModelWithCircularRefB: - circular: Union[Unset, "ModelWithCircularRefA"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - circular: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.circular, Unset): - circular = self.circular.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if circular is not UNSET: - field_dict["circular"] = circular - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_circular_ref_a import ModelWithCircularRefA - - d = src_dict.copy() - _circular = d.pop("circular", UNSET) - circular: Union[Unset, ModelWithCircularRefA] - if isinstance(_circular, Unset): - circular = UNSET - else: - circular = ModelWithCircularRefA.from_dict(_circular) - - model_with_circular_ref_b = cls( - circular=circular, - ) - - model_with_circular_ref_b.additional_properties = d - return model_with_circular_ref_b - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py deleted file mode 100644 index 5b7755a22..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py +++ /dev/null @@ -1,58 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB - - -T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesA") - - -@_attrs_define -class ModelWithCircularRefInAdditionalPropertiesA: - additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = _attrs_field( - init=False, factory=dict - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.to_dict() - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_circular_ref_in_additional_properties_b import ( - ModelWithCircularRefInAdditionalPropertiesB, - ) - - d = src_dict.copy() - model_with_circular_ref_in_additional_properties_a = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = ModelWithCircularRefInAdditionalPropertiesB.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_circular_ref_in_additional_properties_a.additional_properties = additional_properties - return model_with_circular_ref_in_additional_properties_a - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesB": - return self.additional_properties[key] - - def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesB") -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py deleted file mode 100644 index 906794ccf..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py +++ /dev/null @@ -1,58 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA - - -T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesB") - - -@_attrs_define -class ModelWithCircularRefInAdditionalPropertiesB: - additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = _attrs_field( - init=False, factory=dict - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.to_dict() - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_circular_ref_in_additional_properties_a import ( - ModelWithCircularRefInAdditionalPropertiesA, - ) - - d = src_dict.copy() - model_with_circular_ref_in_additional_properties_b = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = ModelWithCircularRefInAdditionalPropertiesA.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_circular_ref_in_additional_properties_b.additional_properties = additional_properties - return model_with_circular_ref_in_additional_properties_b - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesA": - return self.additional_properties[key] - - def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesA") -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py deleted file mode 100644 index d39dd2879..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_date_time_property.py +++ /dev/null @@ -1,62 +0,0 @@ -import datetime -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithDateTimeProperty") - - -@_attrs_define -class ModelWithDateTimeProperty: - datetime_: Union[Unset, datetime.datetime] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - datetime_: Union[Unset, str] = UNSET - if not isinstance(self.datetime_, Unset): - datetime_ = self.datetime_.isoformat() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if datetime_ is not UNSET: - field_dict["datetime"] = datetime_ - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - _datetime_ = d.pop("datetime", UNSET) - datetime_: Union[Unset, datetime.datetime] - if isinstance(_datetime_, Unset): - datetime_ = UNSET - else: - datetime_ = isoparse(_datetime_) - - model_with_date_time_property = cls( - datetime_=datetime_, - ) - - model_with_date_time_property.additional_properties = d - return model_with_date_time_property - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py new file mode 100644 index 000000000..dde413e66 --- /dev/null +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py @@ -0,0 +1,77 @@ +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ModelWithDescription") + + +@_attrs_define +class ModelWithDescription: + """This is a nice model.""" + + prop_with_no_desc: Union[Unset, str] = UNSET + prop_with_desc: Union[Unset, str] = UNSET + """ This is a nice property. """ + prop_with_long_desc: Union[Unset, str] = UNSET + """ It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of + foolishness, + it was the epoch of belief, it was the epoch of incredulity, it was the season of light, it was the season of + darkness, it was the spring of hope, it was the winter of despair. + """ + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + prop_with_no_desc = self.prop_with_no_desc + + prop_with_desc = self.prop_with_desc + + prop_with_long_desc = self.prop_with_long_desc + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if prop_with_no_desc is not UNSET: + field_dict["propWithNoDesc"] = prop_with_no_desc + if prop_with_desc is not UNSET: + field_dict["propWithDesc"] = prop_with_desc + if prop_with_long_desc is not UNSET: + field_dict["propWithLongDesc"] = prop_with_long_desc + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + d = src_dict.copy() + prop_with_no_desc = d.pop("propWithNoDesc", UNSET) + + prop_with_desc = d.pop("propWithDesc", UNSET) + + prop_with_long_desc = d.pop("propWithLongDesc", UNSET) + + model_with_description = cls( + prop_with_no_desc=prop_with_no_desc, + prop_with_desc=prop_with_desc, + prop_with_long_desc=prop_with_long_desc, + ) + + model_with_description.additional_properties = d + return model_with_description + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py deleted file mode 100644 index 709b0a045..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_discriminated_union.py +++ /dev/null @@ -1,98 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 - from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 - - -T = TypeVar("T", bound="ModelWithDiscriminatedUnion") - - -@_attrs_define -class ModelWithDiscriminatedUnion: - discriminated_union: Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 - from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 - - discriminated_union: Union[None, Unset, dict[str, Any]] - if isinstance(self.discriminated_union, Unset): - discriminated_union = UNSET - elif isinstance(self.discriminated_union, ADiscriminatedUnionType1): - discriminated_union = self.discriminated_union.to_dict() - elif isinstance(self.discriminated_union, ADiscriminatedUnionType2): - discriminated_union = self.discriminated_union.to_dict() - else: - discriminated_union = self.discriminated_union - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if discriminated_union is not UNSET: - field_dict["discriminated_union"] = discriminated_union - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 - from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 - - d = src_dict.copy() - - def _parse_discriminated_union( - data: object, - ) -> Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - componentsschemas_a_discriminated_union_type_0 = ADiscriminatedUnionType1.from_dict(data) - - return componentsschemas_a_discriminated_union_type_0 - except: # noqa: E722 - pass - try: - if not isinstance(data, dict): - raise TypeError() - componentsschemas_a_discriminated_union_type_1 = ADiscriminatedUnionType2.from_dict(data) - - return componentsschemas_a_discriminated_union_type_1 - except: # noqa: E722 - pass - return cast(Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset], data) - - discriminated_union = _parse_discriminated_union(d.pop("discriminated_union", UNSET)) - - model_with_discriminated_union = cls( - discriminated_union=discriminated_union, - ) - - model_with_discriminated_union.additional_properties = d - return model_with_discriminated_union - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py deleted file mode 100644 index 40e5c8f38..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties.py +++ /dev/null @@ -1,103 +0,0 @@ -import datetime -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithMergedProperties") - - -@_attrs_define -class ModelWithMergedProperties: - simple_string: Union[Unset, str] = "new default" - """ extended simpleString description """ - string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] = ModelWithMergedPropertiesStringToEnum.A - string_to_date: Union[Unset, datetime.date] = UNSET - number_to_int: Union[Unset, int] = UNSET - any_to_string: Union[Unset, str] = "x" - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - simple_string = self.simple_string - - string_to_enum: Union[Unset, str] = UNSET - if not isinstance(self.string_to_enum, Unset): - string_to_enum = self.string_to_enum.value - - string_to_date: Union[Unset, str] = UNSET - if not isinstance(self.string_to_date, Unset): - string_to_date = self.string_to_date.isoformat() - - number_to_int = self.number_to_int - - any_to_string = self.any_to_string - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if simple_string is not UNSET: - field_dict["simpleString"] = simple_string - if string_to_enum is not UNSET: - field_dict["stringToEnum"] = string_to_enum - if string_to_date is not UNSET: - field_dict["stringToDate"] = string_to_date - if number_to_int is not UNSET: - field_dict["numberToInt"] = number_to_int - if any_to_string is not UNSET: - field_dict["anyToString"] = any_to_string - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - simple_string = d.pop("simpleString", UNSET) - - _string_to_enum = d.pop("stringToEnum", UNSET) - string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] - if isinstance(_string_to_enum, Unset): - string_to_enum = UNSET - else: - string_to_enum = ModelWithMergedPropertiesStringToEnum(_string_to_enum) - - _string_to_date = d.pop("stringToDate", UNSET) - string_to_date: Union[Unset, datetime.date] - if isinstance(_string_to_date, Unset): - string_to_date = UNSET - else: - string_to_date = isoparse(_string_to_date).date() - - number_to_int = d.pop("numberToInt", UNSET) - - any_to_string = d.pop("anyToString", UNSET) - - model_with_merged_properties = cls( - simple_string=simple_string, - string_to_enum=string_to_enum, - string_to_date=string_to_date, - number_to_int=number_to_int, - any_to_string=any_to_string, - ) - - model_with_merged_properties.additional_properties = d - return model_with_merged_properties - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py deleted file mode 100644 index 5e146c5eb..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - - -class ModelWithMergedPropertiesStringToEnum(str, Enum): - A = "a" - B = "b" - - def __str__(self) -> str: - return str(self.value) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py similarity index 55% rename from end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py rename to end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py index 1fdf2f20d..374db16a6 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/mixed_case_response_200.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py @@ -5,44 +5,45 @@ from ..types import UNSET, Unset -T = TypeVar("T", bound="MixedCaseResponse200") +T = TypeVar("T", bound="ModelWithNoDescription") @_attrs_define -class MixedCaseResponse200: - mixed_case: Union[Unset, str] = UNSET - mixedCase: Union[Unset, str] = UNSET +class ModelWithNoDescription: + prop_with_no_desc: Union[Unset, str] = UNSET + prop_with_desc: Union[Unset, str] = UNSET + """ This is a nice property. """ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - mixed_case = self.mixed_case + prop_with_no_desc = self.prop_with_no_desc - mixedCase = self.mixedCase + prop_with_desc = self.prop_with_desc field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) - if mixed_case is not UNSET: - field_dict["mixed_case"] = mixed_case - if mixedCase is not UNSET: - field_dict["mixedCase"] = mixedCase + if prop_with_no_desc is not UNSET: + field_dict["propWithNoDesc"] = prop_with_no_desc + if prop_with_desc is not UNSET: + field_dict["propWithDesc"] = prop_with_desc return field_dict @classmethod def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() - mixed_case = d.pop("mixed_case", UNSET) + prop_with_no_desc = d.pop("propWithNoDesc", UNSET) - mixedCase = d.pop("mixedCase", UNSET) + prop_with_desc = d.pop("propWithDesc", UNSET) - mixed_case_response_200 = cls( - mixed_case=mixed_case, - mixedCase=mixedCase, + model_with_no_description = cls( + prop_with_no_desc=prop_with_no_desc, + prop_with_desc=prop_with_desc, ) - mixed_case_response_200.additional_properties = d - return mixed_case_response_200 + model_with_no_description.additional_properties = d + return model_with_no_description @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py deleted file mode 100644 index a1261f931..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_properties.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define - -T = TypeVar("T", bound="ModelWithNoProperties") - - -@_attrs_define -class ModelWithNoProperties: - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - model_with_no_properties = cls() - - return model_with_no_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py deleted file mode 100644 index 5410886e4..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py +++ /dev/null @@ -1,70 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_with_primitive_additional_properties_a_date_holder import ( - ModelWithPrimitiveAdditionalPropertiesADateHolder, - ) - - -T = TypeVar("T", bound="ModelWithPrimitiveAdditionalProperties") - - -@_attrs_define -class ModelWithPrimitiveAdditionalProperties: - a_date_holder: Union[Unset, "ModelWithPrimitiveAdditionalPropertiesADateHolder"] = UNSET - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a_date_holder: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.a_date_holder, Unset): - a_date_holder = self.a_date_holder.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a_date_holder is not UNSET: - field_dict["a_date_holder"] = a_date_holder - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_primitive_additional_properties_a_date_holder import ( - ModelWithPrimitiveAdditionalPropertiesADateHolder, - ) - - d = src_dict.copy() - _a_date_holder = d.pop("a_date_holder", UNSET) - a_date_holder: Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder] - if isinstance(_a_date_holder, Unset): - a_date_holder = UNSET - else: - a_date_holder = ModelWithPrimitiveAdditionalPropertiesADateHolder.from_dict(_a_date_holder) - - model_with_primitive_additional_properties = cls( - a_date_holder=a_date_holder, - ) - - model_with_primitive_additional_properties.additional_properties = d - return model_with_primitive_additional_properties - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> str: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: str) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py deleted file mode 100644 index cc322bcfd..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py +++ /dev/null @@ -1,50 +0,0 @@ -import datetime -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -T = TypeVar("T", bound="ModelWithPrimitiveAdditionalPropertiesADateHolder") - - -@_attrs_define -class ModelWithPrimitiveAdditionalPropertiesADateHolder: - additional_properties: dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.isoformat() - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_with_primitive_additional_properties_a_date_holder = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = isoparse(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_primitive_additional_properties_a_date_holder.additional_properties = additional_properties - return model_with_primitive_additional_properties_a_date_holder - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> datetime.datetime: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: datetime.datetime) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py deleted file mode 100644 index d82d0d7eb..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_property_ref.py +++ /dev/null @@ -1,66 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_name import ModelName - - -T = TypeVar("T", bound="ModelWithPropertyRef") - - -@_attrs_define -class ModelWithPropertyRef: - inner: Union[Unset, "ModelName"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - inner: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.inner, Unset): - inner = self.inner.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if inner is not UNSET: - field_dict["inner"] = inner - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_name import ModelName - - d = src_dict.copy() - _inner = d.pop("inner", UNSET) - inner: Union[Unset, ModelName] - if isinstance(_inner, Unset): - inner = UNSET - else: - inner = ModelName.from_dict(_inner) - - model_with_property_ref = cls( - inner=inner, - ) - - model_with_property_ref.additional_properties = d - return model_with_property_ref - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py deleted file mode 100644 index b97c8c68b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref.py +++ /dev/null @@ -1,60 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithRecursiveRef") - - -@_attrs_define -class ModelWithRecursiveRef: - recursive: Union[Unset, "ModelWithRecursiveRef"] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - recursive: Union[Unset, dict[str, Any]] = UNSET - if not isinstance(self.recursive, Unset): - recursive = self.recursive.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if recursive is not UNSET: - field_dict["recursive"] = recursive - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - _recursive = d.pop("recursive", UNSET) - recursive: Union[Unset, ModelWithRecursiveRef] - if isinstance(_recursive, Unset): - recursive = UNSET - else: - recursive = ModelWithRecursiveRef.from_dict(_recursive) - - model_with_recursive_ref = cls( - recursive=recursive, - ) - - model_with_recursive_ref.additional_properties = d - return model_with_recursive_ref - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py deleted file mode 100644 index 15bf5c7ba..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py +++ /dev/null @@ -1,50 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="ModelWithRecursiveRefInAdditionalProperties") - - -@_attrs_define -class ModelWithRecursiveRefInAdditionalProperties: - additional_properties: dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = _attrs_field( - init=False, factory=dict - ) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = prop.to_dict() - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - model_with_recursive_ref_in_additional_properties = cls() - - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = ModelWithRecursiveRefInAdditionalProperties.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - model_with_recursive_ref_in_additional_properties.additional_properties = additional_properties - return model_with_recursive_ref_in_additional_properties - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> "ModelWithRecursiveRefInAdditionalProperties": - return self.additional_properties[key] - - def __setitem__(self, key: str, value: "ModelWithRecursiveRefInAdditionalProperties") -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py deleted file mode 100644 index 25c5a6d01..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property.py +++ /dev/null @@ -1,59 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define - -from ..models.an_enum import AnEnum -from ..models.an_int_enum import AnIntEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithUnionProperty") - - -@_attrs_define -class ModelWithUnionProperty: - a_property: Union[AnEnum, AnIntEnum, Unset] = UNSET - - def to_dict(self) -> dict[str, Any]: - a_property: Union[Unset, int, str] - if isinstance(self.a_property, Unset): - a_property = UNSET - elif isinstance(self.a_property, AnEnum): - a_property = self.a_property.value - else: - a_property = self.a_property.value - - field_dict: dict[str, Any] = {} - field_dict.update({}) - if a_property is not UNSET: - field_dict["a_property"] = a_property - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - - def _parse_a_property(data: object) -> Union[AnEnum, AnIntEnum, Unset]: - if isinstance(data, Unset): - return data - try: - if not isinstance(data, str): - raise TypeError() - a_property_type_0 = AnEnum(data) - - return a_property_type_0 - except: # noqa: E722 - pass - if not isinstance(data, int): - raise TypeError() - a_property_type_1 = AnIntEnum(data) - - return a_property_type_1 - - a_property = _parse_a_property(d.pop("a_property", UNSET)) - - model_with_union_property = cls( - a_property=a_property, - ) - - return model_with_union_property diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py deleted file mode 100644 index 466c64e76..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined.py +++ /dev/null @@ -1,69 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union - -from attrs import define as _attrs_define - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 - from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 - - -T = TypeVar("T", bound="ModelWithUnionPropertyInlined") - - -@_attrs_define -class ModelWithUnionPropertyInlined: - fruit: Union["ModelWithUnionPropertyInlinedFruitType0", "ModelWithUnionPropertyInlinedFruitType1", Unset] = UNSET - - def to_dict(self) -> dict[str, Any]: - from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 - - fruit: Union[Unset, dict[str, Any]] - if isinstance(self.fruit, Unset): - fruit = UNSET - elif isinstance(self.fruit, ModelWithUnionPropertyInlinedFruitType0): - fruit = self.fruit.to_dict() - else: - fruit = self.fruit.to_dict() - - field_dict: dict[str, Any] = {} - field_dict.update({}) - if fruit is not UNSET: - field_dict["fruit"] = fruit - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 - from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 - - d = src_dict.copy() - - def _parse_fruit( - data: object, - ) -> Union["ModelWithUnionPropertyInlinedFruitType0", "ModelWithUnionPropertyInlinedFruitType1", Unset]: - if isinstance(data, Unset): - return data - try: - if not isinstance(data, dict): - raise TypeError() - fruit_type_0 = ModelWithUnionPropertyInlinedFruitType0.from_dict(data) - - return fruit_type_0 - except: # noqa: E722 - pass - if not isinstance(data, dict): - raise TypeError() - fruit_type_1 = ModelWithUnionPropertyInlinedFruitType1.from_dict(data) - - return fruit_type_1 - - fruit = _parse_fruit(d.pop("fruit", UNSET)) - - model_with_union_property_inlined = cls( - fruit=fruit, - ) - - return model_with_union_property_inlined diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py deleted file mode 100644 index 48b19e4bc..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithUnionPropertyInlinedFruitType0") - - -@_attrs_define -class ModelWithUnionPropertyInlinedFruitType0: - apples: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - apples = self.apples - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if apples is not UNSET: - field_dict["apples"] = apples - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - apples = d.pop("apples", UNSET) - - model_with_union_property_inlined_fruit_type_0 = cls( - apples=apples, - ) - - model_with_union_property_inlined_fruit_type_0.additional_properties = d - return model_with_union_property_inlined_fruit_type_0 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py deleted file mode 100644 index e5f1f16f5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ModelWithUnionPropertyInlinedFruitType1") - - -@_attrs_define -class ModelWithUnionPropertyInlinedFruitType1: - bananas: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - bananas = self.bananas - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if bananas is not UNSET: - field_dict["bananas"] = bananas - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - bananas = d.pop("bananas", UNSET) - - model_with_union_property_inlined_fruit_type_1 = cls( - bananas=bananas, - ) - - model_with_union_property_inlined_fruit_type_1.additional_properties = d - return model_with_union_property_inlined_fruit_type_1 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py deleted file mode 100644 index f17e0919b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/none.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="None_") - - -@_attrs_define -class None_: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - none = cls() - - none.additional_properties = d - return none - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py deleted file mode 100644 index b6a3b72c5..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostBodiesMultipleDataBody") - - -@_attrs_define -class PostBodiesMultipleDataBody: - a: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a = self.a - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a is not UNSET: - field_dict["a"] = a - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a = d.pop("a", UNSET) - - post_bodies_multiple_data_body = cls( - a=a, - ) - - post_bodies_multiple_data_body.additional_properties = d - return post_bodies_multiple_data_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py deleted file mode 100644 index dea65306c..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py +++ /dev/null @@ -1,66 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostBodiesMultipleFilesBody") - - -@_attrs_define -class PostBodiesMultipleFilesBody: - a: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a = self.a - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a is not UNSET: - field_dict["a"] = a - - return field_dict - - def to_multipart(self) -> dict[str, Any]: - a = self.a if isinstance(self.a, Unset) else (None, str(self.a).encode(), "text/plain") - - field_dict: dict[str, Any] = {} - for prop_name, prop in self.additional_properties.items(): - field_dict[prop_name] = (None, str(prop).encode(), "text/plain") - - field_dict.update({}) - if a is not UNSET: - field_dict["a"] = a - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a = d.pop("a", UNSET) - - post_bodies_multiple_files_body = cls( - a=a, - ) - - post_bodies_multiple_files_body.additional_properties = d - return post_bodies_multiple_files_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py deleted file mode 100644 index e764bec2e..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py +++ /dev/null @@ -1,53 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostBodiesMultipleJsonBody") - - -@_attrs_define -class PostBodiesMultipleJsonBody: - a: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a = self.a - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if a is not UNSET: - field_dict["a"] = a - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a = d.pop("a", UNSET) - - post_bodies_multiple_json_body = cls( - a=a, - ) - - post_bodies_multiple_json_body.additional_properties = d - return post_bodies_multiple_json_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py deleted file mode 100644 index c1abf6b6b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_form_data_inline_body.py +++ /dev/null @@ -1,63 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostFormDataInlineBody") - - -@_attrs_define -class PostFormDataInlineBody: - a_required_field: str - an_optional_field: Union[Unset, str] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - a_required_field = self.a_required_field - - an_optional_field = self.an_optional_field - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "a_required_field": a_required_field, - } - ) - if an_optional_field is not UNSET: - field_dict["an_optional_field"] = an_optional_field - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_required_field = d.pop("a_required_field") - - an_optional_field = d.pop("an_optional_field", UNSET) - - post_form_data_inline_body = cls( - a_required_field=a_required_field, - an_optional_field=an_optional_field, - ) - - post_form_data_inline_body.additional_properties = d - return post_form_data_inline_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py deleted file mode 100644 index dadb2c9c2..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py +++ /dev/null @@ -1,63 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostNamingPropertyConflictWithImportBody") - - -@_attrs_define -class PostNamingPropertyConflictWithImportBody: - field: Union[Unset, str] = UNSET - """ A python_name of field should not interfere with attrs field """ - define: Union[Unset, str] = UNSET - """ A python_name of define should not interfere with attrs define """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field = self.field - - define = self.define - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if field is not UNSET: - field_dict["Field"] = field - if define is not UNSET: - field_dict["Define"] = define - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - field = d.pop("Field", UNSET) - - define = d.pop("Define", UNSET) - - post_naming_property_conflict_with_import_body = cls( - field=field, - define=define, - ) - - post_naming_property_conflict_with_import_body.additional_properties = d - return post_naming_property_conflict_with_import_body - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py deleted file mode 100644 index 3fb02dd44..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py +++ /dev/null @@ -1,63 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="PostNamingPropertyConflictWithImportResponse200") - - -@_attrs_define -class PostNamingPropertyConflictWithImportResponse200: - field: Union[Unset, str] = UNSET - """ A python_name of field should not interfere with attrs field """ - define: Union[Unset, str] = UNSET - """ A python_name of define should not interfere with attrs define """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field = self.field - - define = self.define - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if field is not UNSET: - field_dict["Field"] = field - if define is not UNSET: - field_dict["Define"] = define - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - field = d.pop("Field", UNSET) - - define = d.pop("Define", UNSET) - - post_naming_property_conflict_with_import_response_200 = cls( - field=field, - define=define, - ) - - post_naming_property_conflict_with_import_response_200.additional_properties = d - return post_naming_property_conflict_with_import_response_200 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py deleted file mode 100644 index 1685d1471..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py +++ /dev/null @@ -1,83 +0,0 @@ -from typing import TYPE_CHECKING, Any, TypeVar, Union, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -if TYPE_CHECKING: - from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, - ) - - -T = TypeVar("T", bound="PostResponsesUnionsSimpleBeforeComplexResponse200") - - -@_attrs_define -class PostResponsesUnionsSimpleBeforeComplexResponse200: - a: Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str] - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, - ) - - a: Union[dict[str, Any], str] - if isinstance(self.a, PostResponsesUnionsSimpleBeforeComplexResponse200AType1): - a = self.a.to_dict() - else: - a = self.a - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "a": a, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, - ) - - d = src_dict.copy() - - def _parse_a(data: object) -> Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str]: - try: - if not isinstance(data, dict): - raise TypeError() - a_type_1 = PostResponsesUnionsSimpleBeforeComplexResponse200AType1.from_dict(data) - - return a_type_1 - except: # noqa: E722 - pass - return cast(Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str], data) - - a = _parse_a(d.pop("a")) - - post_responses_unions_simple_before_complex_response_200 = cls( - a=a, - ) - - post_responses_unions_simple_before_complex_response_200.additional_properties = d - return post_responses_unions_simple_before_complex_response_200 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py deleted file mode 100644 index 74b4c03e4..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py +++ /dev/null @@ -1,41 +0,0 @@ -from typing import Any, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -T = TypeVar("T", bound="PostResponsesUnionsSimpleBeforeComplexResponse200AType1") - - -@_attrs_define -class PostResponsesUnionsSimpleBeforeComplexResponse200AType1: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - post_responses_unions_simple_before_complex_response_200a_type_1 = cls() - - post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = d - return post_responses_unions_simple_before_complex_response_200a_type_1 - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py deleted file mode 100644 index 9b794752b..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_body.py +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="TestInlineObjectsBody") - - -@_attrs_define -class TestInlineObjectsBody: - a_property: Union[Unset, str] = UNSET - - def to_dict(self) -> dict[str, Any]: - a_property = self.a_property - - field_dict: dict[str, Any] = {} - field_dict.update({}) - if a_property is not UNSET: - field_dict["a_property"] = a_property - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_property = d.pop("a_property", UNSET) - - test_inline_objects_body = cls( - a_property=a_property, - ) - - return test_inline_objects_body diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py deleted file mode 100644 index 91a46fea2..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/test_inline_objects_response_200.py +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="TestInlineObjectsResponse200") - - -@_attrs_define -class TestInlineObjectsResponse200: - a_property: Union[Unset, str] = UNSET - - def to_dict(self) -> dict[str, Any]: - a_property = self.a_property - - field_dict: dict[str, Any] = {} - field_dict.update({}) - if a_property is not UNSET: - field_dict["a_property"] = a_property - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - a_property = d.pop("a_property", UNSET) - - test_inline_objects_response_200 = cls( - a_property=a_property, - ) - - return test_inline_objects_response_200 diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py deleted file mode 100644 index ff52e8669..000000000 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/validation_error.py +++ /dev/null @@ -1,47 +0,0 @@ -from typing import Any, TypeVar, cast - -from attrs import define as _attrs_define - -T = TypeVar("T", bound="ValidationError") - - -@_attrs_define -class ValidationError: - loc: list[str] - msg: str - type_: str - - def to_dict(self) -> dict[str, Any]: - loc = self.loc - - msg = self.msg - - type_ = self.type_ - - field_dict: dict[str, Any] = {} - field_dict.update( - { - "loc": loc, - "msg": msg, - "type": type_, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - loc = cast(list[str], d.pop("loc")) - - msg = d.pop("msg") - - type_ = d.pop("type") - - validation_error = cls( - loc=loc, - msg=msg, - type_=type_, - ) - - return validation_error diff --git a/end_to_end_tests/docstrings_on_attributes.yml b/end_to_end_tests/docstrings_on_attributes.yml new file mode 100644 index 000000000..22e6e227d --- /dev/null +++ b/end_to_end_tests/docstrings_on_attributes.yml @@ -0,0 +1,32 @@ +openapi: 3.1.0 +info: + title: My Test API + description: An API for testing docstrings_on_attributes behavior + version: 0.1.0 +paths: + {} +components: + schemas: + ModelWithDescription: + type: object + description: This is a nice model. + properties: + propWithNoDesc: + type: string + propWithDesc: + type: string + description: This is a nice property. + propWithLongDesc: + type: string + description: | + It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, + it was the epoch of belief, it was the epoch of incredulity, it was the season of light, it was the season of + darkness, it was the spring of hope, it was the winter of despair. + ModelWithNoDescription: + type: object + properties: + propWithNoDesc: + type: string + propWithDesc: + type: string + description: This is a nice property. diff --git a/end_to_end_tests/regen_golden_record.py b/end_to_end_tests/regen_golden_record.py index 8ae805ed1..ddac817ca 100644 --- a/end_to_end_tests/regen_golden_record.py +++ b/end_to_end_tests/regen_golden_record.py @@ -86,7 +86,7 @@ def regen_metadata_snapshots(): def regen_docstrings_on_attributes_golden_record(): _regenerate( - spec_file_name="baseline_openapi_3.0.json", + spec_file_name="docstrings_on_attributes.yml", golden_record_dir="docstrings-on-attributes-golden-record", config_file_name="docstrings_on_attributes.config.yml", ) diff --git a/integration-tests/pyproject.toml b/integration-tests/pyproject.toml index 559c07f8a..cbcff74c6 100644 --- a/integration-tests/pyproject.toml +++ b/integration-tests/pyproject.toml @@ -24,7 +24,7 @@ dev = [ [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" - + [tool.ruff] line-length = 120 From e47e10190f35c6e6c86246f0f92e8f9dfa64cfc1 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 12:38:00 -0800 Subject: [PATCH 6/9] document config template variable --- .changeset/config-in-templates.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/config-in-templates.md diff --git a/.changeset/config-in-templates.md b/.changeset/config-in-templates.md new file mode 100644 index 000000000..7b34f7497 --- /dev/null +++ b/.changeset/config-in-templates.md @@ -0,0 +1,7 @@ +--- +default: minor +--- + +# Make `config` available in custom templates + +The configuration options object is now exposed as a variable called `config` in Jinja2 templates. From f894bb58fbe6ac18fe5ab2dcf8fc94b9612b7659 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 7 Jan 2025 12:45:24 -0800 Subject: [PATCH 7/9] fix test --- end_to_end_tests/test_end_to_end.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index efa8da4f3..2d7238a2c 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -195,7 +195,7 @@ def test_none_meta(): def test_docstrings_on_attributes(): config_path = Path(__file__).parent / "docstrings_on_attributes.config.yml" run_e2e_test( - "baseline_openapi_3.1.yaml", + "docstrings_on_attributes.yml", [f"--config={config_path}"], {}, "docstrings-on-attributes-golden-record", From 457f96328e05001500e1c139a92a8887a6a0e2d2 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Mon, 13 Jan 2025 11:02:02 -0800 Subject: [PATCH 8/9] rm unnecessary test config --- .../docstrings_on_attributes.config.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/end_to_end_tests/docstrings_on_attributes.config.yml b/end_to_end_tests/docstrings_on_attributes.config.yml index 6341692d5..0b21ad0b5 100644 --- a/end_to_end_tests/docstrings_on_attributes.config.yml +++ b/end_to_end_tests/docstrings_on_attributes.config.yml @@ -1,15 +1 @@ -class_overrides: - _ABCResponse: - class_name: ABCResponse - module_name: abc_response - AnEnumValueItem: - class_name: AnEnumValue - module_name: an_enum_value - NestedListOfEnumsItemItem: - class_name: AnEnumValue - module_name: an_enum_value -field_prefix: attr_ -content_type_overrides: - openapi/python/client: application/json -generate_all_tags: true docstrings_on_attributes: true From 7c3427e212e87feae01a46176a1ced5710436b24 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Mon, 13 Jan 2025 11:52:27 -0800 Subject: [PATCH 9/9] also move docstrings to attributes in client classes --- .../my_test_api_client/client.py | 18 ++----- .../templates/client.py.jinja | 51 ++++++++++++++----- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py index e80446f10..e05334a5f 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py @@ -27,14 +27,10 @@ class Client: ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. - - Attributes: - raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a - status code that was not documented in the source OpenAPI document. Can also be provided as a keyword - argument to the constructor. """ raise_on_unexpected_status: bool = field(default=False, kw_only=True) + """Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. Can also be provided as a keyword argument to the constructor.""" _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") @@ -154,17 +150,10 @@ class AuthenticatedClient: ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. - - Attributes: - raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a - status code that was not documented in the source OpenAPI document. Can also be provided as a keyword - argument to the constructor. - token: The token to use for authentication - prefix: The prefix to use for the Authorization header - auth_header_name: The name of the Authorization header """ raise_on_unexpected_status: bool = field(default=False, kw_only=True) + """Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. Can also be provided as a keyword argument to the constructor.""" _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") @@ -176,8 +165,11 @@ class AuthenticatedClient: _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) token: str + """The token to use for authentication""" prefix: str = "Bearer" + """The prefix to use for the Authorization header""" auth_header_name: str = "Authorization" + """The name of the Authorization header""" def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index aee6096e9..cf0301a9a 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -5,6 +5,31 @@ from attrs import define, field, evolve import httpx +{% set attrs_info = { + "raise_on_unexpected_status": namespace( + type="bool", + default="field(default=False, kw_only=True)", + docstring="Whether or not to raise an errors.UnexpectedStatus if the API returns a status code" + " that was not documented in the source OpenAPI document. Can also be provided as a keyword" + " argument to the constructor." + ), + "token": namespace(type="str", default="", docstring="The token to use for authentication"), + "prefix": namespace(type="str", default='"Bearer"', docstring="The prefix to use for the Authorization header"), + "auth_header_name": namespace(type="str", default='"Authorization"', docstring="The name of the Authorization header"), +} %} + +{% macro attr_in_class_docstring(name) %} +{{ name }}: {{ attrs_info[name].docstring }} +{%- endmacro %} + +{% macro declare_attr(name) %} +{% set attr = attrs_info[name] %} +{{ name }}: {{ attr.type }}{% if attr.default %} = {{ attr.default }}{% endif %} +{% if attr.docstring and config.docstrings_on_attributes +%} +"""{{ attr.docstring }}""" +{%- endif %} +{% endmacro %} + @define class Client: """A class for keeping track of data related to the API @@ -29,14 +54,14 @@ class Client: ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. {% endmacro %} {{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} Attributes: - raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a - status code that was not documented in the source OpenAPI document. Can also be provided as a keyword - argument to the constructor. + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} +{% endif %} """ {% macro attributes() %} - raise_on_unexpected_status: bool = field(default=False, kw_only=True) + {{ declare_attr("raise_on_unexpected_status") | indent(4) }} _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") @@ -147,20 +172,20 @@ class AuthenticatedClient: """A Client which has been authenticated for use on secured endpoints {{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} Attributes: - raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a - status code that was not documented in the source OpenAPI document. Can also be provided as a keyword - argument to the constructor. - token: The token to use for authentication - prefix: The prefix to use for the Authorization header - auth_header_name: The name of the Authorization header + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} + {{ attr_in_class_docstring("token") | indent(8) }} + {{ attr_in_class_docstring("prefix") | indent(8) }} + {{ attr_in_class_docstring("auth_header_name") | indent(8) }} +{% endif %} """ {{ attributes() }} - token: str - prefix: str = "Bearer" - auth_header_name: str = "Authorization" + {{ declare_attr("token") | indent(4) }} + {{ declare_attr("prefix") | indent(4) }} + {{ declare_attr("auth_header_name") | indent(4) }} {{ builders("AuthenticatedClient") }} {{ httpx_stuff("AuthenticatedClient", "self._headers[self.auth_header_name] = f\"{self.prefix} {self.token}\" if self.prefix else self.token") }}