[python-nextgen] better sample code (#15248)

* better python-nextgen sample code

* remove future import

* fix signing doc

* better test

* use hasHttpBearerMethods instead
This commit is contained in:
William Cheng
2023-04-19 15:55:06 +08:00
committed by GitHub
parent e3fdac0711
commit 0176957e26
28 changed files with 325 additions and 880 deletions

View File

@@ -19,12 +19,12 @@ Test binary (gif) response body
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -46,6 +46,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling BodyApi->test_binary_gif: %s\n" % e)
```
### Parameters
This endpoint does not need any parameter.
@@ -79,12 +80,13 @@ Test body parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.models.pet import Pet
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -107,6 +109,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling BodyApi->test_echo_body_pet: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -143,12 +146,13 @@ Test empty response body
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.models.pet import Pet
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -171,6 +175,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling BodyApi->test_echo_body_pet_response_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes

View File

@@ -17,12 +17,12 @@ Test form parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -47,6 +47,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling FormApi->test_form_integer_boolean_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes

View File

@@ -17,12 +17,12 @@ Test header parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -47,6 +47,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling HeaderApi->test_header_integer_boolean_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes

View File

@@ -17,12 +17,12 @@ Test path parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -46,6 +46,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling PathApi->tests_path_string_path_string_integer_path_integer: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes

View File

@@ -23,12 +23,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -53,6 +53,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_datetime_date_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -91,12 +92,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -121,6 +122,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_integer_boolean_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -159,12 +161,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -187,6 +189,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_style_deep_object_explode_true_object: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -223,12 +226,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -251,6 +254,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_style_deep_object_explode_true_object_all_of: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -287,12 +291,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -315,6 +319,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_style_form_explode_true_array_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -351,12 +356,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -379,6 +384,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_style_form_explode_true_object: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
@@ -415,12 +421,12 @@ Test query parameter(s)
### Example
```python
from __future__ import print_function
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
@@ -443,6 +449,7 @@ with openapi_client.ApiClient(configuration) as api_client:
print("Exception when calling QueryApi->test_query_style_form_explode_true_object_all_of: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes

View File

@@ -33,6 +33,7 @@ from openapi_client.exceptions import ApiValueError
from openapi_client.exceptions import ApiKeyError
from openapi_client.exceptions import ApiAttributeError
from openapi_client.exceptions import ApiException
# import models into sdk package
from openapi_client.models.bird import Bird
from openapi_client.models.category import Category

View File

@@ -31,6 +31,7 @@ class TestManual(unittest.TestCase):
def testDateTimeQueryWithDateTimeFormat(self):
api_instance = openapi_client.QueryApi()
datetime_format_backup = api_instance.api_client.configuration.datetime_format # backup dateime_format
api_instance.api_client.configuration.datetime_format = "%Y-%m-%d %a %H:%M:%S%Z"
datetime_query = datetime.datetime.fromisoformat('2013-10-20T19:20:30-05:00') # datetime | (optional)
date_query = '2013-10-20' # date | (optional)
@@ -41,6 +42,9 @@ class TestManual(unittest.TestCase):
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20%20Sun%2019%3A20%3A30UTC-05%3A00&date_query=2013-10-20&string_query=string_query_example")
# restore datetime format
api_instance.api_client.configuration.datetime_format = datetime_format_backup
def testDateTimeQueryWithDateTime(self):
api_instance = openapi_client.QueryApi()
datetime_query = datetime.datetime.fromisoformat('2013-10-20T19:20:30-05:00') # datetime | (optional)