update samples

This commit is contained in:
William Cheng
2022-02-14 11:45:12 +08:00
parent dce8b80af7
commit 5346d0b6b7
14 changed files with 271 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ $properties = @(
'apiName=Api', 'apiName=Api',
'targetFramework=netstandard2.0', 'targetFramework=netstandard2.0',
'validatable=true', 'validatable=true',
'nullableReferenceTypes=false', 'nullableReferenceTypes=',
'hideGenerationTimestamp=true', 'hideGenerationTimestamp=true',
'packageVersion=1.0.0', 'packageVersion=1.0.0',
'packageAuthors=OpenAPI', 'packageAuthors=OpenAPI',
@@ -232,7 +232,7 @@ Authentication schemes defined for the API:
- modelPropertyNaming: - modelPropertyNaming:
- netCoreProjectFile: false - netCoreProjectFile: false
- nonPublicApi: false - nonPublicApi: false
- nullableReferenceTypes: false - nullableReferenceTypes:
- optionalAssemblyInfo: - optionalAssemblyInfo:
- optionalEmitDefaultValues: false - optionalEmitDefaultValues: false
- optionalMethodArgument: true - optionalMethodArgument: true

View File

@@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object):
'_preload_content', '_preload_content',
'_request_timeout', '_request_timeout',
'_request_auth', '_request_auth',
'_content_type' '_content_type',
'_headers'
] ]
) )
@@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object):
query_params = [] query_params = []
header_params = {} header_params = dict(local_var_params.get('_headers', {}))
form_params = [] form_params = []
local_var_files = {} local_var_files = {}

View File

@@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object):
'_preload_content', '_preload_content',
'_request_timeout', '_request_timeout',
'_request_auth', '_request_auth',
'_content_type' '_content_type',
'_headers'
] ]
) )
@@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object):
query_params = [] query_params = []
header_params = {} header_params = dict(local_var_params.get('_headers', {}))
form_params = [] form_params = []
local_var_files = {} local_var_files = {}

View File

@@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object):
'_preload_content', '_preload_content',
'_request_timeout', '_request_timeout',
'_request_auth', '_request_auth',
'_content_type' '_content_type',
'_headers'
] ]
) )
@@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object):
query_params = [] query_params = []
header_params = {} header_params = dict(local_var_params.get('_headers', {}))
form_params = [] form_params = []
local_var_files = {} local_var_files = {}

View File

@@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object):
_check_return_type (bool): specifies if type checking _check_return_type (bool): specifies if type checking
should be done one the data received from the server. should be done one the data received from the server.
Default is True. Default is True.
_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)
_content_type (str/None): force body content-type. _content_type (str/None): force body content-type.
Default is None and content-type will be predicted by allowed Default is None and content-type will be predicted by allowed
content-types and body. content-types and body.
@@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object):
kwargs['_check_return_type'] = kwargs.get( kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True '_check_return_type', True
) )
kwargs['_spec_property_naming'] = kwargs.get(
'_spec_property_naming', False
)
kwargs['_content_type'] = kwargs.get( kwargs['_content_type'] = kwargs.get(
'_content_type') '_content_type')
kwargs['_host_index'] = kwargs.get('_host_index') kwargs['_host_index'] = kwargs.get('_host_index')

View File

@@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object):
_check_return_type (bool): specifies if type checking _check_return_type (bool): specifies if type checking
should be done one the data received from the server. should be done one the data received from the server.
Default is True. Default is True.
_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)
_content_type (str/None): force body content-type. _content_type (str/None): force body content-type.
Default is None and content-type will be predicted by allowed Default is None and content-type will be predicted by allowed
content-types and body. content-types and body.
@@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object):
kwargs['_check_return_type'] = kwargs.get( kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True '_check_return_type', True
) )
kwargs['_spec_property_naming'] = kwargs.get(
'_spec_property_naming', False
)
kwargs['_content_type'] = kwargs.get( kwargs['_content_type'] = kwargs.get(
'_content_type') '_content_type')
kwargs['_host_index'] = kwargs.get('_host_index') kwargs['_host_index'] = kwargs.get('_host_index')

View File

@@ -134,7 +134,7 @@ petstore_api/api/__init__.py
petstore_api/api/another_fake_api.py petstore_api/api/another_fake_api.py
petstore_api/api/default_api.py petstore_api/api/default_api.py
petstore_api/api/fake_api.py petstore_api/api/fake_api.py
petstore_api/api/fake_classname_tags_123_api.py petstore_api/api/fake_classname_tags123_api.py
petstore_api/api/pet_api.py petstore_api/api/pet_api.py
petstore_api/api/store_api.py petstore_api/api/store_api.py
petstore_api/api/user_api.py petstore_api/api/user_api.py
@@ -271,4 +271,5 @@ setup.cfg
setup.py setup.py
test-requirements.txt test-requirements.txt
test/__init__.py test/__init__.py
test/test_fake_classname_tags123_api.py
tox.ini tox.ini

View File

