[python-experimental] moves composed schemas into cls (#13255)

* Composed schemas moved into cls

* Fixes tests

* Other sample regenerated

* Reverts version files
This commit is contained in:
Justin Black 2022-08-22 16:50:46 -07:00 committed by GitHub
parent fac576a2bf
commit d6fb08d837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 1655 additions and 2248 deletions

View File

@ -1,7 +1,32 @@
{{#with composedSchemas}}
{{#each allOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#each oneOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#each anyOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#with not}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/with}}
{{/with}}
{{#with composedSchemas}}
{{#if allOf}}
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -9,82 +34,101 @@ def _composed_schemas(cls):
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
{{#with composedSchemas}} return [
{{#each allOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#each oneOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#each anyOf}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/each}}
{{#with not}}
{{#unless complexType}}
{{> model_templates/schema }}
{{/unless}}
{{/with}}
{{/with}}
return {
'allOf': [
{{#with composedSchemas}}
{{#each allOf}} {{#each allOf}}
{{#if complexType}} {{#if complexType}}
{{complexType}}, {{complexType}},
{{else}} {{else}}
{{#if nameInSnakeCase}} {{#if nameInSnakeCase}}
{{name}}, cls.{{name}},
{{else}} {{else}}
{{baseName}}, cls.{{baseName}},
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
], ]
'oneOf': [ {{/if}}
{{#if oneOf}}
@classmethod
@property
@functools.cache
def _one_of(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
return [
{{#each oneOf}} {{#each oneOf}}
{{#if complexType}} {{#if complexType}}
{{complexType}}, {{complexType}},
{{else}} {{else}}
{{#if nameInSnakeCase}} {{#if nameInSnakeCase}}
{{name}}, cls.{{name}},
{{else}} {{else}}
{{baseName}}, cls.{{baseName}},
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
], ]
'anyOf': [ {{/if}}
{{#if anyOf}}
@classmethod
@property
@functools.cache
def _any_of(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
return [
{{#each anyOf}} {{#each anyOf}}
{{#if complexType}} {{#if complexType}}
{{complexType}}, {{complexType}},
{{else}} {{else}}
{{#if nameInSnakeCase}} {{#if nameInSnakeCase}}
{{name}}, cls.{{name}},
{{else}} {{else}}
{{baseName}}, cls.{{baseName}},
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
], ]
'not': {{/if}}
{{#if not}}
@classmethod
@property
@functools.cache
def _not(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
return (
{{#with not}} {{#with not}}
{{#if complexType}} {{#if complexType}}
{{complexType}} {{complexType}}
{{else}} {{else}}
{{#if nameInSnakeCase}} {{#if nameInSnakeCase}}
{{name}} cls.{{name}}
{{else}} {{else}}
{{baseName}} cls.{{baseName}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{else}} {{else}}
None None
{{/with}} {{/with}}
)
{{/if}}
{{/with}} {{/with}}
}

View File

@ -942,20 +942,20 @@ class Discriminable:
discriminated_cls = disc[disc_property_name].get(disc_payload_value) discriminated_cls = disc[disc_property_name].get(disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
elif not hasattr(cls, '_composed_schemas'): elif not (hasattr(cls, '_all_of') or hasattr(cls, '_one_of') or hasattr(cls, '_any_of')):
return None return None
# TODO stop traveling if a cycle is hit # TODO stop traveling if a cycle is hit
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in getattr(cls, '_all_of', []):
discriminated_cls = allof_cls._get_discriminated_class( discriminated_cls = allof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in getattr(cls, '_one_of', []):
discriminated_cls = oneof_cls._get_discriminated_class( discriminated_cls = oneof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in getattr(cls, '_any_of', []):
discriminated_cls = anyof_cls._get_discriminated_class( discriminated_cls = anyof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
@ -1560,7 +1560,7 @@ class ComposedBase(Discriminable):
@classmethod @classmethod
def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata):
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in cls._all_of:
if validation_metadata.validation_ran_earlier(allof_cls): if validation_metadata.validation_ran_earlier(allof_cls):
continue continue
other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata)
@ -1576,7 +1576,7 @@ class ComposedBase(Discriminable):
): ):
oneof_classes = [] oneof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in cls._one_of:
if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: if oneof_cls in path_to_schemas[validation_metadata.path_to_item]:
oneof_classes.append(oneof_cls) oneof_classes.append(oneof_cls)
continue continue
@ -1611,7 +1611,7 @@ class ComposedBase(Discriminable):
): ):
anyof_classes = [] anyof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in cls._any_of:
if validation_metadata.validation_ran_earlier(anyof_cls): if validation_metadata.validation_ran_earlier(anyof_cls):
anyof_classes.append(anyof_cls) anyof_classes.append(anyof_cls)
continue continue
@ -1683,24 +1683,24 @@ class ComposedBase(Discriminable):
) )
) )
if cls._composed_schemas['allOf']: if hasattr(cls, '_all_of'):
other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm)
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['oneOf']: if hasattr(cls, '_one_of'):
other_path_to_schemas = cls.__get_oneof_class( other_path_to_schemas = cls.__get_oneof_class(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']: if hasattr(cls, '_any_of'):
other_path_to_schemas = cls.__get_anyof_classes( other_path_to_schemas = cls.__get_anyof_classes(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
not_cls = cls._composed_schemas['not'] not_cls = getattr(cls, '_not', None)
if not_cls: if not_cls:
other_path_to_schemas = None other_path_to_schemas = None
not_exception = ApiValueError( not_exception = ApiValueError(
@ -1994,27 +1994,10 @@ class BinarySchema(
BinaryBase, BinaryBase,
Schema, Schema,
): ):
_one_of = [
@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
return {
'allOf': [],
'oneOf': [
BytesSchema, BytesSchema,
FileSchema, FileSchema,
], ]
'anyOf': [
],
'not': None
}
def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]):
return super().__new__(cls, arg) return super().__new__(cls, arg)

View File

@ -33,17 +33,6 @@ class AdditionalpropertiesShouldNotLookInApplicators(
""" """
_additional_properties = schemas.BoolSchema _additional_properties = schemas.BoolSchema
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -65,17 +54,21 @@ class AdditionalpropertiesShouldNotLookInApplicators(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class Allof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -91,18 +80,22 @@ class Allof(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
all_of_1, @functools.cache
], def _all_of(cls):
'oneOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.all_of_0,
cls.all_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class AllofCombinedWithAnyofOneof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -100,19 +89,51 @@ class AllofCombinedWithAnyofOneof(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
one_of_0, # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
any_of_0, # level we would get an error because the class level
], # code would be run when this module is imported, and these composed
'not': # classes don't exist yet because their module has not finished
None # loading
} return [
cls.all_of_0,
]
@classmethod
@property
@functools.cache
def _one_of(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
return [
cls.one_of_0,
]
@classmethod
@property
@functools.cache
def _any_of(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
return [
cls.any_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class AllofSimpleTypes(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -81,18 +70,22 @@ class AllofSimpleTypes(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
all_of_1, @functools.cache
], def _all_of(cls):
'oneOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.all_of_0,
cls.all_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -36,17 +36,6 @@ class AllofWithBaseSchema(
} }
bar = schemas.IntSchema bar = schemas.IntSchema
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -95,18 +84,22 @@ class AllofWithBaseSchema(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
all_of_1, @functools.cache
], def _all_of(cls):
'oneOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.all_of_0,
cls.all_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,12 @@ class AllofWithOneEmptySchema(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,18 +45,9 @@ class AllofWithOneEmptySchema(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,13 @@ class AllofWithTheFirstEmptySchema(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
all_of_1 = schemas.NumberSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +46,10 @@ class AllofWithTheFirstEmptySchema(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
all_of_1 = schemas.NumberSchema cls.all_of_0,
return { cls.all_of_1,
'allOf': [ ]
all_of_0,
all_of_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,13 @@ class AllofWithTheLastEmptySchema(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.NumberSchema
all_of_1 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +46,10 @@ class AllofWithTheLastEmptySchema(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.NumberSchema return [
all_of_1 = schemas.AnyTypeSchema cls.all_of_0,
return { cls.all_of_1,
'allOf': [ ]
all_of_0,
all_of_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,13 @@ class AllofWithTwoEmptySchemas(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
all_of_1 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +46,10 @@ class AllofWithTwoEmptySchemas(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
all_of_1 = schemas.AnyTypeSchema cls.all_of_0,
return { cls.all_of_1,
'allOf': [ ]
all_of_0,
all_of_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class Anyof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
any_of_0 = schemas.IntSchema any_of_0 = schemas.IntSchema
@ -63,18 +52,22 @@ class Anyof(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _any_of(cls):
'anyOf': [ # we need this here to make our import statements work
any_of_0, # we must store _composed_schemas in here so the code is only run
any_of_1, # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.any_of_0,
cls.any_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class AnyofComplexTypes(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class any_of_0( class any_of_0(
@ -91,18 +80,22 @@ class AnyofComplexTypes(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _any_of(cls):
'anyOf': [ # we need this here to make our import statements work
any_of_0, # we must store _composed_schemas in here so the code is only run
any_of_1, # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.any_of_0,
cls.any_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -33,17 +33,6 @@ class AnyofWithBaseSchema(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class any_of_0( class any_of_0(
@ -82,18 +71,22 @@ class AnyofWithBaseSchema(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _any_of(cls):
'anyOf': [ # we need this here to make our import statements work
any_of_0, # we must store _composed_schemas in here so the code is only run
any_of_1, # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.any_of_0,
cls.any_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,13 @@ class AnyofWithOneEmptySchema(
Do not edit the class manually. Do not edit the class manually.
""" """
any_of_0 = schemas.NumberSchema
any_of_1 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _any_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +46,10 @@ class AnyofWithOneEmptySchema(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
any_of_0 = schemas.NumberSchema return [
any_of_1 = schemas.AnyTypeSchema cls.any_of_0,
return { cls.any_of_1,
'allOf': [ ]
],
'oneOf': [
],
'anyOf': [
any_of_0,
any_of_1,
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -37,10 +37,12 @@ class ForbiddenProperty(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
not_schema = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -48,17 +50,9 @@ class ForbiddenProperty(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.AnyTypeSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,12 @@ class ModelNot(
Do not edit the class manually. Do not edit the class manually.
""" """
not_schema = schemas.IntSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +45,9 @@ class ModelNot(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.IntSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -32,27 +32,18 @@ class NestedAllofToCheckValidationSemantics(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
all_of_0 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -60,18 +51,9 @@ class NestedAllofToCheckValidationSemantics(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.NoneSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,
@ -85,17 +67,21 @@ class NestedAllofToCheckValidationSemantics(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,27 +32,18 @@ class NestedAnyofToCheckValidationSemantics(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class any_of_0( class any_of_0(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
any_of_0 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _any_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -60,18 +51,9 @@ class NestedAnyofToCheckValidationSemantics(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
any_of_0 = schemas.NoneSchema return [
return { cls.any_of_0,
'allOf': [ ]
],
'oneOf': [
],
'anyOf': [
any_of_0,
],
'not':
None
}
def __new__( def __new__(
cls, cls,
@ -85,17 +67,21 @@ class NestedAnyofToCheckValidationSemantics(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _any_of(cls):
'anyOf': [ # we need this here to make our import statements work
any_of_0, # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.any_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,27 +32,18 @@ class NestedOneofToCheckValidationSemantics(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class one_of_0( class one_of_0(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
one_of_0 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -60,18 +51,9 @@ class NestedOneofToCheckValidationSemantics(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
one_of_0 = schemas.NoneSchema return [
return { cls.one_of_0,
'allOf': [ ]
],
'oneOf': [
one_of_0,
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,
@ -85,17 +67,21 @@ class NestedOneofToCheckValidationSemantics(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
one_of_0, def _one_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.one_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class NotMoreComplexSchema(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class not_schema( class not_schema(
@ -65,16 +54,21 @@ class NotMoreComplexSchema(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _not(cls):
'anyOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'not': # when we invoke this method. If we kept this at the class
not_schema # 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
return (
cls.not_schema
)
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class Oneof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
one_of_0 = schemas.IntSchema one_of_0 = schemas.IntSchema
@ -63,18 +52,22 @@ class Oneof(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
one_of_0, def _one_of(cls):
one_of_1, # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.one_of_0,
cls.one_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class OneofComplexTypes(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class one_of_0( class one_of_0(
@ -91,18 +80,22 @@ class OneofComplexTypes(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
one_of_0, def _one_of(cls):
one_of_1, # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.one_of_0,
cls.one_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -33,17 +33,6 @@ class OneofWithBaseSchema(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class one_of_0( class one_of_0(
@ -82,18 +71,22 @@ class OneofWithBaseSchema(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
one_of_0, def _one_of(cls):
one_of_1, # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.one_of_0,
cls.one_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,13 @@ class OneofWithEmptySchema(
Do not edit the class manually. Do not edit the class manually.
""" """
one_of_0 = schemas.NumberSchema
one_of_1 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +46,10 @@ class OneofWithEmptySchema(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
one_of_0 = schemas.NumberSchema return [
one_of_1 = schemas.AnyTypeSchema cls.one_of_0,
return { cls.one_of_1,
'allOf': [ ]
],
'oneOf': [
one_of_0,
one_of_1,
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,17 +33,6 @@ class OneofWithRequired(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class one_of_0( class one_of_0(
@ -88,18 +77,22 @@ class OneofWithRequired(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
one_of_0, def _one_of(cls):
one_of_1, # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'anyOf': [ # when we invoke this method. If we kept this at the class
], # level we would get an error because the class level
'not': # code would be run when this module is imported, and these composed
None # classes don't exist yet because their module has not finished
} # loading
return [
cls.one_of_0,
cls.one_of_1,
]
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class RefInAllof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +44,9 @@ class RefInAllof(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
PropertyNamedRefThatIsNotAReference, PropertyNamedRefThatIsNotAReference,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class RefInAnyof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _any_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +44,9 @@ class RefInAnyof(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
],
'anyOf': [
PropertyNamedRefThatIsNotAReference, PropertyNamedRefThatIsNotAReference,
], ]
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class RefInNot(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,16 +44,9 @@ class RefInNot(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return (
'allOf': [
],
'oneOf': [
],
'anyOf': [
],
'not':
PropertyNamedRefThatIsNotAReference PropertyNamedRefThatIsNotAReference
} )
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class RefInOneof(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +44,9 @@ class RefInOneof(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
PropertyNamedRefThatIsNotAReference, PropertyNamedRefThatIsNotAReference,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -30,17 +30,6 @@ class SchemaForRequestBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class not_schema( class not_schema(
@ -63,16 +52,21 @@ class SchemaForRequestBodyApplicationJson(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _not(cls):
'anyOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'not': # when we invoke this method. If we kept this at the class
not_schema # 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
return (
cls.not_schema
)
def __new__( def __new__(
cls, cls,

View File

@ -30,10 +30,12 @@ class SchemaForRequestBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
not_schema = schemas.IntSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -41,17 +43,9 @@ class SchemaForRequestBodyApplicationJson(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.IntSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class SchemaForRequestBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,16 +44,9 @@ class SchemaForRequestBodyApplicationJson(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return (
'allOf': [
],
'oneOf': [
],
'anyOf': [
],
'not':
PropertyNamedRefThatIsNotAReference PropertyNamedRefThatIsNotAReference
} )
def __new__( def __new__(
cls, cls,

View File

@ -29,17 +29,6 @@ class SchemaFor200ResponseBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class not_schema( class not_schema(
@ -62,16 +51,21 @@ class SchemaFor200ResponseBodyApplicationJson(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _not(cls):
'anyOf': [ # we need this here to make our import statements work
], # we must store _composed_schemas in here so the code is only run
'not': # when we invoke this method. If we kept this at the class
not_schema # 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
return (
cls.not_schema
)
def __new__( def __new__(
cls, cls,

View File

@ -29,10 +29,12 @@ class SchemaFor200ResponseBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
not_schema = schemas.IntSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -40,17 +42,9 @@ class SchemaFor200ResponseBodyApplicationJson(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.IntSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -31,10 +31,11 @@ class SchemaFor200ResponseBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -42,16 +43,9 @@ class SchemaFor200ResponseBodyApplicationJson(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return (
'allOf': [
],
'oneOf': [
],
'anyOf': [
],
'not':
PropertyNamedRefThatIsNotAReference PropertyNamedRefThatIsNotAReference
} )
def __new__( def __new__(
cls, cls,

View File

@ -949,20 +949,20 @@ class Discriminable:
discriminated_cls = disc[disc_property_name].get(disc_payload_value) discriminated_cls = disc[disc_property_name].get(disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
elif not hasattr(cls, '_composed_schemas'): elif not (hasattr(cls, '_all_of') or hasattr(cls, '_one_of') or hasattr(cls, '_any_of')):
return None return None
# TODO stop traveling if a cycle is hit # TODO stop traveling if a cycle is hit
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in getattr(cls, '_all_of', []):
discriminated_cls = allof_cls._get_discriminated_class( discriminated_cls = allof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in getattr(cls, '_one_of', []):
discriminated_cls = oneof_cls._get_discriminated_class( discriminated_cls = oneof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in getattr(cls, '_any_of', []):
discriminated_cls = anyof_cls._get_discriminated_class( discriminated_cls = anyof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
@ -1567,7 +1567,7 @@ class ComposedBase(Discriminable):
@classmethod @classmethod
def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata):
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in cls._all_of:
if validation_metadata.validation_ran_earlier(allof_cls): if validation_metadata.validation_ran_earlier(allof_cls):
continue continue
other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata)
@ -1583,7 +1583,7 @@ class ComposedBase(Discriminable):
): ):
oneof_classes = [] oneof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in cls._one_of:
if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: if oneof_cls in path_to_schemas[validation_metadata.path_to_item]:
oneof_classes.append(oneof_cls) oneof_classes.append(oneof_cls)
continue continue
@ -1618,7 +1618,7 @@ class ComposedBase(Discriminable):
): ):
anyof_classes = [] anyof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in cls._any_of:
if validation_metadata.validation_ran_earlier(anyof_cls): if validation_metadata.validation_ran_earlier(anyof_cls):
anyof_classes.append(anyof_cls) anyof_classes.append(anyof_cls)
continue continue
@ -1690,24 +1690,24 @@ class ComposedBase(Discriminable):
) )
) )
if cls._composed_schemas['allOf']: if hasattr(cls, '_all_of'):
other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm)
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['oneOf']: if hasattr(cls, '_one_of'):
other_path_to_schemas = cls.__get_oneof_class( other_path_to_schemas = cls.__get_oneof_class(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']: if hasattr(cls, '_any_of'):
other_path_to_schemas = cls.__get_anyof_classes( other_path_to_schemas = cls.__get_anyof_classes(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
not_cls = cls._composed_schemas['not'] not_cls = getattr(cls, '_not', None)
if not_cls: if not_cls:
other_path_to_schemas = None other_path_to_schemas = None
not_exception = ApiValueError( not_exception = ApiValueError(
@ -2001,27 +2001,10 @@ class BinarySchema(
BinaryBase, BinaryBase,
Schema, Schema,
): ):
_one_of = [
@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
return {
'allOf': [],
'oneOf': [
BytesSchema, BytesSchema,
FileSchema, FileSchema,
], ]
'anyOf': [
],
'not': None
}
def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]):
return super().__new__(cls, arg) return super().__new__(cls, arg)

View File

@ -32,10 +32,12 @@ class AnyTypeNotString(
Do not edit the class manually. Do not edit the class manually.
""" """
not_schema = schemas.StrSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +45,9 @@ class AnyTypeNotString(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.StrSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class Cat(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -65,18 +54,22 @@ class Cat(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
Animal, Animal,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class ChildCat(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -65,18 +54,22 @@ class ChildCat(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
ParentPet, ParentPet,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class ComplexQuadrilateral(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -79,18 +68,22 @@ class ComplexQuadrilateral(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
QuadrilateralInterface, QuadrilateralInterface,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class ComposedAnyOfDifferentTypesNoValidations(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
any_of_0 = schemas.DictSchema any_of_0 = schemas.DictSchema
any_of_1 = schemas.DateSchema any_of_1 = schemas.DateSchema
any_of_2 = schemas.DateTimeSchema any_of_2 = schemas.DateTimeSchema
@ -64,32 +53,36 @@ class ComposedAnyOfDifferentTypesNoValidations(
any_of_13 = schemas.IntSchema any_of_13 = schemas.IntSchema
any_of_14 = schemas.Int32Schema any_of_14 = schemas.Int32Schema
any_of_15 = schemas.Int64Schema any_of_15 = schemas.Int64Schema
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
], def _any_of(cls):
'anyOf': [ # we need this here to make our import statements work
any_of_0, # we must store _composed_schemas in here so the code is only run
any_of_1, # when we invoke this method. If we kept this at the class
any_of_2, # level we would get an error because the class level
any_of_3, # code would be run when this module is imported, and these composed
any_of_4, # classes don't exist yet because their module has not finished
any_of_5, # loading
any_of_6, return [
any_of_7, cls.any_of_0,
any_of_8, cls.any_of_1,
any_of_9, cls.any_of_2,
any_of_10, cls.any_of_3,
any_of_11, cls.any_of_4,
any_of_12, cls.any_of_5,
any_of_13, cls.any_of_6,
any_of_14, cls.any_of_7,
any_of_15, cls.any_of_8,
], cls.any_of_9,
'not': cls.any_of_10,
None cls.any_of_11,
} cls.any_of_12,
cls.any_of_13,
cls.any_of_14,
cls.any_of_15,
]
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,12 @@ class ComposedBool(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +46,9 @@ class ComposedBool(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,12 @@ class ComposedNone(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +46,9 @@ class ComposedNone(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,12 @@ class ComposedNumber(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +46,9 @@ class ComposedNumber(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,12 @@ class ComposedObject(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +46,9 @@ class ComposedObject(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -34,17 +34,6 @@ class ComposedOneOfDifferentTypes(
this is a model that allows payloads of type object or number this is a model that allows payloads of type object or number
""" """
@classmethod
@property
@functools.cache
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
one_of_2 = schemas.NoneSchema one_of_2 = schemas.NoneSchema
one_of_3 = schemas.DateSchema one_of_3 = schemas.DateSchema
@ -85,23 +74,27 @@ class ComposedOneOfDifferentTypes(
'pattern': r'^2020.*', # noqa: E501 'pattern': r'^2020.*', # noqa: E501
}] }]
pass pass
return {
'allOf': [ @classmethod
], @property
'oneOf': [ @functools.cache
def _one_of(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
return [
NumberWithValidations, NumberWithValidations,
Animal, Animal,
one_of_2, cls.one_of_2,
one_of_3, cls.one_of_3,
one_of_4, cls.one_of_4,
one_of_5, cls.one_of_5,
one_of_6, cls.one_of_6,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,12 @@ class ComposedString(
Do not edit the class manually. Do not edit the class manually.
""" """
all_of_0 = schemas.AnyTypeSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +46,9 @@ class ComposedString(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
all_of_0 = schemas.AnyTypeSchema return [
return { cls.all_of_0,
'allOf': [ ]
all_of_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class Dog(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -65,18 +54,22 @@ class Dog(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
Animal, Animal,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class EquilateralTriangle(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -79,18 +68,22 @@ class EquilateralTriangle(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
TriangleInterface, TriangleInterface,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,11 @@ class Fruit(
""" """
color = schemas.StrSchema color = schemas.StrSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +45,10 @@ class Fruit(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
Apple, Apple,
Banana, Banana,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,12 @@ class FruitReq(
Do not edit the class manually. Do not edit the class manually.
""" """
one_of_0 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,20 +45,11 @@ class FruitReq(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
one_of_0 = schemas.NoneSchema return [
return { cls.one_of_0,
'allOf': [
],
'oneOf': [
one_of_0,
AppleReq, AppleReq,
BananaReq, BananaReq,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -33,10 +33,11 @@ class GmFruit(
""" """
color = schemas.StrSchema color = schemas.StrSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _any_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -44,18 +45,10 @@ class GmFruit(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
],
'anyOf': [
Apple, Apple,
Banana, Banana,
], ]
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class IsoscelesTriangle(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -79,18 +68,22 @@ class IsoscelesTriangle(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
TriangleInterface, TriangleInterface,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -43,10 +43,11 @@ class Mammal(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -54,19 +55,11 @@ class Mammal(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
Whale, Whale,
Zebra, Zebra,
Pig, Pig,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -34,10 +34,12 @@ class NullableShape(
The value may be a shape or the 'null' value. For a composed schema to validate a null payload, one of its chosen oneOf schemas must be type null or nullable (introduced in OAS schema >= 3.0) The value may be a shape or the 'null' value. For a composed schema to validate a null payload, one of its chosen oneOf schemas must be type null or nullable (introduced in OAS schema >= 3.0)
""" """
one_of_2 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -45,20 +47,11 @@ class NullableShape(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
one_of_2 = schemas.NoneSchema return [
return {
'allOf': [
],
'oneOf': [
Triangle, Triangle,
Quadrilateral, Quadrilateral,
one_of_2, cls.one_of_2,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -37,17 +37,6 @@ class ObjectWithInlineCompositionProperty(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -55,17 +44,21 @@ class ObjectWithInlineCompositionProperty(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -42,10 +42,11 @@ class ParentPet(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -53,17 +54,9 @@ class ParentPet(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
GrandparentAnimal, GrandparentAnimal,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -42,10 +42,11 @@ class Pig(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -53,18 +54,10 @@ class Pig(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
BasquePig, BasquePig,
DanishPig, DanishPig,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -42,10 +42,11 @@ class Quadrilateral(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -53,18 +54,10 @@ class Quadrilateral(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
SimpleQuadrilateral, SimpleQuadrilateral,
ComplexQuadrilateral, ComplexQuadrilateral,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class ScaleneTriangle(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -79,18 +68,22 @@ class ScaleneTriangle(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
TriangleInterface, TriangleInterface,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -42,10 +42,11 @@ class Shape(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -53,18 +54,10 @@ class Shape(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
Triangle, Triangle,
Quadrilateral, Quadrilateral,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -44,10 +44,12 @@ class ShapeOrNull(
} }
} }
one_of_0 = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -55,20 +57,11 @@ class ShapeOrNull(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
one_of_0 = schemas.NoneSchema return [
return { cls.one_of_0,
'allOf': [
],
'oneOf': [
one_of_0,
Triangle, Triangle,
Quadrilateral, Quadrilateral,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,17 +32,6 @@ class SimpleQuadrilateral(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod
@property
@functools.cache
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
class all_of_1( class all_of_1(
@ -79,18 +68,22 @@ class SimpleQuadrilateral(
_configuration=_configuration, _configuration=_configuration,
**kwargs, **kwargs,
) )
return {
'allOf': [ @classmethod
@property
@functools.cache
def _all_of(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
return [
QuadrilateralInterface, QuadrilateralInterface,
all_of_1, cls.all_of_1,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -32,10 +32,11 @@ class SomeObject(
Do not edit the class manually. Do not edit the class manually.
""" """
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _all_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -43,17 +44,9 @@ class SomeObject(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
ObjectInterface, ObjectInterface,
], ]
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -43,10 +43,11 @@ class Triangle(
} }
} }
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _one_of(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -54,19 +55,11 @@ class Triangle(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
return { return [
'allOf': [
],
'oneOf': [
EquilateralTriangle, EquilateralTriangle,
IsoscelesTriangle, IsoscelesTriangle,
ScaleneTriangle, ScaleneTriangle,
], ]
'anyOf': [
],
'not':
None
}
def __new__( def __new__(
cls, cls,

View File

@ -68,10 +68,12 @@ class User(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
not_schema = schemas.NoneSchema
@classmethod @classmethod
@property @property
@functools.cache @functools.cache
def _composed_schemas(cls): def _not(cls):
# we need this here to make our import statements work # we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run # 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 # when we invoke this method. If we kept this at the class
@ -79,17 +81,9 @@ class User(
# code would be run when this module is imported, and these composed # code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished # classes don't exist yet because their module has not finished
# loading # loading
not_schema = schemas.NoneSchema return (
return { cls.not_schema
'allOf': [ )
],
'oneOf': [
],
'anyOf': [
],
'not':
not_schema
}
def __new__( def __new__(
cls, cls,

View File

@ -30,17 +30,6 @@ class CompositionAtRootSchema(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -48,17 +37,21 @@ class CompositionAtRootSchema(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,
@ -83,17 +76,6 @@ class CompositionInPropertySchema(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -101,17 +83,21 @@ class CompositionInPropertySchema(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,
@ -179,17 +165,6 @@ class SchemaForRequestBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -197,17 +172,21 @@ class SchemaForRequestBodyApplicationJson(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,
@ -232,17 +211,6 @@ class SchemaForRequestBodyMultipartFormData(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -250,17 +218,21 @@ class SchemaForRequestBodyMultipartFormData(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,
@ -306,17 +278,6 @@ class SchemaFor200ResponseBodyApplicationJson(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -324,17 +285,21 @@ class SchemaFor200ResponseBodyApplicationJson(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,
@ -359,17 +324,6 @@ class SchemaFor200ResponseBodyMultipartFormData(
schemas.ComposedSchema, schemas.ComposedSchema,
): ):
@classmethod
@property
@functools.cache
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
class all_of_0( class all_of_0(
@ -377,17 +331,21 @@ class SchemaFor200ResponseBodyMultipartFormData(
): ):
_min_length=1 _min_length=1
pass pass
return {
'allOf': [ @classmethod
all_of_0, @property
], @functools.cache
'oneOf': [ def _all_of(cls):
], # we need this here to make our import statements work
'anyOf': [ # 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
'not': # level we would get an error because the class level
None # code would be run when this module is imported, and these composed
} # classes don't exist yet because their module has not finished
# loading
return [
cls.all_of_0,
]
def __new__( def __new__(
cls, cls,

View File

@ -949,20 +949,20 @@ class Discriminable:
discriminated_cls = disc[disc_property_name].get(disc_payload_value) discriminated_cls = disc[disc_property_name].get(disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
elif not hasattr(cls, '_composed_schemas'): elif not (hasattr(cls, '_all_of') or hasattr(cls, '_one_of') or hasattr(cls, '_any_of')):
return None return None
# TODO stop traveling if a cycle is hit # TODO stop traveling if a cycle is hit
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in getattr(cls, '_all_of', []):
discriminated_cls = allof_cls._get_discriminated_class( discriminated_cls = allof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in getattr(cls, '_one_of', []):
discriminated_cls = oneof_cls._get_discriminated_class( discriminated_cls = oneof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
return discriminated_cls return discriminated_cls
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in getattr(cls, '_any_of', []):
discriminated_cls = anyof_cls._get_discriminated_class( discriminated_cls = anyof_cls._get_discriminated_class(
disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) disc_property_name=disc_property_name, disc_payload_value=disc_payload_value)
if discriminated_cls is not None: if discriminated_cls is not None:
@ -1567,7 +1567,7 @@ class ComposedBase(Discriminable):
@classmethod @classmethod
def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata):
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for allof_cls in cls._composed_schemas['allOf']: for allof_cls in cls._all_of:
if validation_metadata.validation_ran_earlier(allof_cls): if validation_metadata.validation_ran_earlier(allof_cls):
continue continue
other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata)
@ -1583,7 +1583,7 @@ class ComposedBase(Discriminable):
): ):
oneof_classes = [] oneof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for oneof_cls in cls._composed_schemas['oneOf']: for oneof_cls in cls._one_of:
if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: if oneof_cls in path_to_schemas[validation_metadata.path_to_item]:
oneof_classes.append(oneof_cls) oneof_classes.append(oneof_cls)
continue continue
@ -1618,7 +1618,7 @@ class ComposedBase(Discriminable):
): ):
anyof_classes = [] anyof_classes = []
path_to_schemas = defaultdict(set) path_to_schemas = defaultdict(set)
for anyof_cls in cls._composed_schemas['anyOf']: for anyof_cls in cls._any_of:
if validation_metadata.validation_ran_earlier(anyof_cls): if validation_metadata.validation_ran_earlier(anyof_cls):
anyof_classes.append(anyof_cls) anyof_classes.append(anyof_cls)
continue continue
@ -1690,24 +1690,24 @@ class ComposedBase(Discriminable):
) )
) )
if cls._composed_schemas['allOf']: if hasattr(cls, '_all_of'):
other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm)
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['oneOf']: if hasattr(cls, '_one_of'):
other_path_to_schemas = cls.__get_oneof_class( other_path_to_schemas = cls.__get_oneof_class(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']: if hasattr(cls, '_any_of'):
other_path_to_schemas = cls.__get_anyof_classes( other_path_to_schemas = cls.__get_anyof_classes(
arg, arg,
discriminated_cls=discriminated_cls, discriminated_cls=discriminated_cls,
validation_metadata=updated_vm validation_metadata=updated_vm
) )
update(path_to_schemas, other_path_to_schemas) update(path_to_schemas, other_path_to_schemas)
not_cls = cls._composed_schemas['not'] not_cls = getattr(cls, '_not', None)
if not_cls: if not_cls:
other_path_to_schemas = None other_path_to_schemas = None
not_exception = ApiValueError( not_exception = ApiValueError(
@ -2001,27 +2001,10 @@ class BinarySchema(
BinaryBase, BinaryBase,
Schema, Schema,
): ):
_one_of = [
@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
return {
'allOf': [],
'oneOf': [
BytesSchema, BytesSchema,
FileSchema, FileSchema,
], ]
'anyOf': [
],
'not': None
}
def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]):
return super().__new__(cls, arg) return super().__new__(cls, arg)

View File

@ -42,7 +42,7 @@ class TestAnimal(unittest.TestCase):
assert isinstance(animal, Animal) assert isinstance(animal, Animal)
assert isinstance(animal, frozendict) assert isinstance(animal, frozendict)
assert isinstance(animal, Cat) assert isinstance(animal, Cat)
assert isinstance(animal, Cat._composed_schemas['allOf'][1]) assert isinstance(animal, Cat._all_of[1])
assert set(animal.keys()) == {'className', 'color'} assert set(animal.keys()) == {'className', 'color'}
assert animal.className == 'Cat' assert animal.className == 'Cat'
assert animal.color == 'black' assert animal.color == 'black'
@ -54,7 +54,7 @@ class TestAnimal(unittest.TestCase):
assert isinstance(animal, Animal) assert isinstance(animal, Animal)
assert isinstance(animal, frozendict) assert isinstance(animal, frozendict)
assert isinstance(animal, Cat) assert isinstance(animal, Cat)
assert isinstance(animal, Cat._composed_schemas['allOf'][1]) assert isinstance(animal, Cat._all_of[1])
assert set(animal.keys()) == {'className', 'color', 'declawed'} assert set(animal.keys()) == {'className', 'color', 'declawed'}
assert animal.className == 'Cat' assert animal.className == 'Cat'
assert animal.color == 'black' assert animal.color == 'black'
@ -68,7 +68,7 @@ class TestAnimal(unittest.TestCase):
assert isinstance(animal, Animal) assert isinstance(animal, Animal)
assert isinstance(animal, frozendict) assert isinstance(animal, frozendict)
assert isinstance(animal, Dog) assert isinstance(animal, Dog)
assert isinstance(animal, Dog._composed_schemas['allOf'][1]) assert isinstance(animal, Dog._all_of[1])
assert set(animal.keys()) == {'className', 'color'} assert set(animal.keys()) == {'className', 'color'}
assert animal.className == 'Dog' assert animal.className == 'Dog'
assert animal.color == 'black' assert animal.color == 'black'
@ -80,7 +80,7 @@ class TestAnimal(unittest.TestCase):
assert isinstance(animal, Animal) assert isinstance(animal, Animal)
assert isinstance(animal, frozendict) assert isinstance(animal, frozendict)
assert isinstance(animal, Dog) assert isinstance(animal, Dog)
assert isinstance(animal, Dog._composed_schemas['allOf'][1]) assert isinstance(animal, Dog._all_of[1])
assert set(animal.keys()) == {'className', 'color', 'breed'} assert set(animal.keys()) == {'className', 'color', 'breed'}
assert animal.className == 'Dog' assert animal.className == 'Dog'
assert animal.color == 'black' assert animal.color == 'black'

View File

@ -38,20 +38,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testDictSchema(self): def testDictSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
DictSchema, DictSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model(a=1, b='hi') m = Model(a=1, b='hi')
assert isinstance(m, Model) assert isinstance(m, Model)
@ -63,20 +53,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testListSchema(self): def testListSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
ListSchema, ListSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model([1, 'hi']) m = Model([1, 'hi'])
assert isinstance(m, Model) assert isinstance(m, Model)
@ -88,20 +68,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testStrSchema(self): def testStrSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
StrSchema, StrSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model('hi') m = Model('hi')
assert isinstance(m, Model) assert isinstance(m, Model)
@ -113,20 +83,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testNumberSchema(self): def testNumberSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
NumberSchema, NumberSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model(1) m = Model(1)
assert isinstance(m, Model) assert isinstance(m, Model)
@ -145,20 +105,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testIntSchema(self): def testIntSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
IntSchema, IntSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model(1) m = Model(1)
assert isinstance(m, Model) assert isinstance(m, Model)
@ -174,20 +124,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testBoolSchema(self): def testBoolSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
BoolSchema, BoolSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model(True) m = Model(True)
assert isinstance(m, Model) assert isinstance(m, Model)
@ -206,20 +146,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testNoneSchema(self): def testNoneSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
NoneSchema, NoneSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model(None) m = Model(None)
assert isinstance(m, Model) assert isinstance(m, Model)
@ -231,20 +161,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testDateSchema(self): def testDateSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
DateSchema, DateSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model('1970-01-01') m = Model('1970-01-01')
assert isinstance(m, Model) assert isinstance(m, Model)
@ -256,20 +176,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testDateTimeSchema(self): def testDateTimeSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
DateTimeSchema, DateTimeSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model('2020-01-01T00:00:00') m = Model('2020-01-01T00:00:00')
assert isinstance(m, Model) assert isinstance(m, Model)
@ -281,20 +191,10 @@ class TestAnyTypeSchema(unittest.TestCase):
def testDecimalSchema(self): def testDecimalSchema(self):
class Model(ComposedSchema): class Model(ComposedSchema):
@classmethod _all_of = [
@property
def _composed_schemas(cls):
return {
'allOf': [
AnyTypeSchema, AnyTypeSchema,
DecimalSchema, DecimalSchema,
], ]
'oneOf': [
],
'anyOf': [
],
'not': None
}
m = Model('12.34') m = Model('12.34')
assert isinstance(m, Model) assert isinstance(m, Model)

View File

@ -84,16 +84,11 @@ class TestFruit(unittest.TestCase):
# make sure that the ModelComposed class properties are correct # make sure that the ModelComposed class properties are correct
# model._composed_schemas stores the anyOf/allOf/oneOf info # model._composed_schemas stores the anyOf/allOf/oneOf info
self.assertEqual( self.assertEqual(
fruit._composed_schemas, fruit._one_of,
{ [
'anyOf': [],
'allOf': [],
'oneOf': [
apple.Apple, apple.Apple,
banana.Banana, banana.Banana,
], ],
'not': None
}
) )
""" """

View File

@ -69,17 +69,12 @@ class TestFruitReq(unittest.TestCase):
# make sure that the ModelComposed class properties are correct # make sure that the ModelComposed class properties are correct
# model._composed_schemas stores the anyOf/allOf/oneOf info # model._composed_schemas stores the anyOf/allOf/oneOf info
self.assertEqual( self.assertEqual(
fruit._composed_schemas, fruit._one_of,
{ [
'anyOf': [],
'allOf': [],
'oneOf': [
NoneSchema, NoneSchema,
apple_req.AppleReq, apple_req.AppleReq,
banana_req.BananaReq, banana_req.BananaReq,
], ],
'not': None
}
) )
# including extra parameters raises an exception # including extra parameters raises an exception

View File

@ -66,16 +66,11 @@ class TestGmFruit(unittest.TestCase):
# make sure that the ModelComposed class properties are correct # make sure that the ModelComposed class properties are correct
# model._composed_schemas stores the anyOf/allOf/oneOf info # model._composed_schemas stores the anyOf/allOf/oneOf info
self.assertEqual( self.assertEqual(
fruit._composed_schemas, fruit._any_of,
{ [
'anyOf': [
apple.Apple, apple.Apple,
banana.Banana, banana.Banana,
], ],
'allOf': [],
'oneOf': [],
'not': None
}
) )
# including extra parameters works # including extra parameters works

View File

@ -100,7 +100,7 @@ class TestValidateResults(unittest.TestCase):
frozendict(className="Dog", color="black"), validation_metadata=vm frozendict(className="Dog", color="black"), validation_metadata=vm
) )
assert path_to_schemas == { assert path_to_schemas == {
("args[0]",): set([Animal, Dog, Dog._composed_schemas['allOf'][1], frozendict]), ("args[0]",): set([Animal, Dog, Dog._all_of[1], frozendict]),
("args[0]", "className"): set([StrSchema, AnyTypeSchema, str]), ("args[0]", "className"): set([StrSchema, AnyTypeSchema, str]),
("args[0]", "color"): set([StrSchema, AnyTypeSchema, str]), ("args[0]", "color"): set([StrSchema, AnyTypeSchema, str]),
} }