From e39b99051c2bdaf5ad14d0b876cca60a722134f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= <34892635+fa0311@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:40:33 +0900 Subject: [PATCH] [python] add test Missing the important statement for Datetime in Python binding generation (#18175) * [python] add test on datetime response import * [python] update sample * [python] update sample --- ...ith-fake-endpoints-models-for-testing.yaml | 14 + .../openapi_client/api/auth_api.py | 1 + .../python/openapi_client/api/auth_api.py | 1 + .../python-aiohttp/.openapi-generator/FILES | 2 + .../client/petstore/python-aiohttp/README.md | 1 + .../docs/ImportTestDatetimeApi.md | 70 +++++ .../python-aiohttp/petstore_api/__init__.py | 1 + .../petstore_api/api/__init__.py | 1 + .../api/import_test_datetime_api.py | 275 ++++++++++++++++++ .../petstore_api/api/store_api.py | 3 +- .../test/test_import_test_datetime_api.py | 38 +++ .../.openapi-generator/FILES | 2 + .../python-pydantic-v1-aiohttp/README.md | 1 + .../docs/ImportTestDatetimeApi.md | 69 +++++ .../petstore_api/__init__.py | 1 + .../petstore_api/api/__init__.py | 1 + .../api/import_test_datetime_api.py | 157 ++++++++++ .../test/test_import_test_datetime_api.py | 38 +++ .../.openapi-generator/FILES | 2 + .../petstore/python-pydantic-v1/README.md | 1 + .../docs/ImportTestDatetimeApi.md | 69 +++++ .../petstore_api/__init__.py | 1 + .../petstore_api/api/__init__.py | 1 + .../api/import_test_datetime_api.py | 172 +++++++++++ .../test/test_import_test_datetime_api.py | 38 +++ .../petstore/python/.openapi-generator/FILES | 2 + .../openapi3/client/petstore/python/README.md | 1 + .../python/docs/ImportTestDatetimeApi.md | 70 +++++ .../petstore/python/petstore_api/__init__.py | 1 + .../python/petstore_api/api/__init__.py | 1 + .../api/import_test_datetime_api.py | 275 ++++++++++++++++++ .../python/petstore_api/api/store_api.py | 3 +- .../test/test_import_test_datetime_api.py | 38 +++ 33 files changed, 1349 insertions(+), 2 deletions(-) create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/ImportTestDatetimeApi.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ImportTestDatetimeApi.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/ImportTestDatetimeApi.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python/docs/ImportTestDatetimeApi.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py create mode 100644 samples/openapi3/client/petstore/python/test/test_import_test_datetime_api.py diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index 2de718448471..aee3e5544fce 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1524,6 +1524,20 @@ paths: schema: type: string format: byte + /import_test/return_datetime: + get: + tags: + - import-test-datetime + summary: test date time + operationId: import_test_return_datetime + responses: + 200: + description: OK + content: + application/json: + schema: + format: date-time + type: string servers: - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py index 3e1140868079..dfd24668c5ee 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/auth_api.py @@ -17,6 +17,7 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated +from pydantic import StrictStr from openapi_client.api_client import ApiClient, RequestSerialized from openapi_client.api_response import ApiResponse diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index 3e1140868079..dfd24668c5ee 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -17,6 +17,7 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated +from pydantic import StrictStr from openapi_client.api_client import ApiClient, RequestSerialized from openapi_client.api_response import ApiResponse diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 8ca56876d60f..cc12732eaed8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -50,6 +50,7 @@ docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/ImportTestDatetimeApi.md docs/InnerDictWithProperty.md docs/InputAllOf.md docs/IntOrString.md @@ -109,6 +110,7 @@ petstore_api/api/another_fake_api.py petstore_api/api/default_api.py petstore_api/api/fake_api.py petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/import_test_datetime_api.py petstore_api/api/pet_api.py petstore_api/api/store_api.py petstore_api/api/user_api.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 786d1ec7491b..48ddb10468b3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -123,6 +123,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*ImportTestDatetimeApi* | [**import_test_return_datetime**](docs/ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/ImportTestDatetimeApi.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ImportTestDatetimeApi.md new file mode 100644 index 000000000000..fd20b1e873d4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ImportTestDatetimeApi.md @@ -0,0 +1,70 @@ +# petstore_api.ImportTestDatetimeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**import_test_return_datetime**](ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time + + +# **import_test_return_datetime** +> datetime import_test_return_datetime() + +test date time + +### Example + + +```python +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.ImportTestDatetimeApi(api_client) + + try: + # test date time + api_response = await api_instance.import_test_return_datetime() + print("The response of ImportTestDatetimeApi->import_test_return_datetime:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ImportTestDatetimeApi->import_test_return_datetime: %s\n" % e) +``` + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**datetime** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[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/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index b038a7fc2608..003d9fa61b75 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -21,6 +21,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/__init__.py index 7a2616975a2f..79d2ab7dc931 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/__init__.py @@ -5,6 +5,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py new file mode 100644 index 000000000000..16a8ea0f3239 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/import_test_datetime_api.py @@ -0,0 +1,275 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from datetime import datetime + +from petstore_api.api_client import ApiClient, RequestSerialized +from petstore_api.api_response import ApiResponse +from petstore_api.rest import RESTResponseType + + +class ImportTestDatetimeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def import_test_return_datetime( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> datetime: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def import_test_return_datetime_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[datetime]: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def import_test_return_datetime_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _import_test_return_datetime_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/import_test/return_datetime', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index 1f84e3d5a4ab..d4150f7f9b97 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -16,7 +16,8 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import Field, StrictStr +from pydantic import Field, StrictInt, StrictStr +from typing import Dict from typing_extensions import Annotated from petstore_api.models.order import Order diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_import_test_datetime_api.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_import_test_datetime_api.py new file mode 100644 index 000000000000..6cd4fb8cbaf5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_import_test_datetime_api.py @@ -0,0 +1,38 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi + + +class TestImportTestDatetimeApi(unittest.TestCase): + """ImportTestDatetimeApi unit test stubs""" + + def setUp(self) -> None: + self.api = ImportTestDatetimeApi() + + def tearDown(self) -> None: + pass + + def test_import_test_return_datetime(self) -> None: + """Test case for import_test_return_datetime + + test date time + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES index fa3538ce756b..eb888a3ec67a 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES @@ -51,6 +51,7 @@ docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/ImportTestDatetimeApi.md docs/InnerDictWithProperty.md docs/InputAllOf.md docs/IntOrString.md @@ -109,6 +110,7 @@ petstore_api/api/another_fake_api.py petstore_api/api/default_api.py petstore_api/api/fake_api.py petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/import_test_datetime_api.py petstore_api/api/pet_api.py petstore_api/api/store_api.py petstore_api/api/user_api.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md index a82cd0b31ea7..0e380ce1c892 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -124,6 +124,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*ImportTestDatetimeApi* | [**import_test_return_datetime**](docs/ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ImportTestDatetimeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ImportTestDatetimeApi.md new file mode 100644 index 000000000000..2f2c198f2ad7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ImportTestDatetimeApi.md @@ -0,0 +1,69 @@ +# petstore_api.ImportTestDatetimeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**import_test_return_datetime**](ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time + + +# **import_test_return_datetime** +> datetime import_test_return_datetime() + +test date time + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.ImportTestDatetimeApi(api_client) + + try: + # test date time + api_response = await api_instance.import_test_return_datetime() + print("The response of ImportTestDatetimeApi->import_test_return_datetime:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ImportTestDatetimeApi->import_test_return_datetime: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**datetime** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[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/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py index 5b780780fd85..17351301564e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py @@ -21,6 +21,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/__init__.py index 7a2616975a2f..79d2ab7dc931 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/__init__.py @@ -5,6 +5,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/import_test_datetime_api.py new file mode 100644 index 000000000000..daa8449ea38d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/import_test_datetime_api.py @@ -0,0 +1,157 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError +from typing import overload, Optional, Union, Awaitable + +from datetime import datetime + + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ImportTestDatetimeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + async def import_test_return_datetime(self, **kwargs) -> datetime: # noqa: E501 + """test date time # noqa: E501 + + + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: datetime + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the import_test_return_datetime_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return await self.import_test_return_datetime_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + async def import_test_return_datetime_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test date time # noqa: E501 + + + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(datetime, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method import_test_return_datetime" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "datetime", + } + + return await self.api_client.call_api( + '/import_test/return_datetime', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_import_test_datetime_api.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_import_test_datetime_api.py new file mode 100644 index 000000000000..82e7781c0821 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_import_test_datetime_api.py @@ -0,0 +1,38 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi # noqa: E501 + + +class TestImportTestDatetimeApi(unittest.TestCase): + """ImportTestDatetimeApi unit test stubs""" + + def setUp(self) -> None: + self.api = ImportTestDatetimeApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_import_test_return_datetime(self) -> None: + """Test case for import_test_return_datetime + + test date time # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES index fa3538ce756b..eb888a3ec67a 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -51,6 +51,7 @@ docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/ImportTestDatetimeApi.md docs/InnerDictWithProperty.md docs/InputAllOf.md docs/IntOrString.md @@ -109,6 +110,7 @@ petstore_api/api/another_fake_api.py petstore_api/api/default_api.py petstore_api/api/fake_api.py petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/import_test_datetime_api.py petstore_api/api/pet_api.py petstore_api/api/store_api.py petstore_api/api/user_api.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 2aa26baea077..a0315cceb7e2 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -124,6 +124,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*ImportTestDatetimeApi* | [**import_test_return_datetime**](docs/ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/ImportTestDatetimeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/ImportTestDatetimeApi.md new file mode 100644 index 000000000000..9071e2a5cc26 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/ImportTestDatetimeApi.md @@ -0,0 +1,69 @@ +# petstore_api.ImportTestDatetimeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**import_test_return_datetime**](ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time + + +# **import_test_return_datetime** +> datetime import_test_return_datetime() + +test date time + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.ImportTestDatetimeApi(api_client) + + try: + # test date time + api_response = api_instance.import_test_return_datetime() + print("The response of ImportTestDatetimeApi->import_test_return_datetime:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ImportTestDatetimeApi->import_test_return_datetime: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**datetime** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[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/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py index 5b780780fd85..17351301564e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py @@ -21,6 +21,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/__init__.py index 7a2616975a2f..79d2ab7dc931 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/__init__.py @@ -5,6 +5,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/import_test_datetime_api.py new file mode 100644 index 000000000000..b6a09bad5229 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/import_test_datetime_api.py @@ -0,0 +1,172 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from datetime import datetime + + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ImportTestDatetimeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_arguments + def import_test_return_datetime(self, **kwargs) -> datetime: # noqa: E501 + """test date time # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.import_test_return_datetime(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: datetime + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the import_test_return_datetime_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.import_test_return_datetime_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def import_test_return_datetime_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test date time # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.import_test_return_datetime_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(datetime, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method import_test_return_datetime" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "datetime", + } + + return self.api_client.call_api( + '/import_test/return_datetime', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_import_test_datetime_api.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_import_test_datetime_api.py new file mode 100644 index 000000000000..82e7781c0821 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_import_test_datetime_api.py @@ -0,0 +1,38 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi # noqa: E501 + + +class TestImportTestDatetimeApi(unittest.TestCase): + """ImportTestDatetimeApi unit test stubs""" + + def setUp(self) -> None: + self.api = ImportTestDatetimeApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_import_test_return_datetime(self) -> None: + """Test case for import_test_return_datetime + + test date time # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 8ca56876d60f..cc12732eaed8 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -50,6 +50,7 @@ docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/ImportTestDatetimeApi.md docs/InnerDictWithProperty.md docs/InputAllOf.md docs/IntOrString.md @@ -109,6 +110,7 @@ petstore_api/api/another_fake_api.py petstore_api/api/default_api.py petstore_api/api/fake_api.py petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/import_test_datetime_api.py petstore_api/api/pet_api.py petstore_api/api/store_api.py petstore_api/api/user_api.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 08b0a1e89373..0cf77f4f8899 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -123,6 +123,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*ImportTestDatetimeApi* | [**import_test_return_datetime**](docs/ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/openapi3/client/petstore/python/docs/ImportTestDatetimeApi.md b/samples/openapi3/client/petstore/python/docs/ImportTestDatetimeApi.md new file mode 100644 index 000000000000..9e8e90a99a34 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/ImportTestDatetimeApi.md @@ -0,0 +1,70 @@ +# petstore_api.ImportTestDatetimeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**import_test_return_datetime**](ImportTestDatetimeApi.md#import_test_return_datetime) | **GET** /import_test/return_datetime | test date time + + +# **import_test_return_datetime** +> datetime import_test_return_datetime() + +test date time + +### Example + + +```python +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.ImportTestDatetimeApi(api_client) + + try: + # test date time + api_response = api_instance.import_test_return_datetime() + print("The response of ImportTestDatetimeApi->import_test_return_datetime:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ImportTestDatetimeApi->import_test_return_datetime: %s\n" % e) +``` + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**datetime** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[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/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index b038a7fc2608..003d9fa61b75 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -21,6 +21,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/api/__init__.py index 7a2616975a2f..79d2ab7dc931 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/__init__.py @@ -5,6 +5,7 @@ from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi from petstore_api.api.pet_api import PetApi from petstore_api.api.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py new file mode 100644 index 000000000000..f2467c71f2a4 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/api/import_test_datetime_api.py @@ -0,0 +1,275 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from datetime import datetime + +from petstore_api.api_client import ApiClient, RequestSerialized +from petstore_api.api_response import ApiResponse +from petstore_api.rest import RESTResponseType + + +class ImportTestDatetimeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def import_test_return_datetime( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> datetime: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def import_test_return_datetime_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[datetime]: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def import_test_return_datetime_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test date time + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._import_test_return_datetime_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "datetime", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _import_test_return_datetime_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/import_test/return_datetime', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index bd1108c901cc..c50d82d6a5b7 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -16,7 +16,8 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import Field, StrictStr +from pydantic import Field, StrictInt, StrictStr +from typing import Dict from typing_extensions import Annotated from petstore_api.models.order import Order diff --git a/samples/openapi3/client/petstore/python/test/test_import_test_datetime_api.py b/samples/openapi3/client/petstore/python/test/test_import_test_datetime_api.py new file mode 100644 index 000000000000..6cd4fb8cbaf5 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_import_test_datetime_api.py @@ -0,0 +1,38 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.api.import_test_datetime_api import ImportTestDatetimeApi + + +class TestImportTestDatetimeApi(unittest.TestCase): + """ImportTestDatetimeApi unit test stubs""" + + def setUp(self) -> None: + self.api = ImportTestDatetimeApi() + + def tearDown(self) -> None: + pass + + def test_import_test_return_datetime(self) -> None: + """Test case for import_test_return_datetime + + test date time + """ + pass + + +if __name__ == '__main__': + unittest.main()