
python.model_templates.composed_schemas.handlebars Maven / Gradle / Ivy
{{#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}}
{{#with composedSchemas}}
{{#if allOf}}
@classmethod
@functools.lru_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 [
{{#each allOf}}
{{#if complexType}}
{{complexType}},
{{else}}
{{#if nameInSnakeCase}}
cls.{{name}},
{{else}}
cls.{{baseName}},
{{/if}}
{{/if}}
{{/each}}
]
{{/if}}
{{#if oneOf}}
@classmethod
@functools.lru_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}}
{{#if complexType}}
{{complexType}},
{{else}}
{{#if nameInSnakeCase}}
cls.{{name}},
{{else}}
cls.{{baseName}},
{{/if}}
{{/if}}
{{/each}}
]
{{/if}}
{{#if anyOf}}
@classmethod
@functools.lru_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}}
{{#if complexType}}
{{complexType}},
{{else}}
{{#if nameInSnakeCase}}
cls.{{name}},
{{else}}
cls.{{baseName}},
{{/if}}
{{/if}}
{{/each}}
]
{{/if}}
{{#if not}}
{{#with not}}
{{#if complexType}}
@staticmethod
def {{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}() -> typing.Type['{{complexType}}']:
return {{complexType}}
{{else}}
{{> model_templates/schema }}
{{/if}}
{{/with}}
{{/if}}
{{/with}}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy