diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/README.md index 58766deeff2..0026fcb3f1a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/README.md @@ -8,7 +8,7 @@ $properties = @( 'apiName=Api', 'targetFramework=netstandard2.0', 'validatable=true', - 'nullableReferenceTypes=false', + 'nullableReferenceTypes=', 'hideGenerationTimestamp=true', 'packageVersion=1.0.0', 'packageAuthors=OpenAPI', @@ -232,7 +232,7 @@ Authentication schemes defined for the API: - modelPropertyNaming: - netCoreProjectFile: false - nonPublicApi: false -- nullableReferenceTypes: false +- nullableReferenceTypes: - optionalAssemblyInfo: - optionalEmitDefaultValues: false - optionalMethodArgument: true diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py index 2b46147fed5..b5cd8cd22c9 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py @@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object): '_preload_content', '_request_timeout', '_request_auth', - '_content_type' + '_content_type', + '_headers' ] ) @@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object): query_params = [] - header_params = {} + header_params = dict(local_var_params.get('_headers', {})) form_params = [] local_var_files = {} diff --git a/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py index 2b46147fed5..b5cd8cd22c9 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py @@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object): '_preload_content', '_request_timeout', '_request_auth', - '_content_type' + '_content_type', + '_headers' ] ) @@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object): query_params = [] - header_params = {} + header_params = dict(local_var_params.get('_headers', {})) form_params = [] local_var_files = {} diff --git a/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py index 2b46147fed5..b5cd8cd22c9 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py @@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object): '_preload_content', '_request_timeout', '_request_auth', - '_content_type' + '_content_type', + '_headers' ] ) @@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object): query_params = [] - header_params = {} + header_params = dict(local_var_params.get('_headers', {})) form_params = [] local_var_files = {} diff --git a/samples/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index 76e35824fbe..70b4a535a81 100644 --- a/samples/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object): _check_return_type (bool): specifies if type checking should be done one the data received from the server. 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. Default is None and content-type will be predicted by allowed content-types and body. @@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object): kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) + kwargs['_spec_property_naming'] = kwargs.get( + '_spec_property_naming', False + ) kwargs['_content_type'] = kwargs.get( '_content_type') kwargs['_host_index'] = kwargs.get('_host_index') diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags123_api.py index 76e35824fbe..70b4a535a81 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api/fake_classname_tags123_api.py @@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object): _check_return_type (bool): specifies if type checking should be done one the data received from the server. 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. Default is None and content-type will be predicted by allowed content-types and body. @@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object): kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) + kwargs['_spec_property_naming'] = kwargs.get( + '_spec_property_naming', False + ) kwargs['_content_type'] = kwargs.get( '_content_type') kwargs['_host_index'] = kwargs.get('_host_index') diff --git a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/FILES index 48127260f21..c44ad090edd 100644 --- a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/FILES @@ -134,7 +134,7 @@ petstore_api/api/__init__.py petstore_api/api/another_fake_api.py petstore_api/api/default_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/store_api.py petstore_api/api/user_api.py @@ -271,4 +271,5 @@ setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_fake_classname_tags123_api.py tox.ini diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md index 6d5c732f70e..f5ddd953897 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md @@ -18,7 +18,7 @@ To test class name in snake case * Api Key Authentication (api_key_query): ```python 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 pprint import pprint # 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 with petstore_api.ApiClient(configuration) as api_client: # 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 body = Client( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api.py new file mode 100644 index 00000000000..ce7cfd29f70 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api.py @@ -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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api_endpoints/classname.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api_endpoints/classname.py new file mode 100644 index 00000000000..d4839bb9b69 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_classname_tags123_api_endpoints/classname.py @@ -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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/apis/__init__.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/apis/__init__.py index 5a98862bba0..6b58c42daa6 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/apis/__init__.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/apis/__init__.py @@ -18,7 +18,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_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.store_api import StoreApi from petstore_api.api.user_api import UserApi diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-experimental/test/test_fake_classname_tags123_api.py new file mode 100644 index 00000000000..705fd1fc9cd --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_fake_classname_tags123_api.py @@ -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() diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py index 1dd90624e71..05c1c8a0e4f 100644 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py @@ -114,7 +114,8 @@ class FakeClassnameTags123Api(object): '_preload_content', '_request_timeout', '_request_auth', - '_content_type' + '_content_type', + '_headers' ] ) @@ -137,7 +138,7 @@ class FakeClassnameTags123Api(object): query_params = [] - header_params = {} + header_params = dict(local_var_params.get('_headers', {})) form_params = [] local_var_files = {} diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index 0284c348b36..a6c187b0251 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -121,6 +121,10 @@ class FakeClassnameTags123Api(object): _check_return_type (bool): specifies if type checking should be done one the data received from the server. 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. Default is None and content-type will be predicted by allowed content-types and body. @@ -152,6 +156,9 @@ class FakeClassnameTags123Api(object): kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) + kwargs['_spec_property_naming'] = kwargs.get( + '_spec_property_naming', False + ) kwargs['_content_type'] = kwargs.get( '_content_type') kwargs['_host_index'] = kwargs.get('_host_index')