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

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

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

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

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}}{{#oneOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}"
        return eval(Base.Meta.parse("{{.}}"))
    {{#-last}}end{{/-last}}{{/oneOf}}{{/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