forked from loafle/openapi-generator-original
Adds not to CodegenComposedSchemas and uses it in python-exp (#12146)
Updates docs
This commit is contained in:
@@ -8,6 +8,7 @@ docs/Address.md
|
||||
docs/Animal.md
|
||||
docs/AnimalFarm.md
|
||||
docs/AnotherFakeApi.md
|
||||
docs/AnyTypeNotString.md
|
||||
docs/ApiResponse.md
|
||||
docs/Apple.md
|
||||
docs/AppleReq.md
|
||||
@@ -150,6 +151,7 @@ petstore_api/model/additional_properties_with_array_of_enums.py
|
||||
petstore_api/model/address.py
|
||||
petstore_api/model/animal.py
|
||||
petstore_api/model/animal_farm.py
|
||||
petstore_api/model/any_type_not_string.py
|
||||
petstore_api/model/api_response.py
|
||||
petstore_api/model/apple.py
|
||||
petstore_api/model/apple_req.py
|
||||
|
||||
@@ -144,6 +144,7 @@ Class | Method | HTTP request | Description
|
||||
- [Address](docs/Address.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [AnyTypeNotString](docs/AnyTypeNotString.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [Apple](docs/Apple.md)
|
||||
- [AppleReq](docs/AppleReq.md)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# AnyTypeNotString
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [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)
|
||||
|
||||
@@ -411,6 +411,7 @@ with petstore_api.ApiClient(configuration) as api_client:
|
||||
object_with_no_declared_props=dict(),
|
||||
object_with_no_declared_props_nullable=dict(),
|
||||
any_type_prop=None,
|
||||
any_type_except_null_prop=None,
|
||||
any_type_prop_nullable=None,
|
||||
)
|
||||
try:
|
||||
|
||||
@@ -14,6 +14,7 @@ Name | Type | Description | Notes
|
||||
**objectWithNoDeclaredProps** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional]
|
||||
**objectWithNoDeclaredPropsNullable** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional]
|
||||
**anyTypeProp** | **bool, date, datetime, dict, float, int, list, str, none_type** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional]
|
||||
**anyTypeExceptNullProp** | **object** | any type except 'null' Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. | [optional]
|
||||
**anyTypePropNullable** | **bool, date, datetime, dict, float, int, list, str, none_type** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ with petstore_api.ApiClient(configuration) as api_client:
|
||||
object_with_no_declared_props=dict(),
|
||||
object_with_no_declared_props_nullable=dict(),
|
||||
any_type_prop=None,
|
||||
any_type_except_null_prop=None,
|
||||
any_type_prop_nullable=None,
|
||||
)
|
||||
try:
|
||||
@@ -139,6 +140,7 @@ with petstore_api.ApiClient(configuration) as api_client:
|
||||
object_with_no_declared_props=dict(),
|
||||
object_with_no_declared_props_nullable=dict(),
|
||||
any_type_prop=None,
|
||||
any_type_except_null_prop=None,
|
||||
any_type_prop_nullable=None,
|
||||
)
|
||||
]
|
||||
@@ -228,6 +230,7 @@ with petstore_api.ApiClient(configuration) as api_client:
|
||||
object_with_no_declared_props=dict(),
|
||||
object_with_no_declared_props_nullable=dict(),
|
||||
any_type_prop=None,
|
||||
any_type_except_null_prop=None,
|
||||
any_type_prop_nullable=None,
|
||||
)
|
||||
]
|
||||
@@ -708,6 +711,7 @@ with petstore_api.ApiClient(configuration) as api_client:
|
||||
object_with_no_declared_props=dict(),
|
||||
object_with_no_declared_props_nullable=dict(),
|
||||
any_type_prop=None,
|
||||
any_type_except_null_prop=None,
|
||||
any_type_prop_nullable=None,
|
||||
)
|
||||
try:
|
||||
|
||||
@@ -99,6 +99,8 @@ class CompositionAtRootSchema(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
@@ -151,6 +153,8 @@ class CompositionInPropertySchema(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
@@ -246,6 +250,8 @@ class SchemaForRequestBodyApplicationJson(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
@@ -298,6 +304,8 @@ class SchemaForRequestBodyMultipartFormData(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
@@ -373,6 +381,8 @@ class SchemaFor200ResponseBodyApplicationJson(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
@@ -425,6 +435,8 @@ class SchemaFor200ResponseBodyMultipartFormData(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
# 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 re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing # noqa: F401
|
||||
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
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,
|
||||
UUIDSchema,
|
||||
DateSchema,
|
||||
DateTimeSchema,
|
||||
DecimalSchema,
|
||||
BoolSchema,
|
||||
BinarySchema,
|
||||
NoneSchema,
|
||||
none_type,
|
||||
Configuration,
|
||||
Unset,
|
||||
unset,
|
||||
ComposedBase,
|
||||
ListBase,
|
||||
DictBase,
|
||||
NoneBase,
|
||||
StrBase,
|
||||
IntBase,
|
||||
Int32Base,
|
||||
Int64Base,
|
||||
Float32Base,
|
||||
Float64Base,
|
||||
NumberBase,
|
||||
UUIDBase,
|
||||
DateBase,
|
||||
DateTimeBase,
|
||||
BoolBase,
|
||||
BinaryBase,
|
||||
Schema,
|
||||
_SchemaValidator,
|
||||
_SchemaTypeChecker,
|
||||
_SchemaEnumMaker
|
||||
)
|
||||
|
||||
|
||||
class AnyTypeNotString(
|
||||
ComposedSchema
|
||||
):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def _composed_schemas(cls):
|
||||
# we need this here to make our import statements work
|
||||
# we must store _composed_schemas in here so the code is only run
|
||||
# when we invoke this method. If we kept this at the class
|
||||
# level we would get an error because the class level
|
||||
# code would be run when this module is imported, and these composed
|
||||
# classes don't exist yet because their module has not finished
|
||||
# loading
|
||||
NotSchema = StrSchema
|
||||
return {
|
||||
'allOf': [
|
||||
],
|
||||
'oneOf': [
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
NotSchema
|
||||
}
|
||||
|
||||
def __new__(
|
||||
cls,
|
||||
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
|
||||
_configuration: typing.Optional[Configuration] = None,
|
||||
**kwargs: typing.Type[Schema],
|
||||
) -> 'AnyTypeNotString':
|
||||
return super().__new__(
|
||||
cls,
|
||||
*args,
|
||||
_configuration=_configuration,
|
||||
**kwargs,
|
||||
)
|
||||
@@ -93,6 +93,8 @@ class Cat(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class ChildCat(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class ComplexQuadrilateral(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -128,6 +128,8 @@ class ComposedAnyOfDifferentTypesNoValidations(
|
||||
anyOf_14,
|
||||
anyOf_15,
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class ComposedBool(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class ComposedNone(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class ComposedNumber(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class ComposedObject(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -146,6 +146,8 @@ class ComposedOneOfDifferentTypes(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class ComposedString(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -106,6 +106,8 @@ class CompositionInProperty(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class Dog(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class EquilateralTriangle(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class Fruit(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -95,6 +95,8 @@ class FruitReq(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -94,6 +94,8 @@ class GmFruit(
|
||||
Apple,
|
||||
Banana,
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class IsoscelesTriangle(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -105,6 +105,8 @@ class Mammal(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -97,6 +97,8 @@ class NullableShape(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -106,6 +106,8 @@ class ObjectWithInlineCompositionProperty(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -102,6 +102,8 @@ class ParentPet(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -103,6 +103,8 @@ class Pig(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -103,6 +103,8 @@ class Quadrilateral(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class ScaleneTriangle(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -103,6 +103,8 @@ class Shape(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -107,6 +107,8 @@ class ShapeOrNull(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -93,6 +93,8 @@ class SimpleQuadrilateral(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -92,6 +92,8 @@ class SomeObject(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -105,6 +105,8 @@ class Triangle(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
None
|
||||
}
|
||||
|
||||
def __new__(
|
||||
|
||||
@@ -104,6 +104,46 @@ class User(
|
||||
**kwargs,
|
||||
)
|
||||
anyTypeProp = AnyTypeSchema
|
||||
|
||||
|
||||
class anyTypeExceptNullProp(
|
||||
ComposedSchema
|
||||
):
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def _composed_schemas(cls):
|
||||
# we need this here to make our import statements work
|
||||
# we must store _composed_schemas in here so the code is only run
|
||||
# when we invoke this method. If we kept this at the class
|
||||
# level we would get an error because the class level
|
||||
# code would be run when this module is imported, and these composed
|
||||
# classes don't exist yet because their module has not finished
|
||||
# loading
|
||||
NotSchema = NoneSchema
|
||||
return {
|
||||
'allOf': [
|
||||
],
|
||||
'oneOf': [
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not':
|
||||
NotSchema
|
||||
}
|
||||
|
||||
def __new__(
|
||||
cls,
|
||||
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
|
||||
_configuration: typing.Optional[Configuration] = None,
|
||||
**kwargs: typing.Type[Schema],
|
||||
) -> 'anyTypeExceptNullProp':
|
||||
return super().__new__(
|
||||
cls,
|
||||
*args,
|
||||
_configuration=_configuration,
|
||||
**kwargs,
|
||||
)
|
||||
anyTypePropNullable = AnyTypeSchema
|
||||
|
||||
|
||||
@@ -121,6 +161,7 @@ class User(
|
||||
objectWithNoDeclaredProps: typing.Union[objectWithNoDeclaredProps, Unset] = unset,
|
||||
objectWithNoDeclaredPropsNullable: typing.Union[objectWithNoDeclaredPropsNullable, Unset] = unset,
|
||||
anyTypeProp: typing.Union[anyTypeProp, Unset] = unset,
|
||||
anyTypeExceptNullProp: typing.Union[anyTypeExceptNullProp, Unset] = unset,
|
||||
anyTypePropNullable: typing.Union[anyTypePropNullable, Unset] = unset,
|
||||
_configuration: typing.Optional[Configuration] = None,
|
||||
**kwargs: typing.Type[Schema],
|
||||
@@ -139,6 +180,7 @@ class User(
|
||||
objectWithNoDeclaredProps=objectWithNoDeclaredProps,
|
||||
objectWithNoDeclaredPropsNullable=objectWithNoDeclaredPropsNullable,
|
||||
anyTypeProp=anyTypeProp,
|
||||
anyTypeExceptNullProp=anyTypeExceptNullProp,
|
||||
anyTypePropNullable=anyTypePropNullable,
|
||||
_configuration=_configuration,
|
||||
**kwargs,
|
||||
|
||||
@@ -16,6 +16,7 @@ from petstore_api.model.additional_properties_with_array_of_enums import Additio
|
||||
from petstore_api.model.address import Address
|
||||
from petstore_api.model.animal import Animal
|
||||
from petstore_api.model.animal_farm import AnimalFarm
|
||||
from petstore_api.model.any_type_not_string import AnyTypeNotString
|
||||
from petstore_api.model.api_response import ApiResponse
|
||||
from petstore_api.model.apple import Apple
|
||||
from petstore_api.model.apple_req import AppleReq
|
||||
|
||||
@@ -1581,19 +1581,19 @@ def cast_to_allowed_types(arg: typing.Union[str, date, datetime, decimal.Decimal
|
||||
class ComposedBase(Discriminable):
|
||||
|
||||
@classmethod
|
||||
def __get_allof_classes(cls, *args, validation_metadata: ValidationMetadata):
|
||||
def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata):
|
||||
path_to_schemas = defaultdict(set)
|
||||
for allof_cls in cls._composed_schemas['allOf']:
|
||||
if allof_cls in validation_metadata.base_classes:
|
||||
continue
|
||||
other_path_to_schemas = allof_cls._validate(*args, validation_metadata=validation_metadata)
|
||||
other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata)
|
||||
update(path_to_schemas, other_path_to_schemas)
|
||||
return path_to_schemas
|
||||
|
||||
@classmethod
|
||||
def __get_oneof_class(
|
||||
cls,
|
||||
*args,
|
||||
arg,
|
||||
discriminated_cls,
|
||||
validation_metadata: ValidationMetadata,
|
||||
path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]]
|
||||
@@ -1607,13 +1607,13 @@ class ComposedBase(Discriminable):
|
||||
if oneof_cls in path_to_schemas[validation_metadata.path_to_item]:
|
||||
oneof_classes.append(oneof_cls)
|
||||
continue
|
||||
if isinstance(args[0], oneof_cls):
|
||||
if isinstance(arg, oneof_cls):
|
||||
# passed in instance is the correct type
|
||||
chosen_oneof_cls = oneof_cls
|
||||
oneof_classes.append(oneof_cls)
|
||||
continue
|
||||
try:
|
||||
path_to_schemas = oneof_cls._validate(*args, validation_metadata=validation_metadata)
|
||||
path_to_schemas = oneof_cls._validate(arg, validation_metadata=validation_metadata)
|
||||
new_base_classes = validation_metadata.base_classes
|
||||
except (ApiValueError, ApiTypeError) as ex:
|
||||
if discriminated_cls is not None and oneof_cls is discriminated_cls:
|
||||
@@ -1636,7 +1636,7 @@ class ComposedBase(Discriminable):
|
||||
@classmethod
|
||||
def __get_anyof_classes(
|
||||
cls,
|
||||
*args,
|
||||
arg,
|
||||
discriminated_cls,
|
||||
validation_metadata: ValidationMetadata
|
||||
):
|
||||
@@ -1647,14 +1647,14 @@ class ComposedBase(Discriminable):
|
||||
for anyof_cls in cls._composed_schemas['anyOf']:
|
||||
if anyof_cls in validation_metadata.base_classes:
|
||||
continue
|
||||
if isinstance(args[0], anyof_cls):
|
||||
if isinstance(arg, anyof_cls):
|
||||
# passed in instance is the correct type
|
||||
chosen_anyof_cls = anyof_cls
|
||||
anyof_classes.append(anyof_cls)
|
||||
continue
|
||||
|
||||
try:
|
||||
other_path_to_schemas = anyof_cls._validate(*args, validation_metadata=validation_metadata)
|
||||
other_path_to_schemas = anyof_cls._validate(arg, validation_metadata=validation_metadata)
|
||||
except (ApiValueError, ApiTypeError) as ex:
|
||||
if discriminated_cls is not None and anyof_cls is discriminated_cls:
|
||||
raise ex
|
||||
@@ -1751,6 +1751,21 @@ class ComposedBase(Discriminable):
|
||||
validation_metadata=updated_vm
|
||||
)
|
||||
update(path_to_schemas, other_path_to_schemas)
|
||||
not_cls = cls._composed_schemas['not']
|
||||
if not_cls:
|
||||
other_path_to_schemas = None
|
||||
try:
|
||||
other_path_to_schemas = not_cls._validate(arg, validation_metadata=updated_vm)
|
||||
except (ApiValueError, ApiTypeError):
|
||||
pass
|
||||
if other_path_to_schemas:
|
||||
raise ApiValueError(
|
||||
"Invalid value '{}' was passed in to {}. Value is invalid because it is disallowed by {}".format(
|
||||
arg,
|
||||
cls.__name__,
|
||||
not_cls.__name__,
|
||||
)
|
||||
)
|
||||
|
||||
if discriminated_cls is not None:
|
||||
# TODO use an exception from this package here
|
||||
@@ -2060,6 +2075,7 @@ class BinarySchema(
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]):
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# 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.model.any_type_not_string import AnyTypeNotString
|
||||
|
||||
|
||||
class TestAnyTypeNotString(unittest.TestCase):
|
||||
"""AnyTypeNotString unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_AnyTypeNotString(self):
|
||||
"""Test AnyTypeNotString"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = AnyTypeNotString() # noqa: E501
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,40 @@
|
||||
# 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.model.any_type_not_string import AnyTypeNotString
|
||||
|
||||
|
||||
class TestAnyTypeNotString(unittest.TestCase):
|
||||
"""AnyTypeNotString unit test stubs"""
|
||||
|
||||
def test_AnyTypeNotString(self):
|
||||
# valid values work
|
||||
valid_values = [
|
||||
True,
|
||||
None,
|
||||
0,
|
||||
3.14,
|
||||
[],
|
||||
{}
|
||||
]
|
||||
for valid_value in valid_values:
|
||||
AnyTypeNotString(valid_value)
|
||||
|
||||
# invalid value raises an exception
|
||||
with self.assertRaises(petstore_api.ApiValueError):
|
||||
AnyTypeNotString('')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -50,6 +50,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model(a=1, b='hi')
|
||||
@@ -74,6 +75,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model([1, 'hi'])
|
||||
@@ -98,6 +100,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model('hi')
|
||||
@@ -122,6 +125,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model(1)
|
||||
@@ -153,6 +157,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model(1)
|
||||
@@ -181,6 +186,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model(True)
|
||||
@@ -212,6 +218,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model(None)
|
||||
@@ -236,6 +243,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model('1970-01-01')
|
||||
@@ -260,6 +268,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model('2020-01-01T00:00:00')
|
||||
@@ -284,6 +293,7 @@ class TestAnyTypeSchema(unittest.TestCase):
|
||||
],
|
||||
'anyOf': [
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
|
||||
m = Model('12.34')
|
||||
|
||||
@@ -92,6 +92,7 @@ class TestFruit(unittest.TestCase):
|
||||
apple.Apple,
|
||||
banana.Banana,
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ class TestFruitReq(unittest.TestCase):
|
||||
apple_req.AppleReq,
|
||||
banana_req.BananaReq,
|
||||
],
|
||||
'not': None
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ class TestGmFruit(unittest.TestCase):
|
||||
],
|
||||
'allOf': [],
|
||||
'oneOf': [],
|
||||
'not': None
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user