[typescript-redux-query] Add proper modelling of allOf usage. (#4780)

This commit is contained in:
Pete Johanson
2019-12-12 15:05:47 -05:00
committed by Esteban Gehring
parent 1e995cacdc
commit db2c8e843e
3 changed files with 44 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
{{#hasImports}}
import {
{{#imports}}
{{{.}}},
{{{.}}}FromJSON,
{{{.}}}ToJSON,
{{/imports}}
} from './';
{{/hasImports}}
/**
* @type {{classname}}{{#description}}
* {{{description}}}{{/description}}
* @export
*/
export interface {{classname}} extends {{#allOf}}{{{.}}}{{^-last}}, {{/-last}}{{/allOf}} {
}
export function {{classname}}FromJSON(json: any): {{classname}} {
return {
{{#allOf}}
...{{.}}FromJSON(json),
{{/allOf}}
};
}
export function {{classname}}ToJSON(value?: {{classname}}): any {
if (value === undefined) {
return undefined;
}
return {
{{#allOf}}
...{{.}}ToJSON(value),
{{/allOf}}
};
}

View File

@@ -34,7 +34,7 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
switch (value.{{propertyName}}) {
{{#mappedModels}}
case '{{mappingName}}': return {{modelName}}ToJSON(value);
case '{{mappingName}}': return {{modelName}}ToJSON(<{{modelName}}>value);
{{/mappedModels}}
default: throw new Error("Unexpected {{propertyName}} value.");
}

View File

@@ -11,8 +11,15 @@
{{>modelOneOf}}
{{/-first}}
{{/oneOf}}
{{#allOf}}
{{#-first}}
{{>modelAllOf}}
{{/-first}}
{{/allOf}}
{{^oneOf}}
{{^allOf}}
{{>modelGeneric}}
{{/allOf}}
{{/oneOf}}
{{/isEnum}}
{{/model}}