@@ -18,7 +18,7 @@ To test class name in snake case
* Api Key Authentication (api_key_query): * Api Key Authentication (api_key_query):
```python ```python
import petstore_api import petstore_api
from petstore_api.api import fake_classname_tags_123_api from petstore_api.api import fake_classname_tags123_api
from petstore_api.model.client import Client from petstore_api.model.client import Client
from pprint import pprint from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 # Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
@@ -40,7 +40,7 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
# Enter a context with an instance of the API client # Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client: with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class # Create an instance of the API class
api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client) api_instance = fake_classname_tags123_api.FakeClassnameTags123Api(api_client)
# example passing only required values which don't have defaults set # example passing only required values which don't have defaults set
body = Client( body = Client(

View File

@@ -0,0 +1,25 @@
# 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
"""
from petstore_api.api_client import ApiClient
from petstore_api.api.fake_classname_tags123_api_endpoints.classname import Classname
class FakeClassnameTags123Api(
Classname,
ApiClient,
):
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
pass

View File

@@ -0,0 +1,170 @@
# coding: utf-8
"""
Generated by: https://openapi-generator.tech
"""
from dataclasses import dataclass
import re # noqa: F401
import sys # noqa: F401
import typing
import urllib3
from urllib3._collections import HTTPHeaderDict
from petstore_api import api_client, exceptions
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from petstore_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
InstantiationMetadata,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
from petstore_api.model.client import Client
# body param
SchemaForRequestBodyApplicationJson = Client
request_body_client = api_client.RequestBody(
content={
'application/json': api_client.MediaType(
schema=SchemaForRequestBodyApplicationJson),
},
required=True,
)
_path = '/fake_classname_test'
_method = 'PATCH'
_auth = [
'api_key_query',
]
SchemaFor200ResponseBodyApplicationJson = Client
@dataclass
class ApiResponseFor200(api_client.ApiResponse):
response: urllib3.HTTPResponse
body: typing.Union[
SchemaFor200ResponseBodyApplicationJson,
]
headers: Unset = unset
_response_for_200 = api_client.OpenApiResponse(
response_cls=ApiResponseFor200,
content={
'application/json': api_client.MediaType(
schema=SchemaFor200ResponseBodyApplicationJson),
},
)
_status_code_to_response = {
'200': _response_for_200,
}
_all_accept_content_types = (
'application/json',
)
class Classname(api_client.Api):
def classname(
self: api_client.Api,
body: typing.Union[SchemaForRequestBodyApplicationJson],
content_type: str = 'application/json',
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
"""
To test class name in snake case
:param skip_deserialization: If true then api_response.response will be set but
api_response.body and api_response.headers will not be deserialized into schema
class instances
"""
_headers = HTTPHeaderDict()
# TODO add cookie handling
if accept_content_types:
for accept_content_type in accept_content_types:
_headers.add('Accept', accept_content_type)
if body is unset:
raise exceptions.ApiValueError(
'The required body parameter has an invalid value of: unset. Set a valid value instead')
_fields = None
_body = None
serialized_data = request_body_client.serialize(body, content_type)
_headers.add('Content-Type', content_type)
if 'fields' in serialized_data:
_fields = serialized_data['fields']
elif 'body' in serialized_data:
_body = serialized_data['body']
response = self.api_client.call_api(
resource_path=_path,
method=_method,
headers=_headers,
fields=_fields,
body=_body,
auth_settings=_auth,
stream=stream,
timeout=timeout,
)
if skip_deserialization:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
else:
response_for_status = _status_code_to_response.get(str(response.status))
if response_for_status:
api_response = response_for_status.deserialize(response, self.api_client.configuration)
else:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
if not 200 <= response.status <= 299:
raise exceptions.ApiException(api_response=api_response)
return api_response

View File

@@ -18,7 +18,7 @@
from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.another_fake_api import AnotherFakeApi
from petstore_api.api.default_api import DefaultApi from petstore_api.api.default_api import DefaultApi
from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_api import FakeApi
from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api
from petstore_api.api.pet_api import PetApi from petstore_api.api.pet_api import PetApi
from petstore_api.api.store_api import StoreApi from petstore_api.api.store_api import StoreApi
from petstore_api.api.user_api import UserApi from petstore_api.api.user_api import UserApi

View File

@@ -0,0 +1,36 @@
# 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
"""
import unittest
import petstore_api
from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api # noqa: E501
class TestFakeClassnameTags123Api(unittest.TestCase):
"""FakeClassnameTags123Api unit test stubs"""
def setUp(self):
self.api = FakeClassnameTags123Api() # noqa: E501
def tearDown(self):
pass
def test_classname(self):
"""Test case for classname
To test class name in snake case # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object):
'_preload_content', '_preload_content',
'_request_timeout', '_request_timeout',
'_request_auth', '_request_auth',
'_content_type' '_content_type',
'_headers'
] ]
) )
@@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object):
query_params = [] query_params = []
header_params = {} header_params = dict(local_var_params.get('_headers', {}))
form_params = [] form_params = []
local_var_files = {} local_var_files = {}

View File

@@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object):
_check_return_type (bool): specifies if type checking _check_return_type (bool): specifies if type checking
should be done one the data received from the server. should be done one the data received from the server.
Default is True. Default is True.
_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)
_content_type (str/None): force body content-type. _content_type (str/None): force body content-type.
Default is None and content-type will be predicted by allowed Default is None and content-type will be predicted by allowed
content-types and body. content-types and body.
@@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object):
kwargs['_check_return_type'] = kwargs.get( kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True '_check_return_type', True
) )
kwargs['_spec_property_naming'] = kwargs.get(
'_spec_property_naming', False
)
kwargs['_content_type'] = kwargs.get( kwargs['_content_type'] = kwargs.get(
'_content_type') '_content_type')
kwargs['_host_index'] = kwargs.get('_host_index') kwargs['_host_index'] = kwargs.get('_host_index')