forked from loafle/openapi-generator-original
[typescript-redux-query] Add proper modelling of allOf usage. (#4780)
This commit is contained in:
committed by
Esteban Gehring
parent
1e995cacdc
commit
db2c8e843e
36
modules/openapi-generator/src/main/resources/typescript-redux-query/modelAllOf.mustache
vendored
Normal file
36
modules/openapi-generator/src/main/resources/typescript-redux-query/modelAllOf.mustache
vendored
Normal 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}}
|
||||
};
|
||||
}
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
@@ -11,8 +11,15 @@
|
||||
{{>modelOneOf}}
|
||||
{{/-first}}
|
||||
{{/oneOf}}
|
||||
{{#allOf}}
|
||||
{{#-first}}
|
||||
{{>modelAllOf}}
|
||||
{{/-first}}
|
||||
{{/allOf}}
|
||||
{{^oneOf}}
|
||||
{{^allOf}}
|
||||
{{>modelGeneric}}
|
||||
{{/allOf}}
|
||||
{{/oneOf}}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
||||
Reference in New Issue
Block a user