All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
rust.model.mustache Maven / Gradle / Ivy
{{>partial_header}}
{{#models}}
{{#model}}
{{#description}}
/// {{{classname}}} : {{{description}}}
{{/description}}
{{!-- for enum schemas --}}
{{#isEnum}}
/// {{{description}}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum {{classname}} {
{{#allowableValues}}
{{#enumVars}}
#[serde(rename = "{{{value}}}")]
{{name}},
{{/enumVars}}{{/allowableValues}}
}
{{/isEnum}}
{{!-- for schemas that have a discriminator --}}
{{#discriminator}}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "{{{vendorExtensions.x-tag-name}}}")]
pub enum {{classname}} {
{{#vendorExtensions}}
{{#mappedModels}}
#[serde(rename="{{mappingName}}")]
{{modelName}} {
{{#vars}}
{{#description}}
/// {{{description}}}
{{/description}}
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
{{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
{{/vars}}
},
{{/mappedModels}}
{{/vendorExtensions}}
}
{{/discriminator}}
{{!-- for non-enum schemas --}}
{{^isEnum}}
{{^discriminator}}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct {{{classname}}} {
{{#vars}}
{{#description}}
/// {{{description}}}
{{/description}}
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
{{/vars}}
}
impl {{{classname}}} {
{{#description}}
/// {{{description}}}
{{/description}}
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
{{{classname}}} {
{{#vars}}
{{{name}}}{{^required}}{{#isListContainer}}: None{{/isListContainer}}{{#isMapContainer}}: None{{/isMapContainer}}{{^isContainer}}: None{{/isContainer}}{{/required}},
{{/vars}}
}
}
}
{{/discriminator}}
{{/isEnum}}
{{!-- for properties that are of enum type --}}
{{#vars}}
{{#isEnum}}
/// {{{description}}}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum {{enumName}} {
{{#allowableValues}}
{{#enumVars}}
#[serde(rename = "{{{value}}}")]
{{name}},
{{/enumVars}}
{{/allowableValues}}
}
{{/isEnum}}
{{/vars}}
{{/model}}
{{/models}}