From c26e19cbc0dd9b2ff2a7c8464be373bec29d21c7 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 21 Jul 2022 12:58:46 +0800 Subject: [PATCH] Revert "Add support for string response deserialization (#12910)" This reverts commit b8524bee232a55e28693354ab543b91e3f65629a. --- .../csharp-netcore/ApiClient.mustache | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../petstore/R/docs/AllofTagApiResponse.md | 13 + samples/client/petstore/R/docs/FakeApi.md | 69 + .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 10 +- samples/client/petstore/perl/docs/Pet.md | 20 + .../lib/WWW/OpenAPIClient/Configuration.pm | 170 ++ .../OpenAPIClient-php/lib/Model/MapTest.php | 533 ++++++ .../powershell/docs/OuterEnumDefaultValue.md | 20 + .../src/PSPetstore/Model/DogAllOf.ps1 | 97 ++ .../petstore/python-asyncio/docs/Pet.md | 16 + .../petstore_api/models/class_model.py | 131 ++ .../models/additional_properties_array.py | 131 ++ .../docs/AdditionalPropertiesClass.md | 21 + .../petstore_api/models/api_response.py | 183 +++ .../python/docs/AdditionalPropertiesNumber.md | 12 + .../model/additional_properties_number.py | 263 +++ .../ruby-faraday/docs/AllOfWithSingleRef.md | 20 + .../models/array_of_array_of_number_only.rb | 221 +++ .../models/additional_properties_class.rb | 232 +++ .../petstore/models/all_of_with_single_ref.rb | 229 +++ .../rust/hyper/petstore/docs/PropertyTest.md | 2 +- .../petstore/src/models/property_test.rs | 2 +- .../petstore-awsv4signature/docs/StoreApi.md | 129 ++ .../reqwest/petstore/docs/PropertyTest.md | 2 +- .../rust/reqwest/petstore/src/models/order.rs | 62 + .../petstore/src/models/property_test.rs | 2 +- .../python-experimental/test/__init__.py | 0 ...s_allows_a_schema_which_should_validate.py | 64 + ...tionalproperties_are_allowed_by_default.py | 39 + ...dditionalproperties_can_exist_by_itself.py | 46 + ...operties_should_not_look_in_applicators.py | 38 + .../python-experimental/test/test_allof.py | 72 + .../test_allof_combined_with_anyof_oneof.py | 88 + .../test/test_allof_simple_types.py | 40 + .../test/test_allof_with_base_schema.py | 89 + .../test/test_allof_with_one_empty_schema.py | 32 + .../test_allof_with_the_first_empty_schema.py | 40 + .../test_allof_with_the_last_empty_schema.py | 40 + .../test/test_allof_with_two_empty_schemas.py | 32 + .../python-experimental/test/test_anyof.py | 54 + .../test/test_anyof_complex_types.py | 70 + .../test/test_anyof_with_base_schema.py | 48 + .../test/test_anyof_with_one_empty_schema.py | 39 + .../test/test_array_type_matches_arrays.py | 82 + .../test_boolean_type_matches_booleans.py | 105 ++ .../python-experimental/test/test_by_int.py | 47 + .../test/test_by_number.py | 47 + .../test/test_by_small_number.py | 40 + .../test/test_date_time_format.py | 69 + .../test/test_email_format.py | 69 + .../test_enum_with0_does_not_match_false.py | 47 + .../test_enum_with1_does_not_match_true.py | 47 + .../test/test_enum_with_escaped_characters.py | 47 + .../test_enum_with_false_does_not_match0.py | 48 + .../test_enum_with_true_does_not_match1.py | 48 + .../test/test_enums_in_properties.py | 93 ++ .../test/test_forbidden_property.py | 50 + .../test/test_hostname_format.py | 69 + .../test_integer_type_matches_integers.py | 97 ++ ...not_raise_error_when_float_division_inf.py | 33 + .../test_invalid_string_value_for_default.py | 43 + .../test/test_ipv4_format.py | 69 + .../test/test_ipv6_format.py | 69 + .../test/test_json_pointer_format.py | 69 + .../test/test_maximum_validation.py | 54 + ...aximum_validation_with_unsigned_integer.py | 54 + .../test/test_maxitems_validation.py | 63 + .../test/test_maxlength_validation.py | 61 + ...axproperties0_means_the_object_is_empty.py | 44 + .../test/test_maxproperties_validation.py | 87 + .../test/test_minimum_validation.py | 54 + ..._minimum_validation_with_signed_integer.py | 76 + .../test/test_minitems_validation.py | 60 + .../test/test_minlength_validation.py | 62 + .../test/test_minproperties_validation.py | 78 + .../test/test_model_not.py | 40 + ...ted_allof_to_check_validation_semantics.py | 40 + ...ted_anyof_to_check_validation_semantics.py | 40 + .../test/test_nested_items.py | 129 ++ ...ted_oneof_to_check_validation_semantics.py | 40 + .../test/test_not_more_complex_schema.py | 53 + .../test/test_nul_characters_in_strings.py | 40 + ..._null_type_matches_only_the_null_object.py | 106 ++ .../test/test_number_type_matches_numbers.py | 96 ++ .../test/test_object_properties_validation.py | 92 ++ .../python-experimental/test/test_oneof.py | 55 + .../test/test_oneof_complex_types.py | 71 + .../test/test_oneof_with_base_schema.py | 48 + .../test/test_oneof_with_empty_schema.py | 40 + .../test/test_pattern_is_not_anchored.py | 32 + .../test/test_pattern_validation.py | 84 + ...test_properties_with_escaped_characters.py | 66 + ...perty_named_ref_that_is_not_a_reference.py | 46 + .../test/test_ref_in_additionalproperties.py | 52 + .../test/test_ref_in_allof.py | 46 + .../test/test_ref_in_anyof.py | 46 + .../test/test_ref_in_items.py | 50 + .../test/test_ref_in_oneof.py | 46 + .../test/test_ref_in_property.py | 52 + .../test/test_required_default_validation.py | 33 + .../test/test_required_validation.py | 68 + .../test/test_required_with_empty_array.py | 33 + .../test/test_simple_enum_validation.py | 40 + .../test/test_string_type_matches_strings.py | 96 ++ ..._do_anything_if_the_property_is_missing.py | 54 + .../test/test_uniqueitems_false_validation.py | 246 +++ .../test/test_uniqueitems_validation.py | 427 +++++ .../test/test_uri_format.py | 69 + .../test/test_uri_reference_format.py | 69 + .../test/test_uri_template_format.py | 69 + .../ruby-client/.openapi-generator/VERSION | 1 + .../petstore/php-laravel/lib/.gitattributes | 5 + .../App/Middleware/InternalServerError.php | 54 + .../app/openapi_server/typing_utils.py | 32 + .../output/no-example-v3/src/client/mod.rs | 464 ++++++ .../output/openapi-v3/docs/AnotherXmlArray.md | 9 + .../output/ops-v3/src/server/mod.rs | 1450 +++++++++++++++++ 123 files changed, 10025 insertions(+), 76 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache index ef4f3e5625f..5bd04c55670 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache @@ -514,10 +514,6 @@ namespace {{packageName}}.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -623,11 +619,7 @@ namespace {{packageName}}.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs index 3c78f717690..ab2eaa766ec 100644 --- a/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/others/csharp-netcore-complex-files/src/Org.OpenAPITools/Client/ApiClient.cs @@ -497,10 +497,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -585,11 +581,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/R/docs/AllofTagApiResponse.md b/samples/client/petstore/R/docs/AllofTagApiResponse.md index e69de29bb2d..14bcc1e22cf 100644 --- a/samples/client/petstore/R/docs/AllofTagApiResponse.md +++ b/samples/client/petstore/R/docs/AllofTagApiResponse.md @@ -0,0 +1,13 @@ +# petstore::AllofTagApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] +**code** | **integer** | | [optional] +**type** | **character** | | [optional] +**message** | **character** | | [optional] + + diff --git a/samples/client/petstore/R/docs/FakeApi.md b/samples/client/petstore/R/docs/FakeApi.md index e69de29bb2d..484ca98a1d6 100644 --- a/samples/client/petstore/R/docs/FakeApi.md +++ b/samples/client/petstore/R/docs/FakeApi.md @@ -0,0 +1,69 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**FakeDataFile**](FakeApi.md#FakeDataFile) | **GET** /fake/data_file | test data_file to ensure it's escaped correctly + + +# **FakeDataFile** +> User FakeDataFile(dummy, var_data_file = var.var_data_file) + +test data_file to ensure it's escaped correctly + + + +### Example +```R +library(petstore) + +var_dummy <- "dummy_example" # character | dummy required parameter +var_var_data_file <- "var_data_file_example" # character | header data file + +#test data_file to ensure it's escaped correctly +api_instance <- FakeApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$FakeDataFile(var_dummy, var_data_file = var_var_data_file, data_file = "result.txt"), + api_instance$FakeDataFile(var_dummy, var_data_file = var_var_data_file), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **dummy** | **character**| dummy required parameter | + **var_data_file** | **character**| header data file | [optional] + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs index 5762fe9cdf8..41df3d29bcf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/ApiClient.cs @@ -512,10 +512,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -614,11 +610,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/ApiClient.cs index 5f589132725..fb2acf28a9b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/ApiClient.cs @@ -513,10 +513,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -615,11 +611,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/ApiClient.cs index 5f589132725..fb2acf28a9b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/ApiClient.cs @@ -513,10 +513,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -615,11 +611,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/ApiClient.cs index 5762fe9cdf8..41df3d29bcf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -512,10 +512,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -614,11 +610,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/ApiClient.cs index 5f589132725..fb2acf28a9b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/ApiClient.cs @@ -513,10 +513,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -615,11 +611,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCoreAndNet47/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCoreAndNet47/src/Org.OpenAPITools/Client/ApiClient.cs index 7923968a68f..92dc7dc97f3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCoreAndNet47/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCoreAndNet47/src/Org.OpenAPITools/Client/ApiClient.cs @@ -512,10 +512,6 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } InterceptResponse(req, response); @@ -614,11 +610,7 @@ namespace Org.OpenAPITools.Client { response.Data = (T)(object)response.RawBytes; } - else if (typeof(T).Name == "String") // for string response - { - response.Data = (T)(object)response.Content; - } - + InterceptResponse(req, response); var result = ToApiResponse(response); diff --git a/samples/client/petstore/perl/docs/Pet.md b/samples/client/petstore/perl/docs/Pet.md index e69de29bb2d..4b47c66b2dc 100644 --- a/samples/client/petstore/perl/docs/Pet.md +++ b/samples/client/petstore/perl/docs/Pet.md @@ -0,0 +1,20 @@ +# WWW::OpenAPIClient::Object::Pet + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::Pet; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **string** | | +**photo_urls** | **ARRAY[string]** | | +**tags** | [**ARRAY[Tag]**](Tag.md) | | [optional] +**status** | **string** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Configuration.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Configuration.pm index e69de29bb2d..5282ac09acb 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Configuration.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Configuration.pm @@ -0,0 +1,170 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Configuration; + +use strict; +use warnings; +use utf8; + +use Log::Any qw($log); +use Carp; + +use constant VERSION => '1.0.0'; + +=head1 Name + + WWW::OpenAPIClient::Configuration - holds the configuration for all WWW::OpenAPIClient Modules + +=head1 new(%parameters) + +=over 4 + +=item http_timeout: (optional) + +Integer. timeout for HTTP requests in seconds + +default: 180 + +=item http_user_agent: (optional) + +String. custom UserAgent header + +default: OpenAPI-Generator/1.0.0/perl + +=item api_key: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). + + api_key => { + secretKey => 'aaaabbbbccccdddd', + anotherKey => '1111222233334444', + }; + +=item api_key_prefix: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. + + api_key_prefix => { + secretKey => 'string', + anotherKey => 'same or some other string', + }; + +=item api_key_in: (optional) + +=item username: (optional) + +String. The username for basic auth. + +=item password: (optional) + +String. The password for basic auth. + +=item access_token: (optional) + +String. The OAuth access token. + +=item base_url: (optional) + +String. The base URL of the API + +default: http://petstore.swagger.io:80/v2 + +=back + +=cut + +sub new { + my ($self, %p) = (shift,@_); + + # class/static variables + $p{http_timeout} //= 180; + $p{http_user_agent} //= 'OpenAPI-Generator/1.0.0/perl'; + + # authentication setting + $p{api_key} //= {}; + $p{api_key_prefix} //= {}; + $p{api_key_in} //= {}; + + # username and password for HTTP basic authentication + $p{username} //= ''; + $p{password} //= ''; + + # access token for OAuth + $p{access_token} //= ''; + + # base_url + $p{base_url} //= 'http://petstore.swagger.io:80/v2'; + + return bless \%p => $self; +} + + +sub get_tokens { + my $self = shift; + + my $tokens = {}; + $tokens->{username} = $self->{username} if $self->{username}; + $tokens->{password} = $self->{password} if $self->{password}; + $tokens->{access_token} = $self->{access_token} if $self->{access_token}; + + foreach my $token_name (keys %{ $self->{api_key} }) { + $tokens->{$token_name}->{token} = $self->{api_key}{$token_name}; + $tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name}; + $tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name}; + } + + return $tokens; +} + +sub clear_tokens { + my $self = shift; + my %tokens = %{$self->get_tokens}; # copy + + $self->{username} = ''; + $self->{password} = ''; + $self->{access_token} = ''; + + $self->{api_key} = {}; + $self->{api_key_prefix} = {}; + $self->{api_key_in} = {}; + + return \%tokens; +} + +sub accept_tokens { + my ($self, $tokens) = @_; + + foreach my $known_name (qw(username password access_token)) { + next unless $tokens->{$known_name}; + $self->{$known_name} = delete $tokens->{$known_name}; + } + + foreach my $token_name (keys %$tokens) { + $self->{api_key}{$token_name} = $tokens->{$token_name}{token}; + if ($tokens->{$token_name}{prefix}) { + $self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix}; + } + my $in = $tokens->{$token_name}->{in} || 'head'; + croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/; + $self->{api_key_in}{$token_name} = $in; + } +} + +1; diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php index e69de29bb2d..899e4a5bb96 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php @@ -0,0 +1,533 @@ + + */ +class MapTest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MapTest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'map_map_of_string' => 'array>', + 'map_of_enum_string' => 'array', + 'direct_map' => 'array', + 'indirect_map' => 'array' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'map_map_of_string' => null, + 'map_of_enum_string' => null, + 'direct_map' => null, + 'indirect_map' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'map_map_of_string' => false, + 'map_of_enum_string' => false, + 'direct_map' => false, + 'indirect_map' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'map_map_of_string' => 'map_map_of_string', + 'map_of_enum_string' => 'map_of_enum_string', + 'direct_map' => 'direct_map', + 'indirect_map' => 'indirect_map' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'map_map_of_string' => 'setMapMapOfString', + 'map_of_enum_string' => 'setMapOfEnumString', + 'direct_map' => 'setDirectMap', + 'indirect_map' => 'setIndirectMap' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'map_map_of_string' => 'getMapMapOfString', + 'map_of_enum_string' => 'getMapOfEnumString', + 'direct_map' => 'getDirectMap', + 'indirect_map' => 'getIndirectMap' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const MAP_OF_ENUM_STRING_UPPER = 'UPPER'; + public const MAP_OF_ENUM_STRING_LOWER = 'lower'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMapOfEnumStringAllowableValues() + { + return [ + self::MAP_OF_ENUM_STRING_UPPER, + self::MAP_OF_ENUM_STRING_LOWER, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('map_map_of_string', $data ?? [], null); + $this->setIfExists('map_of_enum_string', $data ?? [], null); + $this->setIfExists('direct_map', $data ?? [], null); + $this->setIfExists('indirect_map', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets map_map_of_string + * + * @return array>|null + */ + public function getMapMapOfString() + { + return $this->container['map_map_of_string']; + } + + /** + * Sets map_map_of_string + * + * @param array>|null $map_map_of_string map_map_of_string + * + * @return self + */ + public function setMapMapOfString($map_map_of_string) + { + + if (is_null($map_map_of_string)) { + throw new \InvalidArgumentException('non-nullable map_map_of_string cannot be null'); + } + + $this->container['map_map_of_string'] = $map_map_of_string; + + return $this; + } + + /** + * Gets map_of_enum_string + * + * @return array|null + */ + public function getMapOfEnumString() + { + return $this->container['map_of_enum_string']; + } + + /** + * Sets map_of_enum_string + * + * @param array|null $map_of_enum_string map_of_enum_string + * + * @return self + */ + public function setMapOfEnumString($map_of_enum_string) + { + $allowedValues = $this->getMapOfEnumStringAllowableValues(); + if (!is_null($map_of_enum_string) && array_diff($map_of_enum_string, $allowedValues)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'map_of_enum_string', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + + if (is_null($map_of_enum_string)) { + throw new \InvalidArgumentException('non-nullable map_of_enum_string cannot be null'); + } + + $this->container['map_of_enum_string'] = $map_of_enum_string; + + return $this; + } + + /** + * Gets direct_map + * + * @return array|null + */ + public function getDirectMap() + { + return $this->container['direct_map']; + } + + /** + * Sets direct_map + * + * @param array|null $direct_map direct_map + * + * @return self + */ + public function setDirectMap($direct_map) + { + + if (is_null($direct_map)) { + throw new \InvalidArgumentException('non-nullable direct_map cannot be null'); + } + + $this->container['direct_map'] = $direct_map; + + return $this; + } + + /** + * Gets indirect_map + * + * @return array|null + */ + public function getIndirectMap() + { + return $this->container['indirect_map']; + } + + /** + * Sets indirect_map + * + * @param array|null $indirect_map indirect_map + * + * @return self + */ + public function setIndirectMap($indirect_map) + { + + if (is_null($indirect_map)) { + throw new \InvalidArgumentException('non-nullable indirect_map cannot be null'); + } + + $this->container['indirect_map'] = $indirect_map; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/powershell/docs/OuterEnumDefaultValue.md b/samples/client/petstore/powershell/docs/OuterEnumDefaultValue.md index e69de29bb2d..9d4f8e7d0a5 100644 --- a/samples/client/petstore/powershell/docs/OuterEnumDefaultValue.md +++ b/samples/client/petstore/powershell/docs/OuterEnumDefaultValue.md @@ -0,0 +1,20 @@ +# OuterEnumDefaultValue +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Examples + +- Prepare the resource +```powershell +$OuterEnumDefaultValue = Initialize-PSPetstoreOuterEnumDefaultValue +``` + +- Convert the resource to JSON +```powershell +$OuterEnumDefaultValue | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/DogAllOf.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/DogAllOf.ps1 index e69de29bb2d..7737af53e41 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Model/DogAllOf.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/DogAllOf.ps1 @@ -0,0 +1,97 @@ +# +# OpenAPI Petstore +# This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: "" \ +# Version: 1.0.0 +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Breed +No description available. +.OUTPUTS + +DogAllOf +#> + +function Initialize-PSDogAllOf { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String] + ${Breed} + ) + + Process { + 'Creating PSCustomObject: PSPetstore => PSDogAllOf' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "breed" = ${Breed} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to DogAllOf + +.DESCRIPTION + +Convert from JSON to DogAllOf + +.PARAMETER Json + +Json object + +.OUTPUTS + +DogAllOf +#> +function ConvertFrom-PSJsonToDogAllOf { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSPetstore => PSDogAllOf' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in PSDogAllOf + $AllProperties = ("breed") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "breed"))) { #optional property not found + $Breed = $null + } else { + $Breed = $JsonParameters.PSobject.Properties["breed"].value + } + + $PSO = [PSCustomObject]@{ + "breed" = ${Breed} + } + + return $PSO + } + +} + diff --git a/samples/client/petstore/python-asyncio/docs/Pet.md b/samples/client/petstore/python-asyncio/docs/Pet.md index e69de29bb2d..c462e794c89 100644 --- a/samples/client/petstore/python-asyncio/docs/Pet.md +++ b/samples/client/petstore/python-asyncio/docs/Pet.md @@ -0,0 +1,16 @@ +# Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **str** | | +**photo_urls** | **list[str]** | | +**tags** | [**list[Tag]**](Tag.md) | | [optional] +**status** | **str** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py b/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py index e69de29bb2d..84c0de65b47 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from petstore_api.configuration import Configuration + + +class ClassModel(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + '_class': 'str' + } + + attribute_map = { + '_class': '_class' + } + + def __init__(self, _class=None, local_vars_configuration=None): # noqa: E501 + """ClassModel - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self.__class = None + self.discriminator = None + + if _class is not None: + self._class = _class + + @property + def _class(self): + """Gets the _class of this ClassModel. # noqa: E501 + + + :return: The _class of this ClassModel. # noqa: E501 + :rtype: str + """ + return self.__class + + @_class.setter + def _class(self, _class): + """Sets the _class of this ClassModel. + + + :param _class: The _class of this ClassModel. # noqa: E501 + :type _class: str + """ + + self.__class = _class + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(x.to_dict).args + if len(args) == 1: + return x.to_dict() + else: + return x.to_dict(serialize) + else: + return x + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + attr = self.attribute_map.get(attr, attr) if serialize else attr + if isinstance(value, list): + result[attr] = list(map( + lambda x: convert(x), + value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], convert(item[1])), + value.items() + )) + else: + result[attr] = convert(value) + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, ClassModel): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, ClassModel): + return True + + return self.to_dict() != other.to_dict() diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py index e69de29bb2d..c7283e16136 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from petstore_api.configuration import Configuration + + +class AdditionalPropertiesArray(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'name': 'str' + } + + attribute_map = { + 'name': 'name' + } + + def __init__(self, name=None, local_vars_configuration=None): # noqa: E501 + """AdditionalPropertiesArray - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._name = None + self.discriminator = None + + if name is not None: + self.name = name + + @property + def name(self): + """Gets the name of this AdditionalPropertiesArray. # noqa: E501 + + + :return: The name of this AdditionalPropertiesArray. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this AdditionalPropertiesArray. + + + :param name: The name of this AdditionalPropertiesArray. # noqa: E501 + :type name: str + """ + + self._name = name + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(x.to_dict).args + if len(args) == 1: + return x.to_dict() + else: + return x.to_dict(serialize) + else: + return x + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + attr = self.attribute_map.get(attr, attr) if serialize else attr + if isinstance(value, list): + result[attr] = list(map( + lambda x: convert(x), + value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], convert(item[1])), + value.items() + )) + else: + result[attr] = convert(value) + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, AdditionalPropertiesArray): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, AdditionalPropertiesArray): + return True + + return self.to_dict() != other.to_dict() diff --git a/samples/client/petstore/python-tornado/docs/AdditionalPropertiesClass.md b/samples/client/petstore/python-tornado/docs/AdditionalPropertiesClass.md index e69de29bb2d..7e5025e58ce 100644 --- a/samples/client/petstore/python-tornado/docs/AdditionalPropertiesClass.md +++ b/samples/client/petstore/python-tornado/docs/AdditionalPropertiesClass.md @@ -0,0 +1,21 @@ +# AdditionalPropertiesClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_string** | **dict(str, str)** | | [optional] +**map_number** | **dict(str, float)** | | [optional] +**map_integer** | **dict(str, int)** | | [optional] +**map_boolean** | **dict(str, bool)** | | [optional] +**map_array_integer** | **dict(str, list[int])** | | [optional] +**map_array_anytype** | **dict(str, list[object])** | | [optional] +**map_map_string** | **dict(str, dict(str, str))** | | [optional] +**map_map_anytype** | **dict(str, dict(str, object))** | | [optional] +**anytype_1** | **object** | | [optional] +**anytype_2** | **object** | | [optional] +**anytype_3** | **object** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python-tornado/petstore_api/models/api_response.py b/samples/client/petstore/python-tornado/petstore_api/models/api_response.py index e69de29bb2d..bddac1eb10a 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/api_response.py @@ -0,0 +1,183 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec +import pprint +import re # noqa: F401 +import six + +from petstore_api.configuration import Configuration + + +class ApiResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'code': 'int', + 'type': 'str', + 'message': 'str' + } + + attribute_map = { + 'code': 'code', + 'type': 'type', + 'message': 'message' + } + + def __init__(self, code=None, type=None, message=None, local_vars_configuration=None): # noqa: E501 + """ApiResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._code = None + self._type = None + self._message = None + self.discriminator = None + + if code is not None: + self.code = code + if type is not None: + self.type = type + if message is not None: + self.message = message + + @property + def code(self): + """Gets the code of this ApiResponse. # noqa: E501 + + + :return: The code of this ApiResponse. # noqa: E501 + :rtype: int + """ + return self._code + + @code.setter + def code(self, code): + """Sets the code of this ApiResponse. + + + :param code: The code of this ApiResponse. # noqa: E501 + :type code: int + """ + + self._code = code + + @property + def type(self): + """Gets the type of this ApiResponse. # noqa: E501 + + + :return: The type of this ApiResponse. # noqa: E501 + :rtype: str + """ + return self._type + + @type.setter + def type(self, type): + """Sets the type of this ApiResponse. + + + :param type: The type of this ApiResponse. # noqa: E501 + :type type: str + """ + + self._type = type + + @property + def message(self): + """Gets the message of this ApiResponse. # noqa: E501 + + + :return: The message of this ApiResponse. # noqa: E501 + :rtype: str + """ + return self._message + + @message.setter + def message(self, message): + """Sets the message of this ApiResponse. + + + :param message: The message of this ApiResponse. # noqa: E501 + :type message: str + """ + + self._message = message + + def to_dict(self, serialize=False): + """Returns the model properties as a dict""" + result = {} + + def convert(x): + if hasattr(x, "to_dict"): + args = getfullargspec(x.to_dict).args + if len(args) == 1: + return x.to_dict() + else: + return x.to_dict(serialize) + else: + return x + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + attr = self.attribute_map.get(attr, attr) if serialize else attr + if isinstance(value, list): + result[attr] = list(map( + lambda x: convert(x), + value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], convert(item[1])), + value.items() + )) + else: + result[attr] = convert(value) + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, ApiResponse): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, ApiResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/samples/client/petstore/python/docs/AdditionalPropertiesNumber.md b/samples/client/petstore/python/docs/AdditionalPropertiesNumber.md index e69de29bb2d..9af52dc6dcf 100644 --- a/samples/client/petstore/python/docs/AdditionalPropertiesNumber.md +++ b/samples/client/petstore/python/docs/AdditionalPropertiesNumber.md @@ -0,0 +1,12 @@ +# AdditionalPropertiesNumber + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**any string name** | **float** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py index e69de29bb2d..79b1fc5e219 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model/additional_properties_number.py @@ -0,0 +1,263 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + + +class AdditionalPropertiesNumber(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (float,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesNumber - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', True) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """AdditionalPropertiesNumber - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + name (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/samples/client/petstore/ruby-faraday/docs/AllOfWithSingleRef.md b/samples/client/petstore/ruby-faraday/docs/AllOfWithSingleRef.md index e69de29bb2d..3c14ac91c4a 100644 --- a/samples/client/petstore/ruby-faraday/docs/AllOfWithSingleRef.md +++ b/samples/client/petstore/ruby-faraday/docs/AllOfWithSingleRef.md @@ -0,0 +1,20 @@ +# Petstore::AllOfWithSingleRef + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **username** | **String** | | [optional] | +| **single_ref_type** | [**SingleRefType**](SingleRefType.md) | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::AllOfWithSingleRef.new( + username: null, + single_ref_type: null +) +``` + diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index e69de29bb2d..a9080289621 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -0,0 +1,221 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 6.1.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ArrayOfArrayOfNumberOnly + attr_accessor :array_array_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'array_array_number' => :'ArrayArrayNumber' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'array_array_number' => :'Array>' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfArrayOfNumberOnly` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ArrayOfArrayOfNumberOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'array_array_number') + if (value = attributes[:'array_array_number']).is_a?(Array) + self.array_array_number = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + array_array_number == o.array_array_number + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [array_array_number].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index e69de29bb2d..fa4cde27668 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -0,0 +1,232 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 6.1.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class AdditionalPropertiesClass + attr_accessor :map_property + + attr_accessor :map_of_map_property + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'map_property' => :'map_property', + :'map_of_map_property' => :'map_of_map_property' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'map_property' => :'Hash', + :'map_of_map_property' => :'Hash>' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesClass` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesClass`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'map_property') + if (value = attributes[:'map_property']).is_a?(Hash) + self.map_property = value + end + end + + if attributes.key?(:'map_of_map_property') + if (value = attributes[:'map_of_map_property']).is_a?(Hash) + self.map_of_map_property = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + map_property == o.map_property && + map_of_map_property == o.map_of_map_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [map_property, map_of_map_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb index e69de29bb2d..4efc82eac4a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb @@ -0,0 +1,229 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 6.1.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class AllOfWithSingleRef + attr_accessor :username + + attr_accessor :single_ref_type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'username' => :'username', + :'single_ref_type' => :'SingleRefType' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'username' => :'String', + :'single_ref_type' => :'SingleRefType' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'single_ref_type' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AllOfWithSingleRef` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AllOfWithSingleRef`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'single_ref_type') + self.single_ref_type = attributes[:'single_ref_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + username == o.username && + single_ref_type == o.single_ref_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [username, single_ref_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md index a1af8d731a5..3f36c163de0 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<**String**> | | [optional] +**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/property_test.rs b/samples/client/petstore/rust/hyper/petstore/src/models/property_test.rs index 8d200bdaaf4..1c3c4f3f3fc 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/property_test.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/property_test.rs @@ -15,7 +15,7 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct PropertyTest { #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] - pub uuid: Option, + pub uuid: Option, } impl PropertyTest { diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/StoreApi.md index e69de29bb2d..a6b3c572ccc 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/StoreApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/StoreApi.md @@ -0,0 +1,129 @@ +# \StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + + +## delete_order + +> delete_order(order_id) +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **String** | ID of the order that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_inventory + +> ::std::collections::HashMap get_inventory() +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**::std::collections::HashMap** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_order_by_id + +> crate::models::Order get_order_by_id(order_id) +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **i64** | ID of pet that needs to be fetched | [required] | + +### Return type + +[**crate::models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## place_order + +> crate::models::Order place_order(order) +Place an order for a pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order** | [**Order**](Order.md) | order placed for purchasing the pet | [required] | + +### Return type + +[**crate::models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md index a1af8d731a5..3f36c163de0 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<**String**> | | [optional] +**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs index e69de29bb2d..66d211cb579 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// Order : An order for a pets from the pet store + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct Order { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "petId", skip_serializing_if = "Option::is_none")] + pub pet_id: Option, + #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] + pub quantity: Option, + #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] + pub ship_date: Option, + /// Order Status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "complete", skip_serializing_if = "Option::is_none")] + pub complete: Option, +} + +impl Order { + /// An order for a pets from the pet store + pub fn new() -> Order { + Order { + id: None, + pet_id: None, + quantity: None, + ship_date: None, + status: None, + complete: None, + } + } +} + +/// Order Status +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "placed")] + Placed, + #[serde(rename = "approved")] + Approved, + #[serde(rename = "delivered")] + Delivered, +} + +impl Default for Status { + fn default() -> Status { + Self::Placed + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/property_test.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/property_test.rs index 8d200bdaaf4..1c3c4f3f3fc 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/property_test.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/property_test.rs @@ -15,7 +15,7 @@ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct PropertyTest { #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] - pub uuid: Option, + pub uuid: Option, } impl PropertyTest { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..9d9c82d710e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,64 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api import configuration + + +class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): + """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + 12, + }, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..e52b193fdb3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api import configuration + + +class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): + """AdditionalpropertiesAreAllowedByDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_additional_properties_are_allowed_passes(self): + # additional properties are allowed + AdditionalpropertiesAreAllowedByDefault._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..3a6473f23ba --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api import configuration + + +class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): + """AdditionalpropertiesCanExistByItself unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + "foo": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..f296b2ad621 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api import configuration + + +class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): + """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" + _configuration = configuration.Configuration() + + def test_properties_defined_in_allof_are_not_examined_fails(self): + # properties defined in allOf are not examined + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( + { + "foo": + 1, + "bar": + True, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py new file mode 100644 index 00000000000..9337a2edd4c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof import Allof +from unit_test_api import configuration + + +class TestAllof(unittest.TestCase): + """Allof unit test stubs""" + _configuration = configuration.Configuration() + + def test_allof_passes(self): + # allOf + Allof._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_first_fails(self): + # mismatch first + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_second_fails(self): + # mismatch second + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + def test_wrong_type_fails(self): + # wrong type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof._from_openapi_data( + { + "foo": + "baz", + "bar": + "quux", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py new file mode 100644 index 00000000000..56a76b5d052 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof +from unit_test_api import configuration + + +class TestAllofCombinedWithAnyofOneof(unittest.TestCase): + """AllofCombinedWithAnyofOneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_allof_true_anyof_false_oneof_false_fails(self): + # allOf: true, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 2, + _configuration=self._configuration + ) + + def test_allof_false_anyof_false_oneof_true_fails(self): + # allOf: false, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 5, + _configuration=self._configuration + ) + + def test_allof_false_anyof_true_oneof_true_fails(self): + # allOf: false, anyOf: true, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 15, + _configuration=self._configuration + ) + + def test_allof_true_anyof_true_oneof_false_fails(self): + # allOf: true, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 6, + _configuration=self._configuration + ) + + def test_allof_true_anyof_true_oneof_true_passes(self): + # allOf: true, anyOf: true, oneOf: true + AllofCombinedWithAnyofOneof._from_openapi_data( + 30, + _configuration=self._configuration + ) + + def test_allof_true_anyof_false_oneof_true_fails(self): + # allOf: true, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 10, + _configuration=self._configuration + ) + + def test_allof_false_anyof_true_oneof_false_fails(self): + # allOf: false, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_allof_false_anyof_false_oneof_false_fails(self): + # allOf: false, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py new file mode 100644 index 00000000000..db0c8b5b52f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_simple_types import AllofSimpleTypes +from unit_test_api import configuration + + +class TestAllofSimpleTypes(unittest.TestCase): + """AllofSimpleTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_passes(self): + # valid + AllofSimpleTypes._from_openapi_data( + 25, + _configuration=self._configuration + ) + + def test_mismatch_one_fails(self): + # mismatch one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofSimpleTypes._from_openapi_data( + 35, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py new file mode 100644 index 00000000000..f9922161cb0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema +from unit_test_api import configuration + + +class TestAllofWithBaseSchema(unittest.TestCase): + """AllofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_passes(self): + # valid + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "bar": + 2, + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_first_allof_fails(self): + # mismatch first allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "bar": + 2, + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "baz": + None, + }, + _configuration=self._configuration + ) + + def test_mismatch_both_fails(self): + # mismatch both + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_mismatch_second_allof_fails(self): + # mismatch second allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema._from_openapi_data( + { + "foo": + "quux", + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py new file mode 100644 index 00000000000..ac60d408568 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema +from unit_test_api import configuration + + +class TestAllofWithOneEmptySchema(unittest.TestCase): + """AllofWithOneEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithOneEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py new file mode 100644 index 00000000000..5dacdfb9797 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema +from unit_test_api import configuration + + +class TestAllofWithTheFirstEmptySchema(unittest.TestCase): + """AllofWithTheFirstEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheFirstEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheFirstEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py new file mode 100644 index 00000000000..bd425c3147c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema +from unit_test_api import configuration + + +class TestAllofWithTheLastEmptySchema(unittest.TestCase): + """AllofWithTheLastEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheLastEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheLastEmptySchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py new file mode 100644 index 00000000000..45356cece7b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas +from unit_test_api import configuration + + +class TestAllofWithTwoEmptySchemas(unittest.TestCase): + """AllofWithTwoEmptySchemas unit test stubs""" + _configuration = configuration.Configuration() + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithTwoEmptySchemas._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py new file mode 100644 index 00000000000..197c3449a9e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof import Anyof +from unit_test_api import configuration + + +class TestAnyof(unittest.TestCase): + """Anyof unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_anyof_valid_passes(self): + # second anyOf valid + Anyof._from_openapi_data( + 2.5, + _configuration=self._configuration + ) + + def test_neither_anyof_valid_fails(self): + # neither anyOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Anyof._from_openapi_data( + 1.5, + _configuration=self._configuration + ) + + def test_both_anyof_valid_passes(self): + # both anyOf valid + Anyof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_first_anyof_valid_passes(self): + # first anyOf valid + Anyof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py new file mode 100644 index 00000000000..eeb533e6196 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_complex_types import AnyofComplexTypes +from unit_test_api import configuration + + +class TestAnyofComplexTypes(unittest.TestCase): + """AnyofComplexTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_anyof_valid_complex_passes(self): + # second anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + def test_neither_anyof_valid_complex_fails(self): + # neither anyOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofComplexTypes._from_openapi_data( + { + "foo": + 2, + "bar": + "quux", + }, + _configuration=self._configuration + ) + + def test_both_anyof_valid_complex_passes(self): + # both anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_first_anyof_valid_complex_passes(self): + # first anyOf valid (complex) + AnyofComplexTypes._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py new file mode 100644 index 00000000000..96e03720d64 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema +from unit_test_api import configuration + + +class TestAnyofWithBaseSchema(unittest.TestCase): + """AnyofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_one_anyof_valid_passes(self): + # one anyOf valid + AnyofWithBaseSchema._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_both_anyof_invalid_fails(self): + # both anyOf invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema._from_openapi_data( + 3, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py new file mode 100644 index 00000000000..dcb2c0ea80a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema +from unit_test_api import configuration + + +class TestAnyofWithOneEmptySchema(unittest.TestCase): + """AnyofWithOneEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_string_is_valid_passes(self): + # string is valid + AnyofWithOneEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_number_is_valid_passes(self): + # number is valid + AnyofWithOneEmptySchema._from_openapi_data( + 123, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py new file mode 100644 index 00000000000..b8bc156e18b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api import configuration + + +class TestArrayTypeMatchesArrays(unittest.TestCase): + """ArrayTypeMatchesArrays unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + ArrayTypeMatchesArrays._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py new file mode 100644 index 00000000000..3ffb73ed957 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api import configuration + + +class TestBooleanTypeMatchesBooleans(unittest.TestCase): + """BooleanTypeMatchesBooleans unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_empty_string_is_not_a_boolean_fails(self): + # an empty string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_boolean_fails(self): + # a float is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_null_is_not_a_boolean_fails(self): + # null is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_zero_is_not_a_boolean_fails(self): + # zero is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_boolean_fails(self): + # an array is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_string_is_not_a_boolean_fails(self): + # a string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_false_is_a_boolean_passes(self): + # false is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_a_boolean_fails(self): + # an integer is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_a_boolean_passes(self): + # true is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_boolean_fails(self): + # an object is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py new file mode 100644 index 00000000000..26254a7aaa8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_int import ByInt +from unit_test_api import configuration + + +class TestByInt(unittest.TestCase): + """ByInt unit test stubs""" + _configuration = configuration.Configuration() + + def test_int_by_int_fail_fails(self): + # int by int fail + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ByInt._from_openapi_data( + 7, + _configuration=self._configuration + ) + + def test_int_by_int_passes(self): + # int by int + ByInt._from_openapi_data( + 10, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + ByInt._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py new file mode 100644 index 00000000000..928b8f3c645 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_number import ByNumber +from unit_test_api import configuration + + +class TestByNumber(unittest.TestCase): + """ByNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_45_is_multiple_of15_passes(self): + # 4.5 is multiple of 1.5 + ByNumber._from_openapi_data( + 4.5, + _configuration=self._configuration + ) + + def test_35_is_not_multiple_of15_fails(self): + # 35 is not multiple of 1.5 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ByNumber._from_openapi_data( + 35, + _configuration=self._configuration + ) + + def test_zero_is_multiple_of_anything_passes(self): + # zero is multiple of anything + ByNumber._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py new file mode 100644 index 00000000000..cc683feebe2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_small_number import BySmallNumber +from unit_test_api import configuration + + +class TestBySmallNumber(unittest.TestCase): + """BySmallNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_000751_is_not_multiple_of00001_fails(self): + # 0.00751 is not multiple of 0.0001 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BySmallNumber._from_openapi_data( + 0.00751, + _configuration=self._configuration + ) + + def test_00075_is_multiple_of00001_passes(self): + # 0.0075 is multiple of 0.0001 + BySmallNumber._from_openapi_data( + 0.0075, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py new file mode 100644 index 00000000000..b3a2b154373 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.date_time_format import DateTimeFormat +from unit_test_api import configuration + + +class TestDateTimeFormat(unittest.TestCase): + """DateTimeFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + DateTimeFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + DateTimeFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + DateTimeFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + DateTimeFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + DateTimeFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + DateTimeFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py new file mode 100644 index 00000000000..c6b2d51c19c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.email_format import EmailFormat +from unit_test_api import configuration + + +class TestEmailFormat(unittest.TestCase): + """EmailFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + EmailFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + EmailFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + EmailFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + EmailFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + EmailFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + EmailFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py new file mode 100644 index 00000000000..f2917a571bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse +from unit_test_api import configuration + + +class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): + """EnumWith0DoesNotMatchFalse unit test stubs""" + _configuration = configuration.Configuration() + + def test_integer_zero_is_valid_passes(self): + # integer zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_float_zero_is_valid_passes(self): + # float zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_false_is_invalid_fails(self): + # false is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWith0DoesNotMatchFalse._from_openapi_data( + False, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py new file mode 100644 index 00000000000..8b498180763 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue +from unit_test_api import configuration + + +class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): + """EnumWith1DoesNotMatchTrue unit test stubs""" + _configuration = configuration.Configuration() + + def test_true_is_invalid_fails(self): + # true is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWith1DoesNotMatchTrue._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_integer_one_is_valid_passes(self): + # integer one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_float_one_is_valid_passes(self): + # float one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py new file mode 100644 index 00000000000..658588f2b0d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters +from unit_test_api import configuration + + +class TestEnumWithEscapedCharacters(unittest.TestCase): + """EnumWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_member2_is_valid_passes(self): + # member 2 is valid + EnumWithEscapedCharacters._from_openapi_data( + "foo\rbar", + _configuration=self._configuration + ) + + def test_member1_is_valid_passes(self): + # member 1 is valid + EnumWithEscapedCharacters._from_openapi_data( + "foo\nbar", + _configuration=self._configuration + ) + + def test_another_string_is_invalid_fails(self): + # another string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithEscapedCharacters._from_openapi_data( + "abc", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py new file mode 100644 index 00000000000..c62d5f79091 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 +from unit_test_api import configuration + + +class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): + """EnumWithFalseDoesNotMatch0 unit test stubs""" + _configuration = configuration.Configuration() + + def test_false_is_valid_passes(self): + # false is valid + EnumWithFalseDoesNotMatch0._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_float_zero_is_invalid_fails(self): + # float zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_integer_zero_is_invalid_fails(self): + # integer zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py new file mode 100644 index 00000000000..9339856f4f5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 +from unit_test_api import configuration + + +class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): + """EnumWithTrueDoesNotMatch1 unit test stubs""" + _configuration = configuration.Configuration() + + def test_float_one_is_invalid_fails(self): + # float one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_true_is_valid_passes(self): + # true is valid + EnumWithTrueDoesNotMatch1._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_integer_one_is_invalid_fails(self): + # integer one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py new file mode 100644 index 00000000000..87c5112a3fb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api import configuration + + +class TestEnumsInProperties(unittest.TestCase): + """EnumsInProperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_optional_property_is_valid_passes(self): + # missing optional property is valid + EnumsInProperties._from_openapi_data( + { + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_wrong_foo_value_fails(self): + # wrong foo value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foot", + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_both_properties_are_valid_passes(self): + # both properties are valid + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + "bar": + "bar", + }, + _configuration=self._configuration + ) + + def test_wrong_bar_value_fails(self): + # wrong bar value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + "bar": + "bart", + }, + _configuration=self._configuration + ) + + def test_missing_all_properties_is_invalid_fails(self): + # missing all properties is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_missing_required_property_is_invalid_fails(self): + # missing required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + EnumsInProperties._from_openapi_data( + { + "foo": + "foo", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py new file mode 100644 index 00000000000..b48d39902f6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.forbidden_property import ForbiddenProperty +from unit_test_api import configuration + + +class TestForbiddenProperty(unittest.TestCase): + """ForbiddenProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_present_fails(self): + # property present + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ForbiddenProperty._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_property_absent_passes(self): + # property absent + ForbiddenProperty._from_openapi_data( + { + "bar": + 1, + "baz": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py new file mode 100644 index 00000000000..32a6f0d003e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.hostname_format import HostnameFormat +from unit_test_api import configuration + + +class TestHostnameFormat(unittest.TestCase): + """HostnameFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + HostnameFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + HostnameFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + HostnameFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + HostnameFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + HostnameFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + HostnameFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py new file mode 100644 index 00000000000..ecf83a0586c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api import configuration + + +class TestIntegerTypeMatchesIntegers(unittest.TestCase): + """IntegerTypeMatchesIntegers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 00000000000..67ce05d42f6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf +from unit_test_api import configuration + + +class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCase): + """InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf unit test stubs""" + _configuration = configuration.Configuration() + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + # always invalid, but naive implementations may raise an overflow error + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( + 1.0E308, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py new file mode 100644 index 00000000000..50f165727b5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api import configuration + + +class TestInvalidStringValueForDefault(unittest.TestCase): + """InvalidStringValueForDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidStringValueForDefault._from_openapi_data( + { + "bar": + "good", + }, + _configuration=self._configuration + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidStringValueForDefault._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py new file mode 100644 index 00000000000..cd4cd9a69d9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv4_format import Ipv4Format +from unit_test_api import configuration + + +class TestIpv4Format(unittest.TestCase): + """Ipv4Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv4Format._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv4Format._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv4Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv4Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv4Format._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv4Format._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py new file mode 100644 index 00000000000..e9e10a48905 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv6_format import Ipv6Format +from unit_test_api import configuration + + +class TestIpv6Format(unittest.TestCase): + """Ipv6Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv6Format._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv6Format._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv6Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv6Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv6Format._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv6Format._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py new file mode 100644 index 00000000000..f20c6aff949 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.json_pointer_format import JsonPointerFormat +from unit_test_api import configuration + + +class TestJsonPointerFormat(unittest.TestCase): + """JsonPointerFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + JsonPointerFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + JsonPointerFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + JsonPointerFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + JsonPointerFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + JsonPointerFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + JsonPointerFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py new file mode 100644 index 00000000000..5c0e51f822a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation import MaximumValidation +from unit_test_api import configuration + + +class TestMaximumValidation(unittest.TestCase): + """MaximumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_valid_passes(self): + # below the maximum is valid + MaximumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MaximumValidation._from_openapi_data( + 3.0, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaximumValidation._from_openapi_data( + 3.5, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MaximumValidation._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py new file mode 100644 index 00000000000..4bc8a4f8372 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger +from unit_test_api import configuration + + +class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): + """MaximumValidationWithUnsignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_invalid_passes(self): + # below the maximum is invalid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 299.97, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.5, + _configuration=self._configuration + ) + + def test_boundary_point_integer_is_valid_passes(self): + # boundary point integer is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300, + _configuration=self._configuration + ) + + def test_boundary_point_float_is_valid_passes(self): + # boundary point float is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py new file mode 100644 index 00000000000..10804599c31 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py @@ -0,0 +1,63 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxitems_validation import MaxitemsValidation +from unit_test_api import configuration + + +class TestMaxitemsValidation(unittest.TestCase): + """MaxitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + 3, + ], + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MaxitemsValidation._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + ], + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py new file mode 100644 index 00000000000..e5871ed0f1c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxlength_validation import MaxlengthValidation +from unit_test_api import configuration + + +class TestMaxlengthValidation(unittest.TestCase): + """MaxlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxlengthValidation._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MaxlengthValidation._from_openapi_data( + 100, + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxlengthValidation._from_openapi_data( + "f", + _configuration=self._configuration + ) + + def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): + # two supplementary Unicode code points is long enough + MaxlengthValidation._from_openapi_data( + "💩💩", + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxlengthValidation._from_openapi_data( + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py new file mode 100644 index 00000000000..57764ac4a84 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty +from unit_test_api import configuration + + +class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): + """Maxproperties0MeansTheObjectIsEmpty unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_properties_is_valid_passes(self): + # no properties is valid + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_one_property_is_invalid_fails(self): + # one property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py new file mode 100644 index 00000000000..cd87cbfc645 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation +from unit_test_api import configuration + + +class TestMaxpropertiesValidation(unittest.TestCase): + """MaxpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + "baz": + 3, + }, + _configuration=self._configuration + ) + + def test_ignores_arrays_passes(self): + # ignores arrays + MaxpropertiesValidation._from_openapi_data( + [ + 1, + 2, + 3, + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MaxpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MaxpropertiesValidation._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py new file mode 100644 index 00000000000..d72abd6e1f8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation import MinimumValidation +from unit_test_api import configuration + + +class TestMinimumValidation(unittest.TestCase): + """MinimumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidation._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_below_the_minimum_is_invalid_fails(self): + # below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidation._from_openapi_data( + 0.6, + _configuration=self._configuration + ) + + def test_above_the_minimum_is_valid_passes(self): + # above the minimum is valid + MinimumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidation._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py new file mode 100644 index 00000000000..d4f2307a2a7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py @@ -0,0 +1,76 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger +from unit_test_api import configuration + + +class TestMinimumValidationWithSignedInteger(unittest.TestCase): + """MinimumValidationWithSignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2, + _configuration=self._configuration + ) + + def test_positive_above_the_minimum_is_valid_passes(self): + # positive above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_int_below_the_minimum_is_invalid_fails(self): + # int below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -3, + _configuration=self._configuration + ) + + def test_float_below_the_minimum_is_invalid_fails(self): + # float below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0001, + _configuration=self._configuration + ) + + def test_boundary_point_with_float_is_valid_passes(self): + # boundary point with float is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0, + _configuration=self._configuration + ) + + def test_negative_above_the_minimum_is_valid_passes(self): + # negative above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -1, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidationWithSignedInteger._from_openapi_data( + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py new file mode 100644 index 00000000000..bca2643fcc8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minitems_validation import MinitemsValidation +from unit_test_api import configuration + + +class TestMinitemsValidation(unittest.TestCase): + """MinitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinitemsValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MinitemsValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinitemsValidation._from_openapi_data( + [ + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py new file mode 100644 index 00000000000..515b2958eb8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py @@ -0,0 +1,62 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minlength_validation import MinlengthValidation +from unit_test_api import configuration + + +class TestMinlengthValidation(unittest.TestCase): + """MinlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinlengthValidation._from_openapi_data( + "f", + _configuration=self._configuration + ) + + def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): + # one supplementary Unicode code point is not long enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinlengthValidation._from_openapi_data( + "💩", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinlengthValidation._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MinlengthValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinlengthValidation._from_openapi_data( + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py new file mode 100644 index 00000000000..b8202eb3465 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minproperties_validation import MinpropertiesValidation +from unit_test_api import configuration + + +class TestMinpropertiesValidation(unittest.TestCase): + """MinpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + MinpropertiesValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MinpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + MinpropertiesValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MinpropertiesValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinpropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinpropertiesValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py new file mode 100644 index 00000000000..7bc1095617d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.model_not import ModelNot +from unit_test_api import configuration + + +class TestModelNot(unittest.TestCase): + """ModelNot unit test stubs""" + _configuration = configuration.Configuration() + + def test_allowed_passes(self): + # allowed + ModelNot._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_disallowed_fails(self): + # disallowed + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ModelNot._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py new file mode 100644 index 00000000000..61cefebba04 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedAllofToCheckValidationSemantics(unittest.TestCase): + """NestedAllofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAllofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAllofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py new file mode 100644 index 00000000000..9790a71c84e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedAnyofToCheckValidationSemantics(unittest.TestCase): + """NestedAnyofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAnyofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAnyofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py new file mode 100644 index 00000000000..e6d42516d3f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_items import NestedItems +from unit_test_api import configuration + + +class TestNestedItems(unittest.TestCase): + """NestedItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_nested_array_passes(self): + # valid nested array + NestedItems._from_openapi_data( + [ + [ + [ + [ + 1, + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], + _configuration=self._configuration + ) + + def test_nested_array_with_invalid_type_fails(self): + # nested array with invalid type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + [ + "1", + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], + _configuration=self._configuration + ) + + def test_not_deep_enough_fails(self): + # not deep enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + 1, + ], + [ + 2, + ], + [ + 3, + ], + ], + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py new file mode 100644 index 00000000000..48f2ffeb026 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics +from unit_test_api import configuration + + +class TestNestedOneofToCheckValidationSemantics(unittest.TestCase): + """NestedOneofToCheckValidationSemantics unit test stubs""" + _configuration = configuration.Configuration() + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedOneofToCheckValidationSemantics._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_null_is_valid_passes(self): + # null is valid + NestedOneofToCheckValidationSemantics._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py new file mode 100644 index 00000000000..b7ab21dadd4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema +from unit_test_api import configuration + + +class TestNotMoreComplexSchema(unittest.TestCase): + """NotMoreComplexSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_other_match_passes(self): + # other match + NotMoreComplexSchema._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NotMoreComplexSchema._from_openapi_data( + { + "foo": + "bar", + }, + _configuration=self._configuration + ) + + def test_match_passes(self): + # match + NotMoreComplexSchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py new file mode 100644 index 00000000000..5f9465d8687 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings +from unit_test_api import configuration + + +class TestNulCharactersInStrings(unittest.TestCase): + """NulCharactersInStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_match_string_with_nul_passes(self): + # match string with nul + NulCharactersInStrings._from_openapi_data( + "hello\x00there", + _configuration=self._configuration + ) + + def test_do_not_match_string_lacking_nul_fails(self): + # do not match string lacking nul + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NulCharactersInStrings._from_openapi_data( + "hellothere", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..0057f89b2b1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api import configuration + + +class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): + """NullTypeMatchesOnlyTheNullObject unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_null_fails(self): + # a float is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_false_is_not_null_fails(self): + # false is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_not_null_fails(self): + # true is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_zero_is_not_null_fails(self): + # zero is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_null_is_null_passes(self): + # null is null + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_array_is_not_null_fails(self): + # an array is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py new file mode 100644 index 00000000000..c71c9a01f74 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api import configuration + + +class TestNumberTypeMatchesNumbers(unittest.TestCase): + """NumberTypeMatchesNumbers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_array_is_not_a_number_fails(self): + # an array is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_null_is_not_a_number_fails(self): + # null is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_number_fails(self): + # an object is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_number_fails(self): + # a boolean is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_a_float_is_a_number_passes(self): + # a float is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + # a string is still not a number, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_a_string_is_not_a_number_fails(self): + # a string is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_an_integer_is_a_number_passes(self): + # an integer is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + # a float with zero fractional part is a number (and an integer) + NumberTypeMatchesNumbers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py new file mode 100644 index 00000000000..f4e44b15adc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation +from unit_test_api import configuration + + +class TestObjectPropertiesValidation(unittest.TestCase): + """ObjectPropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + ObjectPropertiesValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + ObjectPropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_one_property_invalid_is_invalid_fails(self): + # one property invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + { + }, + }, + _configuration=self._configuration + ) + + def test_both_properties_present_and_valid_is_valid_passes(self): + # both properties present and valid is valid + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + 1, + "bar": + "baz", + }, + _configuration=self._configuration + ) + + def test_doesn_t_invalidate_other_properties_passes(self): + # doesn't invalidate other properties + ObjectPropertiesValidation._from_openapi_data( + { + "quux": + [ + ], + }, + _configuration=self._configuration + ) + + def test_both_properties_invalid_is_invalid_fails(self): + # both properties invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + "foo": + [ + ], + "bar": + { + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py new file mode 100644 index 00000000000..5daa47d179f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof import Oneof +from unit_test_api import configuration + + +class TestOneof(unittest.TestCase): + """Oneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_second_oneof_valid_passes(self): + # second oneOf valid + Oneof._from_openapi_data( + 2.5, + _configuration=self._configuration + ) + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Oneof._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_first_oneof_valid_passes(self): + # first oneOf valid + Oneof._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_neither_oneof_valid_fails(self): + # neither oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Oneof._from_openapi_data( + 1.5, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py new file mode 100644 index 00000000000..16e639618c3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_complex_types import OneofComplexTypes +from unit_test_api import configuration + + +class TestOneofComplexTypes(unittest.TestCase): + """OneofComplexTypes unit test stubs""" + _configuration = configuration.Configuration() + + def test_first_oneof_valid_complex_passes(self): + # first oneOf valid (complex) + OneofComplexTypes._from_openapi_data( + { + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_neither_oneof_valid_complex_fails(self): + # neither oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofComplexTypes._from_openapi_data( + { + "foo": + 2, + "bar": + "quux", + }, + _configuration=self._configuration + ) + + def test_both_oneof_valid_complex_fails(self): + # both oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofComplexTypes._from_openapi_data( + { + "foo": + "baz", + "bar": + 2, + }, + _configuration=self._configuration + ) + + def test_second_oneof_valid_complex_passes(self): + # second oneOf valid (complex) + OneofComplexTypes._from_openapi_data( + { + "foo": + "baz", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py new file mode 100644 index 00000000000..52e075c47c3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema +from unit_test_api import configuration + + +class TestOneofWithBaseSchema(unittest.TestCase): + """OneofWithBaseSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithBaseSchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithBaseSchema._from_openapi_data( + 3, + _configuration=self._configuration + ) + + def test_one_oneof_valid_passes(self): + # one oneOf valid + OneofWithBaseSchema._from_openapi_data( + "foobar", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py new file mode 100644 index 00000000000..66b9d79990d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema +from unit_test_api import configuration + + +class TestOneofWithEmptySchema(unittest.TestCase): + """OneofWithEmptySchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_both_valid_invalid_fails(self): + # both valid - invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + OneofWithEmptySchema._from_openapi_data( + 123, + _configuration=self._configuration + ) + + def test_one_valid_valid_passes(self): + # one valid - valid + OneofWithEmptySchema._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py new file mode 100644 index 00000000000..15eb5c25586 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored +from unit_test_api import configuration + + +class TestPatternIsNotAnchored(unittest.TestCase): + """PatternIsNotAnchored unit test stubs""" + _configuration = configuration.Configuration() + + def test_matches_a_substring_passes(self): + # matches a substring + PatternIsNotAnchored._from_openapi_data( + "xxaayy", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py new file mode 100644 index 00000000000..fc76731c830 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_validation import PatternValidation +from unit_test_api import configuration + + +class TestPatternValidation(unittest.TestCase): + """PatternValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + PatternValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_ignores_objects_passes(self): + # ignores objects + PatternValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_ignores_null_passes(self): + # ignores null + PatternValidation._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_ignores_floats_passes(self): + # ignores floats + PatternValidation._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_non_matching_pattern_is_invalid_fails(self): + # a non-matching pattern is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PatternValidation._from_openapi_data( + "abc", + _configuration=self._configuration + ) + + def test_ignores_booleans_passes(self): + # ignores booleans + PatternValidation._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_a_matching_pattern_is_valid_passes(self): + # a matching pattern is valid + PatternValidation._from_openapi_data( + "aaa", + _configuration=self._configuration + ) + + def test_ignores_integers_passes(self): + # ignores integers + PatternValidation._from_openapi_data( + 123, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py new file mode 100644 index 00000000000..d7a0c7b9196 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters +from unit_test_api import configuration + + +class TestPropertiesWithEscapedCharacters(unittest.TestCase): + """PropertiesWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_object_with_all_numbers_is_valid_passes(self): + # object with all numbers is valid + PropertiesWithEscapedCharacters._from_openapi_data( + { + "foo\nbar": + 1, + "foo\"bar": + 1, + "foo\\bar": + 1, + "foo\rbar": + 1, + "foo\tbar": + 1, + "foo\fbar": + 1, + }, + _configuration=self._configuration + ) + + def test_object_with_strings_is_invalid_fails(self): + # object with strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PropertiesWithEscapedCharacters._from_openapi_data( + { + "foo\nbar": + "1", + "foo\"bar": + "1", + "foo\\bar": + "1", + "foo\rbar": + "1", + "foo\tbar": + "1", + "foo\fbar": + "1", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py new file mode 100644 index 00000000000..2599fd45d40 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api import configuration + + +class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): + """PropertyNamedRefThatIsNotAReference unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py new file mode 100644 index 00000000000..3079918ced1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_additionalproperties import RefInAdditionalproperties +from unit_test_api import configuration + + +class TestRefInAdditionalproperties(unittest.TestCase): + """RefInAdditionalproperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py new file mode 100644 index 00000000000..a1bcc365091 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_allof import RefInAllof +from unit_test_api import configuration + + +class TestRefInAllof(unittest.TestCase): + """RefInAllof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAllof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAllof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py new file mode 100644 index 00000000000..33ece563af9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_anyof import RefInAnyof +from unit_test_api import configuration + + +class TestRefInAnyof(unittest.TestCase): + """RefInAnyof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAnyof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAnyof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py new file mode 100644 index 00000000000..1cc69e3556b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_items import RefInItems +from unit_test_api import configuration + + +class TestRefInItems(unittest.TestCase): + """RefInItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInItems._from_openapi_data( + [ + { + "$ref": + "a", + }, + ], + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInItems._from_openapi_data( + [ + { + "$ref": + 2, + }, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py new file mode 100644 index 00000000000..f063204479f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_oneof import RefInOneof +from unit_test_api import configuration + + +class TestRefInOneof(unittest.TestCase): + """RefInOneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInOneof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInOneof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py new file mode 100644 index 00000000000..da213d35ed1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_property import RefInProperty +from unit_test_api import configuration + + +class TestRefInProperty(unittest.TestCase): + """RefInProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py new file mode 100644 index 00000000000..c17d16842b7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api import configuration + + +class TestRequiredDefaultValidation(unittest.TestCase): + """RequiredDefaultValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_not_required_by_default_passes(self): + # not required by default + RequiredDefaultValidation._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py new file mode 100644 index 00000000000..559f0be8d52 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api import configuration + + +class TestRequiredValidation(unittest.TestCase): + """RequiredValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + RequiredValidation._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_present_required_property_is_valid_passes(self): + # present required property is valid + RequiredValidation._from_openapi_data( + { + "foo": + 1, + }, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + RequiredValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + RequiredValidation._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_non_present_required_property_is_invalid_fails(self): + # non-present required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RequiredValidation._from_openapi_data( + { + "bar": + 1, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py new file mode 100644 index 00000000000..aced932c703 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api import configuration + + +class TestRequiredWithEmptyArray(unittest.TestCase): + """RequiredWithEmptyArray unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_not_required_passes(self): + # property not required + RequiredWithEmptyArray._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py new file mode 100644 index 00000000000..56d2746b84a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation +from unit_test_api import configuration + + +class TestSimpleEnumValidation(unittest.TestCase): + """SimpleEnumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_something_else_is_invalid_fails(self): + # something else is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + SimpleEnumValidation._from_openapi_data( + 4, + _configuration=self._configuration + ) + + def test_one_of_the_enum_is_valid_passes(self): + # one of the enum is valid + SimpleEnumValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py new file mode 100644 index 00000000000..807e2afe1c9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api import configuration + + +class TestStringTypeMatchesStrings(unittest.TestCase): + """StringTypeMatchesStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_1_is_not_a_string_fails(self): + # 1 is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): + # a string is still a string, even if it looks like a number + StringTypeMatchesStrings._from_openapi_data( + "1", + _configuration=self._configuration + ) + + def test_an_empty_string_is_still_a_string_passes(self): + # an empty string is still a string + StringTypeMatchesStrings._from_openapi_data( + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_string_fails(self): + # a float is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_string_fails(self): + # an object is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_string_fails(self): + # an array is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_string_fails(self): + # a boolean is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + True, + _configuration=self._configuration + ) + + def test_null_is_not_a_string_fails(self): + # null is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings._from_openapi_data( + None, + _configuration=self._configuration + ) + + def test_a_string_is_a_string_passes(self): + # a string is a string + StringTypeMatchesStrings._from_openapi_data( + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..4f8e583c41a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing +from unit_test_api import configuration + + +class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): + """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + "alpha": + 1, + }, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + "alpha": + 5, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py new file mode 100644 index 00000000000..afe2f481d7e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py @@ -0,0 +1,246 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_false_validation import UniqueitemsFalseValidation +from unit_test_api import configuration + + +class TestUniqueitemsFalseValidation(unittest.TestCase): + """UniqueitemsFalseValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_non_unique_array_of_integers_is_valid_passes(self): + # non-unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 1, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "baz", + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_valid_passes(self): + # non-unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_valid_passes(self): + # non-unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "bar", + }, + ], + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # 1 and true are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_valid_passes(self): + # non-unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_passes(self): + # numbers are unique if mathematically unequal + UniqueitemsFalseValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ], + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + False, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # 0 and false are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + ], + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_valid_passes(self): + # non-unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + { + }, + 1, + ], + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py new file mode 100644 index 00000000000..f4032887b69 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py @@ -0,0 +1,427 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_validation import UniqueitemsValidation +from unit_test_api import configuration + + +class TestUniqueitemsValidation(unittest.TestCase): + """UniqueitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "baz", + }, + ], + _configuration=self._configuration + ) + + def test_a_true_and_a1_are_unique_passes(self): + # {"a": true} and {"a": 1} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + True, + }, + { + "a": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_invalid_fails(self): + # non-unique heterogeneous types are invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + { + }, + 1, + ], + _configuration=self._configuration + ) + + def test_nested0_and_false_are_unique_passes(self): + # nested [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 0, + ], + "foo", + ], + [ + [ + False, + ], + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_a_false_and_a0_are_unique_passes(self): + # {"a": false} and {"a": 0} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + False, + }, + { + "a": + 0, + }, + ], + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_fails(self): + # numbers are unique if mathematically unequal + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ], + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsValidation._from_openapi_data( + [ + 0, + False, + ], + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 0, + ], + [ + False, + ], + ], + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_invalid_fails(self): + # non-unique array of nested objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_integers_is_invalid_fails(self): + # non-unique array of more than two integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + 1, + ], + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsValidation._from_openapi_data( + [ + 1, + True, + ], + _configuration=self._configuration + ) + + def test_objects_are_non_unique_despite_key_order_fails(self): + # objects are non-unique despite key order + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + 1, + "b": + 2, + }, + { + "b": + 2, + "a": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_strings_is_valid_passes(self): + # unique array of strings is valid + UniqueitemsValidation._from_openapi_data( + [ + "foo", + "bar", + "baz", + ], + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 1, + ], + [ + True, + ], + ], + _configuration=self._configuration + ) + + def test_different_objects_are_unique_passes(self): + # different objects are unique + UniqueitemsValidation._from_openapi_data( + [ + { + "a": + 1, + "b": + 2, + }, + { + "a": + 2, + "b": + 1, + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_arrays_is_invalid_fails(self): + # non-unique array of more than two arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "bar", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_invalid_fails(self): + # non-unique array of objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + "bar", + }, + { + "foo": + "bar", + }, + ], + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + "foo": + { + "bar": + { + "baz": + True, + }, + }, + }, + { + "foo": + { + "bar": + { + "baz": + False, + }, + }, + }, + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_invalid_fails(self): + # non-unique array of arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + "foo", + ], + [ + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_strings_is_invalid_fails(self): + # non-unique array of strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + "foo", + "bar", + "foo", + ], + _configuration=self._configuration + ) + + def test_nested1_and_true_are_unique_passes(self): + # nested [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 1, + ], + "foo", + ], + [ + [ + True, + ], + "foo", + ], + ], + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsValidation._from_openapi_data( + [ + { + }, + [ + 1, + ], + True, + None, + 1, + "{}", + ], + _configuration=self._configuration + ) + + def test_non_unique_array_of_integers_is_invalid_fails(self): + # non-unique array of integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 1, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py new file mode 100644 index 00000000000..2f6def90243 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_format import UriFormat +from unit_test_api import configuration + + +class TestUriFormat(unittest.TestCase): + """UriFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py new file mode 100644 index 00000000000..c5508b68bc6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_reference_format import UriReferenceFormat +from unit_test_api import configuration + + +class TestUriReferenceFormat(unittest.TestCase): + """UriReferenceFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriReferenceFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriReferenceFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriReferenceFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriReferenceFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriReferenceFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriReferenceFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py new file mode 100644 index 00000000000..456c0794ad0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_template_format import UriTemplateFormat +from unit_test_api import configuration + + +class TestUriTemplateFormat(unittest.TestCase): + """UriTemplateFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriTemplateFormat._from_openapi_data( + { + }, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriTemplateFormat._from_openapi_data( + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriTemplateFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriTemplateFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriTemplateFormat._from_openapi_data( + [ + ], + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriTemplateFormat._from_openapi_data( + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/VERSION b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/VERSION index e69de29bb2d..66672d4e9d3 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/VERSION +++ b/samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.1.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/php-laravel/lib/.gitattributes b/samples/server/petstore/php-laravel/lib/.gitattributes index e69de29bb2d..967315dd3d1 100644 --- a/samples/server/petstore/php-laravel/lib/.gitattributes +++ b/samples/server/petstore/php-laravel/lib/.gitattributes @@ -0,0 +1,5 @@ +* text=auto +*.css linguist-vendored +*.scss linguist-vendored +*.js linguist-vendored +CHANGELOG.md export-ignore diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php b/samples/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php index e69de29bb2d..f0354421e00 100644 --- a/samples/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php +++ b/samples/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php @@ -0,0 +1,54 @@ +responseGenerator = $responseGenerator; + } + + /** + * @inheritdoc + */ + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + $result = null; + try { + ErrorHandler::start(); + $result = $handler->handle($request); + ErrorHandler::stop(true); + } + catch (\Throwable $error) { + $result = $this->handleError($error); + } + return $result; + } + + public function handleError(\Throwable $error): ResponseInterface + { + \error_log((string)$error); + return $this->generateEmptyResponse()->withStatus(500, 'Internal server error'); + } + + protected function generateEmptyResponse(): ResponseInterface + { + return ($this->responseGenerator)(); + } +} diff --git a/samples/server/petstore/python-blueplanet/app/openapi_server/typing_utils.py b/samples/server/petstore/python-blueplanet/app/openapi_server/typing_utils.py index e69de29bb2d..0563f81fd53 100644 --- a/samples/server/petstore/python-blueplanet/app/openapi_server/typing_utils.py +++ b/samples/server/petstore/python-blueplanet/app/openapi_server/typing_utils.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +import sys + +if sys.version_info < (3, 7): + import typing + + def is_generic(klass): + """ Determine whether klass is a generic class """ + return type(klass) == typing.GenericMeta + + def is_dict(klass): + """ Determine whether klass is a Dict """ + return klass.__extra__ == dict + + def is_list(klass): + """ Determine whether klass is a List """ + return klass.__extra__ == list + +else: + + def is_generic(klass): + """ Determine whether klass is a generic class """ + return hasattr(klass, '__origin__') + + def is_dict(klass): + """ Determine whether klass is a Dict """ + return klass.__origin__ == dict + + def is_list(klass): + """ Determine whether klass is a List """ + return klass.__origin__ == list diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs index e69de29bb2d..bc32420a2d9 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs @@ -0,0 +1,464 @@ +use async_trait::async_trait; +use futures::{Stream, future, future::BoxFuture, stream, future::TryFutureExt, future::FutureExt, stream::StreamExt}; +use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; +use hyper::{Body, Request, Response, service::Service, Uri}; +use percent_encoding::{utf8_percent_encode, AsciiSet}; +use std::borrow::Cow; +use std::convert::TryInto; +use std::io::{ErrorKind, Read}; +use std::error::Error; +use std::future::Future; +use std::fmt; +use std::marker::PhantomData; +use std::path::Path; +use std::sync::{Arc, Mutex}; +use std::str; +use std::str::FromStr; +use std::string::ToString; +use std::task::{Context, Poll}; +use swagger::{ApiError, AuthData, BodyExt, Connector, DropContextService, Has, XSpanIdString}; +use url::form_urlencoded; + + +use crate::models; +use crate::header; + +/// https://url.spec.whatwg.org/#fragment-percent-encode-set +#[allow(dead_code)] +const FRAGMENT_ENCODE_SET: &AsciiSet = &percent_encoding::CONTROLS + .add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); + +/// This encode set is used for object IDs +/// +/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, +/// the vertical bar (|) is encoded. +#[allow(dead_code)] +const ID_ENCODE_SET: &AsciiSet = &FRAGMENT_ENCODE_SET.add(b'|'); + +use crate::{Api, + OpGetResponse + }; + +/// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. +fn into_base_path(input: impl TryInto, correct_scheme: Option<&'static str>) -> Result { + // First convert to Uri, since a base path is a subset of Uri. + let uri = input.try_into()?; + + let scheme = uri.scheme_str().ok_or(ClientInitError::InvalidScheme)?; + + // Check the scheme if necessary + if let Some(correct_scheme) = correct_scheme { + if scheme != correct_scheme { + return Err(ClientInitError::InvalidScheme); + } + } + + let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; + let port = uri.port_u16().map(|x| format!(":{}", x)).unwrap_or_default(); + Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) +} + +/// A client that implements the API by making HTTP calls out to a server. +pub struct Client where + S: Service< + (Request, C), + Response=Response> + Clone + Sync + Send + 'static, + S::Future: Send + 'static, + S::Error: Into + fmt::Display, + C: Clone + Send + Sync + 'static +{ + /// Inner service + client_service: S, + + /// Base path of the API + base_path: String, + + /// Marker + marker: PhantomData, +} + +impl fmt::Debug for Client where + S: Service< + (Request, C), + Response=Response> + Clone + Sync + Send + 'static, + S::Future: Send + 'static, + S::Error: Into + fmt::Display, + C: Clone + Send + Sync + 'static +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Client {{ base_path: {} }}", self.base_path) + } +} + +impl Clone for Client where + S: Service< + (Request, C), + Response=Response> + Clone + Sync + Send + 'static, + S::Future: Send + 'static, + S::Error: Into + fmt::Display, + C: Clone + Send + Sync + 'static +{ + fn clone(&self) -> Self { + Self { + client_service: self.client_service.clone(), + base_path: self.base_path.clone(), + marker: PhantomData, + } + } +} + +impl Client, C>, C> where + Connector: hyper::client::connect::Connect + Clone + Send + Sync + 'static, + C: Clone + Send + Sync + 'static, +{ + /// Create a client with a custom implementation of hyper::client::Connect. + /// + /// Intended for use with custom implementations of connect for e.g. protocol logging + /// or similar functionality which requires wrapping the transport layer. When wrapping a TCP connection, + /// this function should be used in conjunction with `swagger::Connector::builder()`. + /// + /// For ordinary tcp connections, prefer the use of `try_new_http`, `try_new_https` + /// and `try_new_https_mutual`, to avoid introducing a dependency on the underlying transport layer. + /// + /// # Arguments + /// + /// * `base_path` - base path of the client API, i.e. "http://www.my-api-implementation.com" + /// * `protocol` - Which protocol to use when constructing the request url, e.g. `Some("http")` + /// * `connector` - Implementation of `hyper::client::Connect` to use for the client + pub fn try_new_with_connector( + base_path: &str, + protocol: Option<&'static str>, + connector: Connector, + ) -> Result + { + let client_service = hyper::client::Client::builder().build(connector); + let client_service = DropContextService::new(client_service); + + Ok(Self { + client_service, + base_path: into_base_path(base_path, protocol)?, + marker: PhantomData, + }) + } +} + +#[derive(Debug, Clone)] +pub enum HyperClient { + Http(hyper::client::Client), + Https(hyper::client::Client), +} + +impl Service> for HyperClient { + type Response = Response; + type Error = hyper::Error; + type Future = hyper::client::ResponseFuture; + + fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + match self { + HyperClient::Http(client) => client.poll_ready(cx), + HyperClient::Https(client) => client.poll_ready(cx), + } + } + + fn call(&mut self, req: Request) -> Self::Future { + match self { + HyperClient::Http(client) => client.call(req), + HyperClient::Https(client) => client.call(req) + } + } +} + +impl Client, C> where + C: Clone + Send + Sync + 'static, +{ + /// Create an HTTP client. + /// + /// # Arguments + /// * `base_path` - base path of the client API, i.e. "http://www.my-api-implementation.com" + pub fn try_new( + base_path: &str, + ) -> Result { + let uri = Uri::from_str(base_path)?; + + let scheme = uri.scheme_str().ok_or(ClientInitError::InvalidScheme)?; + let scheme = scheme.to_ascii_lowercase(); + + let connector = Connector::builder(); + + let client_service = match scheme.as_str() { + "http" => { + HyperClient::Http(hyper::client::Client::builder().build(connector.build())) + }, + "https" => { + let connector = connector.https() + .build() + .map_err(|e| ClientInitError::SslError(e))?; + HyperClient::Https(hyper::client::Client::builder().build(connector)) + }, + _ => { + return Err(ClientInitError::InvalidScheme); + } + }; + + let client_service = DropContextService::new(client_service); + + Ok(Self { + client_service, + base_path: into_base_path(base_path, None)?, + marker: PhantomData, + }) + } +} + +impl Client, C>, C> where + C: Clone + Send + Sync + 'static +{ + /// Create an HTTP client. + /// + /// # Arguments + /// * `base_path` - base path of the client API, i.e. "http://www.my-api-implementation.com" + pub fn try_new_http( + base_path: &str, + ) -> Result { + let http_connector = Connector::builder().build(); + + Self::try_new_with_connector(base_path, Some("http"), http_connector) + } +} + +#[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))] +type HttpsConnector = hyper_tls::HttpsConnector; + +#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] +type HttpsConnector = hyper_openssl::HttpsConnector; + +impl Client, C>, C> where + C: Clone + Send + Sync + 'static +{ + /// Create a client with a TLS connection to the server + /// + /// # Arguments + /// * `base_path` - base path of the client API, i.e. "https://www.my-api-implementation.com" + pub fn try_new_https(base_path: &str) -> Result + { + let https_connector = Connector::builder() + .https() + .build() + .map_err(|e| ClientInitError::SslError(e))?; + Self::try_new_with_connector(base_path, Some("https"), https_connector) + } + + /// Create a client with a TLS connection to the server using a pinned certificate + /// + /// # Arguments + /// * `base_path` - base path of the client API, i.e. "https://www.my-api-implementation.com" + /// * `ca_certificate` - Path to CA certificate used to authenticate the server + #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] + pub fn try_new_https_pinned( + base_path: &str, + ca_certificate: CA, + ) -> Result + where + CA: AsRef, + { + let https_connector = Connector::builder() + .https() + .pin_server_certificate(ca_certificate) + .build() + .map_err(|e| ClientInitError::SslError(e))?; + Self::try_new_with_connector(base_path, Some("https"), https_connector) + } + + /// Create a client with a mutually authenticated TLS connection to the server. + /// + /// # Arguments + /// * `base_path` - base path of the client API, i.e. "https://www.my-api-implementation.com" + /// * `ca_certificate` - Path to CA certificate used to authenticate the server + /// * `client_key` - Path to the client private key + /// * `client_certificate` - Path to the client's public certificate associated with the private key + #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] + pub fn try_new_https_mutual( + base_path: &str, + ca_certificate: CA, + client_key: K, + client_certificate: D, + ) -> Result + where + CA: AsRef, + K: AsRef, + D: AsRef, + { + let https_connector = Connector::builder() + .https() + .pin_server_certificate(ca_certificate) + .client_authentication(client_key, client_certificate) + .build() + .map_err(|e| ClientInitError::SslError(e))?; + Self::try_new_with_connector(base_path, Some("https"), https_connector) + } +} + +impl Client where + S: Service< + (Request, C), + Response=Response> + Clone + Sync + Send + 'static, + S::Future: Send + 'static, + S::Error: Into + fmt::Display, + C: Clone + Send + Sync + 'static +{ + /// Constructor for creating a `Client` by passing in a pre-made `hyper::service::Service` / + /// `tower::Service` + /// + /// This allows adding custom wrappers around the underlying transport, for example for logging. + pub fn try_new_with_client_service( + client_service: S, + base_path: &str, + ) -> Result + { + Ok(Self { + client_service, + base_path: into_base_path(base_path, None)?, + marker: PhantomData, + }) + } +} + +/// Error type failing to create a Client +#[derive(Debug)] +pub enum ClientInitError { + /// Invalid URL Scheme + InvalidScheme, + + /// Invalid URI + InvalidUri(hyper::http::uri::InvalidUri), + + /// Missing Hostname + MissingHost, + + /// SSL Connection Error + #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))] + SslError(native_tls::Error), + + /// SSL Connection Error + #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] + SslError(openssl::error::ErrorStack), +} + +impl From for ClientInitError { + fn from(err: hyper::http::uri::InvalidUri) -> ClientInitError { + ClientInitError::InvalidUri(err) + } +} + +impl fmt::Display for ClientInitError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s: &dyn fmt::Debug = self; + s.fmt(f) + } +} + +impl Error for ClientInitError { + fn description(&self) -> &str { + "Failed to produce a hyper client." + } +} + +#[async_trait] +impl Api for Client where + S: Service< + (Request, C), + Response=Response> + Clone + Sync + Send + 'static, + S::Future: Send + 'static, + S::Error: Into + fmt::Display, + C: Has + Clone + Send + Sync + 'static, +{ + fn poll_ready(&self, cx: &mut Context) -> Poll> { + match self.client_service.clone().poll_ready(cx) { + Poll::Ready(Err(e)) => Poll::Ready(Err(e.into())), + Poll::Ready(Ok(o)) => Poll::Ready(Ok(o)), + Poll::Pending => Poll::Pending, + } + } + + async fn op_get( + &self, + param_op_get_request: models::OpGetRequest, + context: &C) -> Result + { + let mut client_service = self.client_service.clone(); + let mut uri = format!( + "{}/op", + self.base_path + ); + + // Query parameters + let query_string = { + let mut query_string = form_urlencoded::Serializer::new("".to_owned()); + query_string.finish() + }; + if !query_string.is_empty() { + uri += "?"; + uri += &query_string; + } + + let uri = match Uri::from_str(&uri) { + Ok(uri) => uri, + Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))), + }; + + let mut request = match Request::builder() + .method("GET") + .uri(uri) + .body(Body::empty()) { + Ok(req) => req, + Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) + }; + + // Body parameter + let body = serde_json::to_string(¶m_op_get_request).expect("impossible to fail to serialize"); + + *request.body_mut() = Body::from(body); + + let header = "application/json"; + request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) + }); + + let header = HeaderValue::from_str(Has::::get(context).0.clone().to_string().as_str()); + request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { + Ok(h) => h, + Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) + }); + + let mut response = client_service.call((request, context.clone())) + .map_err(|e| ApiError(format!("No response received: {}", e))).await?; + + match response.status().as_u16() { + 200 => { + let body = response.into_body(); + Ok( + OpGetResponse::OK + ) + } + code => { + let headers = response.headers().clone(); + let body = response.into_body() + .take(100) + .into_raw().await; + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", + code, + headers, + match body { + Ok(body) => match String::from_utf8(body) { + Ok(body) => body, + Err(e) => format!("", e), + }, + Err(e) => format!("", e), + } + ))) + } + } + } + +} diff --git a/samples/server/petstore/rust-server/output/openapi-v3/docs/AnotherXmlArray.md b/samples/server/petstore/rust-server/output/openapi-v3/docs/AnotherXmlArray.md index e69de29bb2d..aa3674f8a24 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/docs/AnotherXmlArray.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/docs/AnotherXmlArray.md @@ -0,0 +1,9 @@ +# AnotherXmlArray + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index e69de29bb2d..438fe894ae9 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -0,0 +1,1450 @@ +use futures::{future, future::BoxFuture, Stream, stream, future::FutureExt, stream::TryStreamExt}; +use hyper::{Request, Response, StatusCode, Body, HeaderMap}; +use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; +use log::warn; +#[allow(unused_imports)] +use std::convert::{TryFrom, TryInto}; +use std::error::Error; +use std::future::Future; +use std::marker::PhantomData; +use std::task::{Context, Poll}; +use swagger::{ApiError, BodyExt, Has, RequestParser, XSpanIdString}; +pub use swagger::auth::Authorization; +use swagger::auth::Scopes; +use url::form_urlencoded; + +#[allow(unused_imports)] +use crate::models; +use crate::header; + +pub use crate::context; + +type ServiceFuture = BoxFuture<'static, Result, crate::ServiceError>>; + +use crate::{Api, + Op10GetResponse, + Op11GetResponse, + Op12GetResponse, + Op13GetResponse, + Op14GetResponse, + Op15GetResponse, + Op16GetResponse, + Op17GetResponse, + Op18GetResponse, + Op19GetResponse, + Op1GetResponse, + Op20GetResponse, + Op21GetResponse, + Op22GetResponse, + Op23GetResponse, + Op24GetResponse, + Op25GetResponse, + Op26GetResponse, + Op27GetResponse, + Op28GetResponse, + Op29GetResponse, + Op2GetResponse, + Op30GetResponse, + Op31GetResponse, + Op32GetResponse, + Op33GetResponse, + Op34GetResponse, + Op35GetResponse, + Op36GetResponse, + Op37GetResponse, + Op3GetResponse, + Op4GetResponse, + Op5GetResponse, + Op6GetResponse, + Op7GetResponse, + Op8GetResponse, + Op9GetResponse +}; + +mod paths { + use lazy_static::lazy_static; + + lazy_static! { + pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![ + r"^/op1$", + r"^/op10$", + r"^/op11$", + r"^/op12$", + r"^/op13$", + r"^/op14$", + r"^/op15$", + r"^/op16$", + r"^/op17$", + r"^/op18$", + r"^/op19$", + r"^/op2$", + r"^/op20$", + r"^/op21$", + r"^/op22$", + r"^/op23$", + r"^/op24$", + r"^/op25$", + r"^/op26$", + r"^/op27$", + r"^/op28$", + r"^/op29$", + r"^/op3$", + r"^/op30$", + r"^/op31$", + r"^/op32$", + r"^/op33$", + r"^/op34$", + r"^/op35$", + r"^/op36$", + r"^/op37$", + r"^/op4$", + r"^/op5$", + r"^/op6$", + r"^/op7$", + r"^/op8$", + r"^/op9$" + ]) + .expect("Unable to create global regex set"); + } + pub(crate) static ID_OP1: usize = 0; + pub(crate) static ID_OP10: usize = 1; + pub(crate) static ID_OP11: usize = 2; + pub(crate) static ID_OP12: usize = 3; + pub(crate) static ID_OP13: usize = 4; + pub(crate) static ID_OP14: usize = 5; + pub(crate) static ID_OP15: usize = 6; + pub(crate) static ID_OP16: usize = 7; + pub(crate) static ID_OP17: usize = 8; + pub(crate) static ID_OP18: usize = 9; + pub(crate) static ID_OP19: usize = 10; + pub(crate) static ID_OP2: usize = 11; + pub(crate) static ID_OP20: usize = 12; + pub(crate) static ID_OP21: usize = 13; + pub(crate) static ID_OP22: usize = 14; + pub(crate) static ID_OP23: usize = 15; + pub(crate) static ID_OP24: usize = 16; + pub(crate) static ID_OP25: usize = 17; + pub(crate) static ID_OP26: usize = 18; + pub(crate) static ID_OP27: usize = 19; + pub(crate) static ID_OP28: usize = 20; + pub(crate) static ID_OP29: usize = 21; + pub(crate) static ID_OP3: usize = 22; + pub(crate) static ID_OP30: usize = 23; + pub(crate) static ID_OP31: usize = 24; + pub(crate) static ID_OP32: usize = 25; + pub(crate) static ID_OP33: usize = 26; + pub(crate) static ID_OP34: usize = 27; + pub(crate) static ID_OP35: usize = 28; + pub(crate) static ID_OP36: usize = 29; + pub(crate) static ID_OP37: usize = 30; + pub(crate) static ID_OP4: usize = 31; + pub(crate) static ID_OP5: usize = 32; + pub(crate) static ID_OP6: usize = 33; + pub(crate) static ID_OP7: usize = 34; + pub(crate) static ID_OP8: usize = 35; + pub(crate) static ID_OP9: usize = 36; +} + +pub struct MakeService where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + api_impl: T, + marker: PhantomData, +} + +impl MakeService where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + pub fn new(api_impl: T) -> Self { + MakeService { + api_impl, + marker: PhantomData + } + } +} + +impl hyper::service::Service for MakeService where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + type Response = Service; + type Error = crate::ServiceError; + type Future = future::Ready>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, target: Target) -> Self::Future { + futures::future::ok(Service::new( + self.api_impl.clone(), + )) + } +} + +fn method_not_allowed() -> Result, crate::ServiceError> { + Ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + ) +} + +pub struct Service where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + api_impl: T, + marker: PhantomData, +} + +impl Service where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + pub fn new(api_impl: T) -> Self { + Service { + api_impl: api_impl, + marker: PhantomData + } + } +} + +impl Clone for Service where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static +{ + fn clone(&self) -> Self { + Service { + api_impl: self.api_impl.clone(), + marker: self.marker.clone(), + } + } +} + +impl hyper::service::Service<(Request, C)> for Service where + T: Api + Clone + Send + Sync + 'static, + C: Has + Send + Sync + 'static +{ + type Response = Response; + type Error = crate::ServiceError; + type Future = ServiceFuture; + + fn poll_ready(&mut self, cx: &mut Context) -> Poll> { + self.api_impl.poll_ready(cx) + } + + fn call(&mut self, req: (Request, C)) -> Self::Future { async fn run(mut api_impl: T, req: (Request, C)) -> Result, crate::ServiceError> where + T: Api + Clone + Send + 'static, + C: Has + Send + Sync + 'static + { + let (request, context) = req; + let (parts, body) = request.into_parts(); + let (method, uri, headers) = (parts.method, parts.uri, parts.headers); + let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); + + match &method { + + // Op10Get - GET /op10 + &hyper::Method::GET if path.matched(paths::ID_OP10) => { + let result = api_impl.op10_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op10GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op11Get - GET /op11 + &hyper::Method::GET if path.matched(paths::ID_OP11) => { + let result = api_impl.op11_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op11GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op12Get - GET /op12 + &hyper::Method::GET if path.matched(paths::ID_OP12) => { + let result = api_impl.op12_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op12GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op13Get - GET /op13 + &hyper::Method::GET if path.matched(paths::ID_OP13) => { + let result = api_impl.op13_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op13GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op14Get - GET /op14 + &hyper::Method::GET if path.matched(paths::ID_OP14) => { + let result = api_impl.op14_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op14GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op15Get - GET /op15 + &hyper::Method::GET if path.matched(paths::ID_OP15) => { + let result = api_impl.op15_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op15GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op16Get - GET /op16 + &hyper::Method::GET if path.matched(paths::ID_OP16) => { + let result = api_impl.op16_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op16GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op17Get - GET /op17 + &hyper::Method::GET if path.matched(paths::ID_OP17) => { + let result = api_impl.op17_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op17GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op18Get - GET /op18 + &hyper::Method::GET if path.matched(paths::ID_OP18) => { + let result = api_impl.op18_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op18GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op19Get - GET /op19 + &hyper::Method::GET if path.matched(paths::ID_OP19) => { + let result = api_impl.op19_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op19GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op1Get - GET /op1 + &hyper::Method::GET if path.matched(paths::ID_OP1) => { + let result = api_impl.op1_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op1GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op20Get - GET /op20 + &hyper::Method::GET if path.matched(paths::ID_OP20) => { + let result = api_impl.op20_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op20GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op21Get - GET /op21 + &hyper::Method::GET if path.matched(paths::ID_OP21) => { + let result = api_impl.op21_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op21GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op22Get - GET /op22 + &hyper::Method::GET if path.matched(paths::ID_OP22) => { + let result = api_impl.op22_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op22GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op23Get - GET /op23 + &hyper::Method::GET if path.matched(paths::ID_OP23) => { + let result = api_impl.op23_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op23GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op24Get - GET /op24 + &hyper::Method::GET if path.matched(paths::ID_OP24) => { + let result = api_impl.op24_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op24GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op25Get - GET /op25 + &hyper::Method::GET if path.matched(paths::ID_OP25) => { + let result = api_impl.op25_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op25GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op26Get - GET /op26 + &hyper::Method::GET if path.matched(paths::ID_OP26) => { + let result = api_impl.op26_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op26GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op27Get - GET /op27 + &hyper::Method::GET if path.matched(paths::ID_OP27) => { + let result = api_impl.op27_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op27GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op28Get - GET /op28 + &hyper::Method::GET if path.matched(paths::ID_OP28) => { + let result = api_impl.op28_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op28GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op29Get - GET /op29 + &hyper::Method::GET if path.matched(paths::ID_OP29) => { + let result = api_impl.op29_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op29GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op2Get - GET /op2 + &hyper::Method::GET if path.matched(paths::ID_OP2) => { + let result = api_impl.op2_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op2GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op30Get - GET /op30 + &hyper::Method::GET if path.matched(paths::ID_OP30) => { + let result = api_impl.op30_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op30GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op31Get - GET /op31 + &hyper::Method::GET if path.matched(paths::ID_OP31) => { + let result = api_impl.op31_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op31GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op32Get - GET /op32 + &hyper::Method::GET if path.matched(paths::ID_OP32) => { + let result = api_impl.op32_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op32GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op33Get - GET /op33 + &hyper::Method::GET if path.matched(paths::ID_OP33) => { + let result = api_impl.op33_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op33GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op34Get - GET /op34 + &hyper::Method::GET if path.matched(paths::ID_OP34) => { + let result = api_impl.op34_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op34GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op35Get - GET /op35 + &hyper::Method::GET if path.matched(paths::ID_OP35) => { + let result = api_impl.op35_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op35GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op36Get - GET /op36 + &hyper::Method::GET if path.matched(paths::ID_OP36) => { + let result = api_impl.op36_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op36GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op37Get - GET /op37 + &hyper::Method::GET if path.matched(paths::ID_OP37) => { + let result = api_impl.op37_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op37GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op3Get - GET /op3 + &hyper::Method::GET if path.matched(paths::ID_OP3) => { + let result = api_impl.op3_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op3GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op4Get - GET /op4 + &hyper::Method::GET if path.matched(paths::ID_OP4) => { + let result = api_impl.op4_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op4GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op5Get - GET /op5 + &hyper::Method::GET if path.matched(paths::ID_OP5) => { + let result = api_impl.op5_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op5GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op6Get - GET /op6 + &hyper::Method::GET if path.matched(paths::ID_OP6) => { + let result = api_impl.op6_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op6GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op7Get - GET /op7 + &hyper::Method::GET if path.matched(paths::ID_OP7) => { + let result = api_impl.op7_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op7GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op8Get - GET /op8 + &hyper::Method::GET if path.matched(paths::ID_OP8) => { + let result = api_impl.op8_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op8GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + // Op9Get - GET /op9 + &hyper::Method::GET if path.matched(paths::ID_OP9) => { + let result = api_impl.op9_get( + &context + ).await; + let mut response = Response::new(Body::empty()); + response.headers_mut().insert( + HeaderName::from_static("x-span-id"), + HeaderValue::from_str((&context as &dyn Has).get().0.clone().to_string().as_str()) + .expect("Unable to create X-Span-ID header value")); + + match result { + Ok(rsp) => match rsp { + Op9GetResponse::OK + => { + *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR; + *response.body_mut() = Body::from("An internal error occurred"); + }, + } + + Ok(response) + }, + + _ if path.matched(paths::ID_OP1) => method_not_allowed(), + _ if path.matched(paths::ID_OP10) => method_not_allowed(), + _ if path.matched(paths::ID_OP11) => method_not_allowed(), + _ if path.matched(paths::ID_OP12) => method_not_allowed(), + _ if path.matched(paths::ID_OP13) => method_not_allowed(), + _ if path.matched(paths::ID_OP14) => method_not_allowed(), + _ if path.matched(paths::ID_OP15) => method_not_allowed(), + _ if path.matched(paths::ID_OP16) => method_not_allowed(), + _ if path.matched(paths::ID_OP17) => method_not_allowed(), + _ if path.matched(paths::ID_OP18) => method_not_allowed(), + _ if path.matched(paths::ID_OP19) => method_not_allowed(), + _ if path.matched(paths::ID_OP2) => method_not_allowed(), + _ if path.matched(paths::ID_OP20) => method_not_allowed(), + _ if path.matched(paths::ID_OP21) => method_not_allowed(), + _ if path.matched(paths::ID_OP22) => method_not_allowed(), + _ if path.matched(paths::ID_OP23) => method_not_allowed(), + _ if path.matched(paths::ID_OP24) => method_not_allowed(), + _ if path.matched(paths::ID_OP25) => method_not_allowed(), + _ if path.matched(paths::ID_OP26) => method_not_allowed(), + _ if path.matched(paths::ID_OP27) => method_not_allowed(), + _ if path.matched(paths::ID_OP28) => method_not_allowed(), + _ if path.matched(paths::ID_OP29) => method_not_allowed(), + _ if path.matched(paths::ID_OP3) => method_not_allowed(), + _ if path.matched(paths::ID_OP30) => method_not_allowed(), + _ if path.matched(paths::ID_OP31) => method_not_allowed(), + _ if path.matched(paths::ID_OP32) => method_not_allowed(), + _ if path.matched(paths::ID_OP33) => method_not_allowed(), + _ if path.matched(paths::ID_OP34) => method_not_allowed(), + _ if path.matched(paths::ID_OP35) => method_not_allowed(), + _ if path.matched(paths::ID_OP36) => method_not_allowed(), + _ if path.matched(paths::ID_OP37) => method_not_allowed(), + _ if path.matched(paths::ID_OP4) => method_not_allowed(), + _ if path.matched(paths::ID_OP5) => method_not_allowed(), + _ if path.matched(paths::ID_OP6) => method_not_allowed(), + _ if path.matched(paths::ID_OP7) => method_not_allowed(), + _ if path.matched(paths::ID_OP8) => method_not_allowed(), + _ if path.matched(paths::ID_OP9) => method_not_allowed(), + _ => Ok(Response::builder().status(StatusCode::NOT_FOUND) + .body(Body::empty()) + .expect("Unable to create Not Found response")) + } + } Box::pin(run(self.api_impl.clone(), req)) } +} + +/// Request parser for `Api`. +pub struct ApiRequestParser; +impl RequestParser for ApiRequestParser { + fn parse_operation_id(request: &Request) -> Option<&'static str> { + let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); + match request.method() { + // Op10Get - GET /op10 + &hyper::Method::GET if path.matched(paths::ID_OP10) => Some("Op10Get"), + // Op11Get - GET /op11 + &hyper::Method::GET if path.matched(paths::ID_OP11) => Some("Op11Get"), + // Op12Get - GET /op12 + &hyper::Method::GET if path.matched(paths::ID_OP12) => Some("Op12Get"), + // Op13Get - GET /op13 + &hyper::Method::GET if path.matched(paths::ID_OP13) => Some("Op13Get"), + // Op14Get - GET /op14 + &hyper::Method::GET if path.matched(paths::ID_OP14) => Some("Op14Get"), + // Op15Get - GET /op15 + &hyper::Method::GET if path.matched(paths::ID_OP15) => Some("Op15Get"), + // Op16Get - GET /op16 + &hyper::Method::GET if path.matched(paths::ID_OP16) => Some("Op16Get"), + // Op17Get - GET /op17 + &hyper::Method::GET if path.matched(paths::ID_OP17) => Some("Op17Get"), + // Op18Get - GET /op18 + &hyper::Method::GET if path.matched(paths::ID_OP18) => Some("Op18Get"), + // Op19Get - GET /op19 + &hyper::Method::GET if path.matched(paths::ID_OP19) => Some("Op19Get"), + // Op1Get - GET /op1 + &hyper::Method::GET if path.matched(paths::ID_OP1) => Some("Op1Get"), + // Op20Get - GET /op20 + &hyper::Method::GET if path.matched(paths::ID_OP20) => Some("Op20Get"), + // Op21Get - GET /op21 + &hyper::Method::GET if path.matched(paths::ID_OP21) => Some("Op21Get"), + // Op22Get - GET /op22 + &hyper::Method::GET if path.matched(paths::ID_OP22) => Some("Op22Get"), + // Op23Get - GET /op23 + &hyper::Method::GET if path.matched(paths::ID_OP23) => Some("Op23Get"), + // Op24Get - GET /op24 + &hyper::Method::GET if path.matched(paths::ID_OP24) => Some("Op24Get"), + // Op25Get - GET /op25 + &hyper::Method::GET if path.matched(paths::ID_OP25) => Some("Op25Get"), + // Op26Get - GET /op26 + &hyper::Method::GET if path.matched(paths::ID_OP26) => Some("Op26Get"), + // Op27Get - GET /op27 + &hyper::Method::GET if path.matched(paths::ID_OP27) => Some("Op27Get"), + // Op28Get - GET /op28 + &hyper::Method::GET if path.matched(paths::ID_OP28) => Some("Op28Get"), + // Op29Get - GET /op29 + &hyper::Method::GET if path.matched(paths::ID_OP29) => Some("Op29Get"), + // Op2Get - GET /op2 + &hyper::Method::GET if path.matched(paths::ID_OP2) => Some("Op2Get"), + // Op30Get - GET /op30 + &hyper::Method::GET if path.matched(paths::ID_OP30) => Some("Op30Get"), + // Op31Get - GET /op31 + &hyper::Method::GET if path.matched(paths::ID_OP31) => Some("Op31Get"), + // Op32Get - GET /op32 + &hyper::Method::GET if path.matched(paths::ID_OP32) => Some("Op32Get"), + // Op33Get - GET /op33 + &hyper::Method::GET if path.matched(paths::ID_OP33) => Some("Op33Get"), + // Op34Get - GET /op34 + &hyper::Method::GET if path.matched(paths::ID_OP34) => Some("Op34Get"), + // Op35Get - GET /op35 + &hyper::Method::GET if path.matched(paths::ID_OP35) => Some("Op35Get"), + // Op36Get - GET /op36 + &hyper::Method::GET if path.matched(paths::ID_OP36) => Some("Op36Get"), + // Op37Get - GET /op37 + &hyper::Method::GET if path.matched(paths::ID_OP37) => Some("Op37Get"), + // Op3Get - GET /op3 + &hyper::Method::GET if path.matched(paths::ID_OP3) => Some("Op3Get"), + // Op4Get - GET /op4 + &hyper::Method::GET if path.matched(paths::ID_OP4) => Some("Op4Get"), + // Op5Get - GET /op5 + &hyper::Method::GET if path.matched(paths::ID_OP5) => Some("Op5Get"), + // Op6Get - GET /op6 + &hyper::Method::GET if path.matched(paths::ID_OP6) => Some("Op6Get"), + // Op7Get - GET /op7 + &hyper::Method::GET if path.matched(paths::ID_OP7) => Some("Op7Get"), + // Op8Get - GET /op8 + &hyper::Method::GET if path.matched(paths::ID_OP8) => Some("Op8Get"), + // Op9Get - GET /op9 + &hyper::Method::GET if path.matched(paths::ID_OP9) => Some("Op9Get"), + _ => None, + } + } +}