All Downloads are FREE. Search and download functionalities are using the official Maven repository.

julia-client.partial_model_anyof.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{#anyOf}}{{#-first}}
@doc raw"""{{name}}{{#description}}
{{description}}{{/description}}

    {{classname}}(; value=nothing)
"""
mutable struct {{classname}} <: OpenAPI.AnyOfAPIModel
    value::Any # Union{ {{/-first}}{{/anyOf}}{{#anyOf}}{{^-first}}, {{/-first}}{{{.}}}{{/anyOf}}{{#anyOf}}{{#-last}} }
    {{classname}}() = new()
    {{classname}}(value) = new(value)
end # type {{classname}}{{/-last}}{{/anyOf}}

function OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol, json::Dict{String,Any})
    {{#discriminator}}discriminator = json["{{propertyName}}"]
    {{#hasDiscriminatorWithNonEmptyMapping}}{{#mappedModels}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{mappingName}}"
        return eval(Base.Meta.parse("{{modelName}}"))
    {{#-last}}end{{/-last}}{{/mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}}{{^hasDiscriminatorWithNonEmptyMapping}}{{#anyOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}"
        return eval(Base.Meta.parse("{{.}}"))
    {{#-last}}end{{/-last}}{{/anyOf}}{{/hasDiscriminatorWithNonEmptyMapping}}
    throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for {{classname}}")){{/discriminator}}{{^discriminator}}
    # no discriminator specified, can't determine the exact type
    return fieldtype({{classname}}, name){{/discriminator}}
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy