[Python] Adds allOf/oneOf/anyOf composed models (#4446)

* Adds composed model support for allOf oneOf anyOf

* Moves discriminator into discriminator() class method, adds test_deserialize_lizard, adds setting discriminator using allOf schema
This commit is contained in:
Justin Black
2019-12-14 18:18:41 -08:00
committed by Jim Schubert
parent 02f5cb1a65
commit 789f1a06f0
196 changed files with 6700 additions and 9551 deletions

View File

@@ -34,17 +34,17 @@ this route creates an XmlItem
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body
# example passing only required values which don't have defaults set
try:
# creates an XmlItem
api_instance.create_xml_item(xml_item)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
```
@@ -52,7 +52,7 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**xml_item** | [**XmlItem**](XmlItem.md)| XmlItem Body |
**xml_item** | [**xml_item.XmlItem**](XmlItem.md)| XmlItem Body |
### Return type
@@ -87,17 +87,18 @@ Test serialization of outer boolean types
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -128,7 +129,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)
# **fake_outer_composite_serialize**
> OuterComposite fake_outer_composite_serialize()
> outer_composite.OuterComposite fake_outer_composite_serialize()
@@ -140,17 +141,18 @@ Test serialization of object with outer number type
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -158,11 +160,11 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
**body** | [**outer_composite.OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
### Return type
[**OuterComposite**](OuterComposite.md)
[**outer_composite.OuterComposite**](OuterComposite.md)
### Authorization
@@ -181,7 +183,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)
# **fake_outer_enum_serialize**
> OuterEnum fake_outer_enum_serialize()
> outer_enum.OuterEnum fake_outer_enum_serialize()
@@ -193,17 +195,18 @@ Test serialization of outer enum
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = OuterEnum("placed") # OuterEnum | Input enum as post body (optional)
body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_enum_serialize(body=body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_enum_serialize: %s\n" % e)
```
@@ -211,11 +214,11 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**OuterEnum**](str.md)| Input enum as post body | [optional]
**body** | [**outer_enum.OuterEnum**](OuterEnum.md)| Input enum as post body | [optional]
### Return type
[**OuterEnum**](OuterEnum.md)
[**outer_enum.OuterEnum**](OuterEnum.md)
### Authorization
@@ -234,7 +237,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)
# **fake_outer_number_serialize**
> OuterNumber fake_outer_number_serialize()
> outer_number.OuterNumber fake_outer_number_serialize()
@@ -246,17 +249,18 @@ Test serialization of outer number types
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = OuterNumber(3.4) # OuterNumber | Input number as post body (optional)
body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -264,11 +268,11 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**OuterNumber**](float.md)| Input number as post body | [optional]
**body** | [**outer_number.OuterNumber**](OuterNumber.md)| Input number as post body | [optional]
### Return type
[**OuterNumber**](OuterNumber.md)
[**outer_number.OuterNumber**](OuterNumber.md)
### Authorization
@@ -299,17 +303,18 @@ Test serialization of outer string types
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -352,16 +357,16 @@ For this test, the body for this request much reference a schema named `File`.
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_file_schema(body)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -369,7 +374,7 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
**body** | [**file_schema_test_class.FileSchemaTestClass**](FileSchemaTestClass.md)| |
### Return type
@@ -402,17 +407,17 @@ No authorization required
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
body = petstore_api.User() # User |
body = petstore_api.User() # user.User |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_query_params(query, body)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -421,7 +426,7 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**query** | **str**| |
**body** | [**User**](User.md)| |
**body** | [**user.User**](User.md)| |
### Return type
@@ -444,7 +449,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)
# **test_client_model**
> Client test_client_model(body)
> client.Client test_client_model(body)
To test \"client\" model
@@ -456,18 +461,18 @@ To test \"client\" model
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # Client | client model
body = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -475,11 +480,11 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
**body** | [**client.Client**](Client.md)| client model |
### Return type
[**Client**](Client.md)
[**client.Client**](Client.md)
### Authorization
@@ -510,20 +515,15 @@ This route has required values with enums of 1
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query_integer = 3 # int | (default to 3)
query_string = 'brillig' # str | (default to 'brillig')
path_string = 'hello' # str | (default to 'hello')
path_integer = 34 # int | (default to 34)
header_number = 1.234 # float | (default to 1.234)
# example passing only required values which don't have defaults set
try:
api_instance.test_endpoint_enums_length_one(query_integer, query_string, path_string, path_integer, header_number)
except ApiException as e:
api_instance.test_endpoint_enums_length_one()
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_enums_length_one: %s\n" % e)
```
@@ -571,7 +571,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
configuration = petstore_api.Configuration()
# Configure HTTP basic authorization: http_basic_test
@@ -597,10 +596,19 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
# example passing only required values which don't have defaults set
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -657,24 +665,25 @@ To test enum parameters
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) (default to '$')
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
# example passing only required values which don't have defaults set
# and optional values
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -682,13 +691,13 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_header_string_array** | [**[str]**](str.md)| Header parameter enum test (string array) | [optional]
**enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional]
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_query_string_array** | [**[str]**](str.md)| Query parameter enum test (string array) | [optional]
**enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional]
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
**enum_form_string_array** | [**[str]**](str.md)| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
### Return type
@@ -725,7 +734,6 @@ Fake endpoint to test group parameters (optional)
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
@@ -737,10 +745,19 @@ string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
# example passing only required values which don't have defaults set
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -786,17 +803,17 @@ test inline additionalProperties
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = {'key': 'param_example'} # {str: (str,)} | request body
# example passing only required values which don't have defaults set
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(param)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -804,7 +821,7 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | [**{str: (str,)}**](str.md)| request body |
**param** | **{str: (str,)}**| request body |
### Return type
@@ -837,7 +854,6 @@ test json serialization of form data
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
@@ -845,10 +861,11 @@ api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
# example passing only required values which don't have defaults set
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```