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

typescript-redux-query.modelOneOf.mustache Maven / Gradle / Ivy

{{#hasImports}}
import {
    {{#imports}}
    {{{.}}},
    {{{.}}}FromJSON,
    {{{.}}}ToJSON,
    {{/imports}}
} from './';

{{/hasImports}}
/**
 * @type {{classname}}{{#description}}
 * {{{description}}}{{/description}}
 * @export
 */
export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}};

{{#discriminator}}

export function {{classname}}FromJSON(json: any): {{classname}} {
  switch (json.{{propertyName}}) {
  {{#mappedModels}}
  case '{{mappingName}}': return {{modelName}}FromJSON(json);
  {{/mappedModels}}
  default: throw new Error("Unexpected {{propertyName}} value.");
  }
}

export function {{classname}}ToJSON(value?: {{classname}}): any {
    {{#hasVars}}
    if (value === undefined) {
        return undefined;
    }

    switch (value.{{propertyName}}) {
    {{#mappedModels}}
    case '{{mappingName}}': return {{modelName}}ToJSON(<{{modelName}}>value);
    {{/mappedModels}}
    default: throw new Error("Unexpected {{propertyName}} value.");
    }
    {{/hasVars}}
    {{^hasVars}}
    return value;
    {{/hasVars}}
}
{{/discriminator}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy