Add a new Python client generator - python-nextgen (#14157)

* add python-nextgen generator

* remove client_side_validation from model

* remove configuraiton import from models

* add inheritance support

* update test requirements, tox

* add typings, pydanic to models

* add test model

* minor improvements

* add enum support

* add typing for parameters, remove validations

* add oneof, anyof support

* fix default value

* fix deserialization, api tests passed

* private variable naming, update tests, all tests passed

* remove six

* remove nose

* update doc

* remove sortParamsByRequiredFlag option

* add parameter validation

* add validation tests

* simplify Field()

* remove previous required parameter validation

* improve parameter handling

* support discriminator mapping

* better typing discriminator mapping

* format test code

* fix tests

* fix oneOf from_dict, add test

* add set validation test

* fix nested oneof serialization, add tests

* add model import

* remove models. prefix

* remove import models

* remove model import from api

* simplify from_dict

* add typing for return

* skip pydantic import in return type

* fix tests, fix enum

* restore more enum schema tests

* uncomment enum integer test

* clean up getfullargspec import in model

* clean up getfullargspec import

* fix deserilizatoin for nested oneof

* minor fixes, add tests

* fix regular expression

* add aiohttp samples, add tests

* remove default content type to json

* update template

* fix select accept, content-type

* move tests

* move tests

* fix url query parameters

* fix list

* fix samples

* fix param pydantic, add list as reserved word

* fix auto-generated doc

* fix readme

* fix list, fix special variable name with var_

* fix Literal in python 3.7

* fix default configuration

* fix aiohttp tests

* set default api client instance

* deprecate get_default_copy method

* fix enum model

* fix enum serializatio/deserialization

* add github workflow support

* add regular expression validator

* add enum validator

* better model import

* fix file, remove x-py-import-models

* rename local var

* better model example

* fix regular expression warning, add special_name test, whitelist schema

* skip self import

* update samples

* various fixes

* add base64, json as reserved word

* add http signature support

* add http signature test

* add additioanl properties support in python client

* add decimal support

* use strictstr instead of constr

* fix test with virtualenv

* add nullable support

* add readonly support

* add model name caching

* fix circular reference import

* add onelook discriminator lookup

* add tests

* update samples

* fix locale

* Fix client legacy generator asyncio README code example

* test python-nextgen in circleci

* fix pom.xml

* update python to 3.7.15

* test with python 3.7.12

* various updates

* fix python legacy
This commit is contained in:
William Cheng
2022-12-17 16:05:47 +08:00
committed by GitHub
parent 6800905123
commit 0cf5ed619d
568 changed files with 56832 additions and 272 deletions

View File

@@ -4,14 +4,14 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_string** | **dict(str, str)** | | [optional]
**map_number** | **dict(str, float)** | | [optional]
**map_integer** | **dict(str, int)** | | [optional]
**map_boolean** | **dict(str, bool)** | | [optional]
**map_array_integer** | **dict(str, list[int])** | | [optional]
**map_array_anytype** | **dict(str, list[object])** | | [optional]
**map_map_string** | **dict(str, dict(str, str))** | | [optional]
**map_map_anytype** | **dict(str, dict(str, object))** | | [optional]
**map_string** | **dict[str, str]** | | [optional]
**map_number** | **dict[str, float]** | | [optional]
**map_integer** | **dict[str, int]** | | [optional]
**map_boolean** | **dict[str, bool]** | | [optional]
**map_array_integer** | **dict[str, list[int]]** | | [optional]
**map_array_anytype** | **dict[str, list[object]]** | | [optional]
**map_map_string** | **dict[str, dict[str, str]]** | | [optional]
**map_map_anytype** | **dict[str, dict[str, object]]** | | [optional]
**anytype_1** | **object** | | [optional]
**anytype_2** | **object** | | [optional]
**anytype_3** | **object** | | [optional]

View File

@@ -777,7 +777,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
param = {'key': 'param_example'} # dict(str, str) | request body
param = {'key': 'param_example'} # dict[str, str] | request body
try:
# test inline additionalProperties
@@ -790,7 +790,7 @@ with petstore_api.ApiClient() as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | [**dict(str, str)**](str.md)| request body |
**param** | [**dict[str, str]**](str.md)| request body |
### Return type

View File

@@ -4,10 +4,10 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_map_of_string** | **dict(str, dict(str, str))** | | [optional]
**map_of_enum_string** | **dict(str, str)** | | [optional]
**direct_map** | **dict(str, bool)** | | [optional]
**indirect_map** | **dict(str, bool)** | | [optional]
**map_map_of_string** | **dict[str, dict[str, str]]** | | [optional]
**map_of_enum_string** | **dict[str, str]** | | [optional]
**direct_map** | **dict[str, bool]** | | [optional]
**indirect_map** | **dict[str, bool]** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | **str** | | [optional]
**date_time** | **datetime** | | [optional]
**map** | [**dict(str, Animal)**](Animal.md) | | [optional]
**map** | [**dict[str, Animal]**](Animal.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -73,7 +73,7 @@ No authorization required
[[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)
# **get_inventory**
> dict(str, int) get_inventory()
> dict[str, int] get_inventory()
Returns pet inventories by status
@@ -123,7 +123,7 @@ This endpoint does not need any parameter.
### Return type
**dict(str, int)**
**dict[str, int]**
### Authorization

View File

@@ -1779,7 +1779,7 @@ class FakeApi(object):
>>> result = thread.get()
:param param: request body (required)
:type param: dict(str, str)
:type param: dict[str, str]
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -1808,7 +1808,7 @@ class FakeApi(object):
>>> result = thread.get()
:param param: request body (required)
:type param: dict(str, str)
:type param: dict[str, str]
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code

View File

@@ -190,7 +190,7 @@ class StoreApi(object):
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: dict(str, int)
:rtype: dict[str, int]
"""
kwargs['_return_http_data_only'] = True
return self.get_inventory_with_http_info(**kwargs) # noqa: E501
@@ -226,7 +226,7 @@ class StoreApi(object):
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(dict(str, int), status_code(int), headers(HTTPHeaderDict))
:rtype: tuple(dict[str, int], status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
@@ -274,7 +274,7 @@ class StoreApi(object):
auth_settings = ['api_key'] # noqa: E501
response_types_map = {
200: "dict(str, int)",
200: "dict[str, int]",
}
return self.api_client.call_api(

View File

@@ -302,8 +302,8 @@ class ApiClient(object):
return [self.__deserialize(sub_data, sub_kls)
for sub_data in data]
if klass.startswith('dict('):
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
if klass.startswith('dict['):
sub_kls = re.match(r'dict\[([^,]*), (.*)\]', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}

View File

@@ -36,14 +36,14 @@ class AdditionalPropertiesClass(object):
and the value is json key in definition.
"""
openapi_types = {
'map_string': 'dict(str, str)',
'map_number': 'dict(str, float)',
'map_integer': 'dict(str, int)',
'map_boolean': 'dict(str, bool)',
'map_array_integer': 'dict(str, list[int])',
'map_array_anytype': 'dict(str, list[object])',
'map_map_string': 'dict(str, dict(str, str))',
'map_map_anytype': 'dict(str, dict(str, object))',
'map_string': 'dict[str, str]',
'map_number': 'dict[str, float]',
'map_integer': 'dict[str, int]',
'map_boolean': 'dict[str, bool]',
'map_array_integer': 'dict[str, list[int]]',
'map_array_anytype': 'dict[str, list[object]]',
'map_map_string': 'dict[str, dict[str, str]]',
'map_map_anytype': 'dict[str, dict[str, object]]',
'anytype_1': 'object',
'anytype_2': 'object',
'anytype_3': 'object'
@@ -111,7 +111,7 @@ class AdditionalPropertiesClass(object):
:return: The map_string of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, str)
:rtype: dict[str, str]
"""
return self._map_string
@@ -121,7 +121,7 @@ class AdditionalPropertiesClass(object):
:param map_string: The map_string of this AdditionalPropertiesClass. # noqa: E501
:type map_string: dict(str, str)
:type map_string: dict[str, str]
"""
self._map_string = map_string
@@ -132,7 +132,7 @@ class AdditionalPropertiesClass(object):
:return: The map_number of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, float)
:rtype: dict[str, float]
"""
return self._map_number
@@ -142,7 +142,7 @@ class AdditionalPropertiesClass(object):
:param map_number: The map_number of this AdditionalPropertiesClass. # noqa: E501
:type map_number: dict(str, float)
:type map_number: dict[str, float]
"""
self._map_number = map_number
@@ -153,7 +153,7 @@ class AdditionalPropertiesClass(object):
:return: The map_integer of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, int)
:rtype: dict[str, int]
"""
return self._map_integer
@@ -163,7 +163,7 @@ class AdditionalPropertiesClass(object):
:param map_integer: The map_integer of this AdditionalPropertiesClass. # noqa: E501
:type map_integer: dict(str, int)
:type map_integer: dict[str, int]
"""
self._map_integer = map_integer
@@ -174,7 +174,7 @@ class AdditionalPropertiesClass(object):
:return: The map_boolean of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, bool)
:rtype: dict[str, bool]
"""
return self._map_boolean
@@ -184,7 +184,7 @@ class AdditionalPropertiesClass(object):
:param map_boolean: The map_boolean of this AdditionalPropertiesClass. # noqa: E501
:type map_boolean: dict(str, bool)
:type map_boolean: dict[str, bool]
"""
self._map_boolean = map_boolean
@@ -195,7 +195,7 @@ class AdditionalPropertiesClass(object):
:return: The map_array_integer of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, list[int])
:rtype: dict[str, list[int]]
"""
return self._map_array_integer
@@ -205,7 +205,7 @@ class AdditionalPropertiesClass(object):
:param map_array_integer: The map_array_integer of this AdditionalPropertiesClass. # noqa: E501
:type map_array_integer: dict(str, list[int])
:type map_array_integer: dict[str, list[int]]
"""
self._map_array_integer = map_array_integer
@@ -216,7 +216,7 @@ class AdditionalPropertiesClass(object):
:return: The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, list[object])
:rtype: dict[str, list[object]]
"""
return self._map_array_anytype
@@ -226,7 +226,7 @@ class AdditionalPropertiesClass(object):
:param map_array_anytype: The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
:type map_array_anytype: dict(str, list[object])
:type map_array_anytype: dict[str, list[object]]
"""
self._map_array_anytype = map_array_anytype
@@ -237,7 +237,7 @@ class AdditionalPropertiesClass(object):
:return: The map_map_string of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, dict(str, str))
:rtype: dict[str, dict[str, str]]
"""
return self._map_map_string
@@ -247,7 +247,7 @@ class AdditionalPropertiesClass(object):
:param map_map_string: The map_map_string of this AdditionalPropertiesClass. # noqa: E501
:type map_map_string: dict(str, dict(str, str))
:type map_map_string: dict[str, dict[str, str]]
"""
self._map_map_string = map_map_string
@@ -258,7 +258,7 @@ class AdditionalPropertiesClass(object):
:return: The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, dict(str, object))
:rtype: dict[str, dict[str, object]]
"""
return self._map_map_anytype
@@ -268,7 +268,7 @@ class AdditionalPropertiesClass(object):
:param map_map_anytype: The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
:type map_map_anytype: dict(str, dict(str, object))
:type map_map_anytype: dict[str, dict[str, object]]
"""
self._map_map_anytype = map_map_anytype

View File

@@ -36,10 +36,10 @@ class MapTest(object):
and the value is json key in definition.
"""
openapi_types = {
'map_map_of_string': 'dict(str, dict(str, str))',
'map_of_enum_string': 'dict(str, str)',
'direct_map': 'dict(str, bool)',
'indirect_map': 'dict(str, bool)'
'map_map_of_string': 'dict[str, dict[str, str]]',
'map_of_enum_string': 'dict[str, str]',
'direct_map': 'dict[str, bool]',
'indirect_map': 'dict[str, bool]'
}
attribute_map = {
@@ -76,7 +76,7 @@ class MapTest(object):
:return: The map_map_of_string of this MapTest. # noqa: E501
:rtype: dict(str, dict(str, str))
:rtype: dict[str, dict[str, str]]
"""
return self._map_map_of_string
@@ -86,7 +86,7 @@ class MapTest(object):
:param map_map_of_string: The map_map_of_string of this MapTest. # noqa: E501
:type map_map_of_string: dict(str, dict(str, str))
:type map_map_of_string: dict[str, dict[str, str]]
"""
self._map_map_of_string = map_map_of_string
@@ -97,7 +97,7 @@ class MapTest(object):
:return: The map_of_enum_string of this MapTest. # noqa: E501
:rtype: dict(str, str)
:rtype: dict[str, str]
"""
return self._map_of_enum_string
@@ -107,7 +107,7 @@ class MapTest(object):
:param map_of_enum_string: The map_of_enum_string of this MapTest. # noqa: E501
:type map_of_enum_string: dict(str, str)
:type map_of_enum_string: dict[str, str]
"""
allowed_values = ["UPPER", "lower"] # noqa: E501
if (self.local_vars_configuration.client_side_validation and
@@ -126,7 +126,7 @@ class MapTest(object):
:return: The direct_map of this MapTest. # noqa: E501
:rtype: dict(str, bool)
:rtype: dict[str, bool]
"""
return self._direct_map
@@ -136,7 +136,7 @@ class MapTest(object):
:param direct_map: The direct_map of this MapTest. # noqa: E501
:type direct_map: dict(str, bool)
:type direct_map: dict[str, bool]
"""
self._direct_map = direct_map
@@ -147,7 +147,7 @@ class MapTest(object):
:return: The indirect_map of this MapTest. # noqa: E501
:rtype: dict(str, bool)
:rtype: dict[str, bool]
"""
return self._indirect_map
@@ -157,7 +157,7 @@ class MapTest(object):
:param indirect_map: The indirect_map of this MapTest. # noqa: E501
:type indirect_map: dict(str, bool)
:type indirect_map: dict[str, bool]
"""
self._indirect_map = indirect_map

View File

@@ -38,7 +38,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(object):
openapi_types = {
'uuid': 'str',
'date_time': 'datetime',
'map': 'dict(str, Animal)'
'map': 'dict[str, Animal]'
}
attribute_map = {
@@ -113,7 +113,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(object):
:return: The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
:rtype: dict(str, Animal)
:rtype: dict[str, Animal]
"""
return self._map
@@ -123,7 +123,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(object):
:param map: The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
:type map: dict(str, Animal)
:type map: dict[str, Animal]
"""
self._map = map