forked from loafle/openapi-generator-original
better additional properties support
This commit is contained in:
@@ -153,6 +153,23 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
*/
|
||||
public boolean isAdditionalPropertiesTrue;
|
||||
|
||||
/**
|
||||
* True if additional properties is set to any type
|
||||
*/
|
||||
public boolean isAdditionalPropertiesAnyType;
|
||||
|
||||
/**
|
||||
* True if additional properties is set to free form object
|
||||
*/
|
||||
public boolean isAdditionalPropertiesFreeFormObject;
|
||||
|
||||
/**
|
||||
* True if additional properties is enabled (boolean or any type)
|
||||
*/
|
||||
public boolean isAdditionalPropertiesEnabled() {
|
||||
return isAdditionalPropertiesTrue || isAdditionalPropertiesAnyType || isAdditionalPropertiesFreeFormObject;
|
||||
}
|
||||
|
||||
private Integer maxProperties;
|
||||
private Integer minProperties;
|
||||
private boolean uniqueItems;
|
||||
@@ -1088,6 +1105,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
Objects.equals(externalDocumentation, that.externalDocumentation) &&
|
||||
Objects.equals(vendorExtensions, that.vendorExtensions) &&
|
||||
Objects.equals(additionalPropertiesType, that.additionalPropertiesType) &&
|
||||
Objects.equals(isAdditionalPropertiesAnyType, that.isAdditionalPropertiesAnyType) &&
|
||||
Objects.equals(isAdditionalPropertiesFreeFormObject, that.isAdditionalPropertiesFreeFormObject) &&
|
||||
Objects.equals(isAdditionalPropertiesTrue, that.isAdditionalPropertiesTrue) &&
|
||||
Objects.equals(getMaxProperties(), that.getMaxProperties()) &&
|
||||
Objects.equals(getMinProperties(), that.getMinProperties()) &&
|
||||
Objects.equals(getMaxItems(), that.getMaxItems()) &&
|
||||
@@ -1121,7 +1141,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
|
||||
isAnyType, getComposedSchemas(), hasMultipleTypes, isDecimal, isUuid, requiredVarsMap, ref,
|
||||
uniqueItemsBoolean, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
|
||||
format, dependentRequired, contains);
|
||||
format, dependentRequired, contains, isAdditionalPropertiesTrue, isAdditionalPropertiesFreeFormObject,
|
||||
isAdditionalPropertiesFreeFormObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1227,6 +1248,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
sb.append(", format=").append(format);
|
||||
sb.append(", dependentRequired=").append(dependentRequired);
|
||||
sb.append(", contains=").append(contains);
|
||||
sb.append(", isAdditionalPropertiesAnyType=").append(isAdditionalPropertiesAnyType);
|
||||
sb.append(", isAdditionalPropertiesFreeFormObject=").append(isAdditionalPropertiesFreeFormObject);
|
||||
sb.append(", isAdditionalPropertiesTrue=").append(isAdditionalPropertiesTrue);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -3167,13 +3167,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// if we are trying to set additionalProperties on an empty schema stop recursing
|
||||
return;
|
||||
}
|
||||
|
||||
boolean additionalPropertiesIsAnyType = false;
|
||||
boolean isAdditionalPropertiesTrue = false;
|
||||
boolean isAdditionalPropertiesFreeFormObject = false;
|
||||
|
||||
CodegenModel m = null;
|
||||
if (property instanceof CodegenModel) {
|
||||
m = (CodegenModel) property;
|
||||
}
|
||||
CodegenProperty addPropProp = null;
|
||||
boolean isAdditionalPropertiesTrue = false;
|
||||
if (schema.getAdditionalProperties() == null) {
|
||||
if (!disallowAdditionalPropertiesIfNotPresent) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
@@ -3184,19 +3187,27 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
addPropProp = fromProperty(getAdditionalPropertiesName(), new Schema(), false);
|
||||
// TODO revise below as it should be true only if it's any type, not boolean
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
} else {
|
||||
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
|
||||
if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
|
||||
if (ModelUtils.isFreeFormObject((Schema) schema.getAdditionalProperties())) {
|
||||
isAdditionalPropertiesFreeFormObject = true;
|
||||
}
|
||||
}
|
||||
if (additionalPropertiesIsAnyType) {
|
||||
property.setAdditionalPropertiesIsAnyType(true);
|
||||
}
|
||||
if (m != null && isAdditionalPropertiesTrue) {
|
||||
m.isAdditionalPropertiesTrue = true;
|
||||
if (m != null) {
|
||||
m.isAdditionalPropertiesTrue = isAdditionalPropertiesTrue;
|
||||
m.isAdditionalPropertiesAnyType = additionalPropertiesIsAnyType;
|
||||
m.isAdditionalPropertiesFreeFormObject = isAdditionalPropertiesFreeFormObject;
|
||||
}
|
||||
if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) {
|
||||
return;
|
||||
|
||||
@@ -22,9 +22,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{#vars}}
|
||||
{{name}}: {{{vendorExtensions.x-py-typing}}}
|
||||
{{/vars}}
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
{{#isAdditionalPropertiesEnabled}}
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{/isAdditionalPropertiesEnabled}}
|
||||
__properties = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}]
|
||||
{{#vars}}
|
||||
{{#vendorExtensions.x-regex}}
|
||||
@@ -130,9 +130,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{#vendorExtensions.x-py-readonly}}
|
||||
"{{{.}}}",
|
||||
{{/vendorExtensions.x-py-readonly}}
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
{{#isAdditionalPropertiesEnabled}}
|
||||
"additional_properties"
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{/isAdditionalPropertiesEnabled}}
|
||||
},
|
||||
exclude_none=True)
|
||||
{{#allVars}}
|
||||
@@ -202,13 +202,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{/allVars}}
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
{{#isAdditionalPropertiesEnabled}}
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{/isAdditionalPropertiesEnabled}}
|
||||
{{#allVars}}
|
||||
{{#isNullable}}
|
||||
# set to None if {{{name}}} (nullable) is None
|
||||
@@ -244,13 +244,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
return {{{classname}}}.parse_obj(obj)
|
||||
|
||||
{{#disallowAdditionalPropertiesIfNotPresent}}
|
||||
{{^isAdditionalPropertiesTrue}}
|
||||
{{^isAdditionalPropertiesEnabled}}
|
||||
# raise errors for additional fields in the input
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj)
|
||||
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{/isAdditionalPropertiesEnabled}}
|
||||
{{/disallowAdditionalPropertiesIfNotPresent}}
|
||||
_obj = {{{classname}}}.parse_obj({
|
||||
{{#allVars}}
|
||||
@@ -348,13 +348,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{/isContainer}}
|
||||
{{/allVars}}
|
||||
})
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
{{#isAdditionalPropertiesEnabled}}
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
{{/isAdditionalPropertiesEnabled}}
|
||||
return _obj
|
||||
{{/hasChildren}}
|
||||
|
||||
@@ -363,4 +363,4 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
{{{.}}}
|
||||
{{/vendorExtensions.x-py-postponed-model-imports}}
|
||||
{{classname}}.update_forward_refs()
|
||||
{{/vendorExtensions.x-py-postponed-model-imports.size}}
|
||||
{{/vendorExtensions.x-py-postponed-model-imports.size}}
|
||||
|
||||
@@ -2246,3 +2246,16 @@ components:
|
||||
description: Property
|
||||
type: boolean
|
||||
default: false
|
||||
AdditionalPropertieObject:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
additionalProperties:
|
||||
type: object
|
||||
AdditionalPropertieAnyType:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
.gitlab-ci.yml
|
||||
.travis.yml
|
||||
README.md
|
||||
docs/AdditionalPropertieAnyType.md
|
||||
docs/AdditionalPropertieObject.md
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/AllOfWithSingleRef.md
|
||||
docs/Animal.md
|
||||
@@ -97,6 +99,8 @@ petstore_api/api_response.py
|
||||
petstore_api/configuration.py
|
||||
petstore_api/exceptions.py
|
||||
petstore_api/models/__init__.py
|
||||
petstore_api/models/additional_propertie_any_type.py
|
||||
petstore_api/models/additional_propertie_object.py
|
||||
petstore_api/models/additional_properties_class.py
|
||||
petstore_api/models/all_of_with_single_ref.py
|
||||
petstore_api/models/animal.py
|
||||
|
||||
@@ -132,6 +132,8 @@ Class | Method | HTTP request | Description
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertieAnyType](docs/AdditionalPropertieAnyType.md)
|
||||
- [AdditionalPropertieObject](docs/AdditionalPropertieObject.md)
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# AdditionalPropertieAnyType
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of AdditionalPropertieAnyType from a JSON string
|
||||
additional_propertie_any_type_instance = AdditionalPropertieAnyType.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print AdditionalPropertieAnyType.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
additional_propertie_any_type_dict = additional_propertie_any_type_instance.to_dict()
|
||||
# create an instance of AdditionalPropertieAnyType from a dict
|
||||
additional_propertie_any_type_form_dict = additional_propertie_any_type.from_dict(additional_propertie_any_type_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# AdditionalPropertieObject
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of AdditionalPropertieObject from a JSON string
|
||||
additional_propertie_object_instance = AdditionalPropertieObject.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print AdditionalPropertieObject.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
additional_propertie_object_dict = additional_propertie_object_instance.to_dict()
|
||||
# create an instance of AdditionalPropertieObject from a dict
|
||||
additional_propertie_object_form_dict = additional_propertie_object.from_dict(additional_propertie_object_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ from petstore_api.exceptions import ApiException
|
||||
from petstore_api.signing import HttpSigningConfiguration
|
||||
|
||||
# import models into sdk package
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
|
||||
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
|
||||
# import models into model package
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
|
||||
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
class AdditionalPropertieAnyType(BaseModel):
|
||||
"""
|
||||
AdditionalPropertieAnyType
|
||||
"""
|
||||
name: Optional[StrictStr] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> AdditionalPropertieAnyType:
|
||||
"""Create an instance of AdditionalPropertieAnyType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> AdditionalPropertieAnyType:
|
||||
"""Create an instance of AdditionalPropertieAnyType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return AdditionalPropertieAnyType.parse_obj(obj)
|
||||
|
||||
_obj = AdditionalPropertieAnyType.parse_obj({
|
||||
"name": obj.get("name")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
class AdditionalPropertieObject(BaseModel):
|
||||
"""
|
||||
AdditionalPropertieObject
|
||||
"""
|
||||
name: Optional[StrictStr] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> AdditionalPropertieObject:
|
||||
"""Create an instance of AdditionalPropertieObject from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> AdditionalPropertieObject:
|
||||
"""Create an instance of AdditionalPropertieObject from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return AdditionalPropertieObject.parse_obj(obj)
|
||||
|
||||
_obj = AdditionalPropertieObject.parse_obj({
|
||||
"name": obj.get("name")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class NullableClass(BaseModel):
|
||||
object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"]
|
||||
|
||||
class Config:
|
||||
@@ -62,8 +63,14 @@ class NullableClass(BaseModel):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
# set to None if required_integer_prop (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__:
|
||||
@@ -145,6 +152,11 @@ class NullableClass(BaseModel):
|
||||
"object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"),
|
||||
"object_items_nullable": obj.get("object_items_nullable")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestAdditionalPropertieAnyType(unittest.TestCase):
|
||||
"""AdditionalPropertieAnyType unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test AdditionalPropertieAnyType
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `AdditionalPropertieAnyType`
|
||||
"""
|
||||
model = petstore_api.models.additional_propertie_any_type.AdditionalPropertieAnyType() # noqa: E501
|
||||
if include_optional :
|
||||
return AdditionalPropertieAnyType(
|
||||
name = ''
|
||||
)
|
||||
else :
|
||||
return AdditionalPropertieAnyType(
|
||||
)
|
||||
"""
|
||||
|
||||
def testAdditionalPropertieAnyType(self):
|
||||
"""Test AdditionalPropertieAnyType"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestAdditionalPropertieObject(unittest.TestCase):
|
||||
"""AdditionalPropertieObject unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test AdditionalPropertieObject
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `AdditionalPropertieObject`
|
||||
"""
|
||||
model = petstore_api.models.additional_propertie_object.AdditionalPropertieObject() # noqa: E501
|
||||
if include_optional :
|
||||
return AdditionalPropertieObject(
|
||||
name = ''
|
||||
)
|
||||
else :
|
||||
return AdditionalPropertieObject(
|
||||
)
|
||||
"""
|
||||
|
||||
def testAdditionalPropertieObject(self):
|
||||
"""Test AdditionalPropertieObject"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -3,6 +3,8 @@
|
||||
.gitlab-ci.yml
|
||||
.travis.yml
|
||||
README.md
|
||||
docs/AdditionalPropertieAnyType.md
|
||||
docs/AdditionalPropertieObject.md
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/AllOfWithSingleRef.md
|
||||
docs/Animal.md
|
||||
@@ -97,6 +99,8 @@ petstore_api/api_response.py
|
||||
petstore_api/configuration.py
|
||||
petstore_api/exceptions.py
|
||||
petstore_api/models/__init__.py
|
||||
petstore_api/models/additional_propertie_any_type.py
|
||||
petstore_api/models/additional_propertie_object.py
|
||||
petstore_api/models/additional_properties_class.py
|
||||
petstore_api/models/all_of_with_single_ref.py
|
||||
petstore_api/models/animal.py
|
||||
|
||||
@@ -132,6 +132,8 @@ Class | Method | HTTP request | Description
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertieAnyType](docs/AdditionalPropertieAnyType.md)
|
||||
- [AdditionalPropertieObject](docs/AdditionalPropertieObject.md)
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# AdditionalPropertieAnyType
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of AdditionalPropertieAnyType from a JSON string
|
||||
additional_propertie_any_type_instance = AdditionalPropertieAnyType.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print AdditionalPropertieAnyType.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
additional_propertie_any_type_dict = additional_propertie_any_type_instance.to_dict()
|
||||
# create an instance of AdditionalPropertieAnyType from a dict
|
||||
additional_propertie_any_type_form_dict = additional_propertie_any_type.from_dict(additional_propertie_any_type_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# AdditionalPropertieObject
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of AdditionalPropertieObject from a JSON string
|
||||
additional_propertie_object_instance = AdditionalPropertieObject.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print AdditionalPropertieObject.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
additional_propertie_object_dict = additional_propertie_object_instance.to_dict()
|
||||
# create an instance of AdditionalPropertieObject from a dict
|
||||
additional_propertie_object_form_dict = additional_propertie_object.from_dict(additional_propertie_object_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# AdditionalPropertiesAnyType
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of AdditionalPropertiesAnyType from a JSON string
|
||||
additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print AdditionalPropertiesAnyType.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict()
|
||||
# create an instance of AdditionalPropertiesAnyType from a dict
|
||||
additional_properties_any_type_form_dict = additional_properties_any_type.from_dict(additional_properties_any_type_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ from petstore_api.exceptions import ApiException
|
||||
from petstore_api.signing import HttpSigningConfiguration
|
||||
|
||||
# import models into sdk package
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
|
||||
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
|
||||
# import models into model package
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
|
||||
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
|
||||
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
class AdditionalPropertieAnyType(BaseModel):
|
||||
"""
|
||||
AdditionalPropertieAnyType
|
||||
"""
|
||||
name: Optional[StrictStr] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> AdditionalPropertieAnyType:
|
||||
"""Create an instance of AdditionalPropertieAnyType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> AdditionalPropertieAnyType:
|
||||
"""Create an instance of AdditionalPropertieAnyType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return AdditionalPropertieAnyType.parse_obj(obj)
|
||||
|
||||
_obj = AdditionalPropertieAnyType.parse_obj({
|
||||
"name": obj.get("name")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
class AdditionalPropertieObject(BaseModel):
|
||||
"""
|
||||
AdditionalPropertieObject
|
||||
"""
|
||||
name: Optional[StrictStr] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> AdditionalPropertieObject:
|
||||
"""Create an instance of AdditionalPropertieObject from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> AdditionalPropertieObject:
|
||||
"""Create an instance of AdditionalPropertieObject from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return AdditionalPropertieObject.parse_obj(obj)
|
||||
|
||||
_obj = AdditionalPropertieObject.parse_obj({
|
||||
"name": obj.get("name")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
class AdditionalPropertiesAnyType(BaseModel):
|
||||
"""
|
||||
AdditionalPropertiesAnyType
|
||||
"""
|
||||
name: Optional[StrictStr] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType:
|
||||
"""Create an instance of AdditionalPropertiesAnyType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType:
|
||||
"""Create an instance of AdditionalPropertiesAnyType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return AdditionalPropertiesAnyType.parse_obj(obj)
|
||||
|
||||
_obj = AdditionalPropertiesAnyType.parse_obj({
|
||||
"name": obj.get("name")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class NullableClass(BaseModel):
|
||||
object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"]
|
||||
|
||||
class Config:
|
||||
@@ -62,8 +63,14 @@ class NullableClass(BaseModel):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
# set to None if required_integer_prop (nullable) is None
|
||||
# and __fields_set__ contains the field
|
||||
if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__:
|
||||
@@ -145,6 +152,11 @@ class NullableClass(BaseModel):
|
||||
"object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"),
|
||||
"object_items_nullable": obj.get("object_items_nullable")
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestAdditionalPropertieAnyType(unittest.TestCase):
|
||||
"""AdditionalPropertieAnyType unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test AdditionalPropertieAnyType
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `AdditionalPropertieAnyType`
|
||||
"""
|
||||
model = petstore_api.models.additional_propertie_any_type.AdditionalPropertieAnyType() # noqa: E501
|
||||
if include_optional :
|
||||
return AdditionalPropertieAnyType(
|
||||
name = ''
|
||||
)
|
||||
else :
|
||||
return AdditionalPropertieAnyType(
|
||||
)
|
||||
"""
|
||||
|
||||
def testAdditionalPropertieAnyType(self):
|
||||
"""Test AdditionalPropertieAnyType"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestAdditionalPropertieObject(unittest.TestCase):
|
||||
"""AdditionalPropertieObject unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test AdditionalPropertieObject
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `AdditionalPropertieObject`
|
||||
"""
|
||||
model = petstore_api.models.additional_propertie_object.AdditionalPropertieObject() # noqa: E501
|
||||
if include_optional :
|
||||
return AdditionalPropertieObject(
|
||||
name = ''
|
||||
)
|
||||
else :
|
||||
return AdditionalPropertieObject(
|
||||
)
|
||||
"""
|
||||
|
||||
def testAdditionalPropertieObject(self):
|
||||
"""Test AdditionalPropertieObject"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
# 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 OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestAdditionalPropertiesAnyType(unittest.TestCase):
|
||||
"""AdditionalPropertiesAnyType unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test AdditionalPropertiesAnyType
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `AdditionalPropertiesAnyType`
|
||||
"""
|
||||
model = petstore_api.models.additional_properties_any_type.AdditionalPropertiesAnyType() # noqa: E501
|
||||
if include_optional :
|
||||
return AdditionalPropertiesAnyType(
|
||||
name = ''
|
||||
)
|
||||
else :
|
||||
return AdditionalPropertiesAnyType(
|
||||
)
|
||||
"""
|
||||
|
||||
def testAdditionalPropertiesAnyType(self):
|
||||
"""Test AdditionalPropertiesAnyType"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -513,3 +513,13 @@ class ModelTests(unittest.TestCase):
|
||||
a = petstore_api.FirstRef.from_dict({})
|
||||
self.assertEqual(a.to_json(), "{}")
|
||||
|
||||
def test_additional_properties(self):
|
||||
a1 = petstore_api.AdditionalPropertieAnyType()
|
||||
a1.additional_properties = { "abc": 123 }
|
||||
self.assertEqual(a1.to_dict(), {"abc": 123})
|
||||
self.assertEqual(a1.to_json(), "{\"abc\": 123}")
|
||||
|
||||
a2 = petstore_api.AdditionalPropertieObject()
|
||||
a2.additional_properties = { "efg": 45.6 }
|
||||
self.assertEqual(a2.to_dict(), {"efg": 45.6})
|
||||
self.assertEqual(a2.to_json(), "{\"efg\": 45.6}")
|
||||
|
||||
Reference in New Issue
Block a user