forked from loafle/openapi-generator-original
[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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'))
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user