add free form object support to ts fetch (#2453)

This commit is contained in:
William Cheng 2019-04-05 07:20:26 +08:00 committed by GitHub
parent d9ae80f76f
commit 9368bea130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -84,7 +84,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
"any",
"File",
"Error",
"Map"
"Map",
"object"
));
languageGenericTypes = new HashSet<String>(Arrays.asList(
@ -106,7 +107,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
typeMapping.put("short", "number");
typeMapping.put("char", "string");
typeMapping.put("double", "number");
typeMapping.put("object", "any");
typeMapping.put("object", "object");
typeMapping.put("integer", "number");
typeMapping.put("Map", "any");
typeMapping.put("map", "any");

View File

@ -50,7 +50,12 @@ export function {{classname}}FromJSON(json: any): {{classname}} {
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}(json['{{baseName}}'] as Array<any>).map({{#items}}{{datatype}}{{/items}}FromJSON),
{{/isContainer}}
{{^isContainer}}
{{^isFreeFormObject}}
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}{{datatype}}FromJSON(json['{{baseName}}']),
{{/isFreeFormObject}}
{{#isFreeFormObject}}
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}json['{{baseName}}'],
{{/isFreeFormObject}}
{{/isContainer}}
{{/isPrimitiveType}}
{{/allVars}}
@ -77,7 +82,12 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
'{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}(value.{{name}} as Array<any>).map({{#items}}{{datatype}}{{/items}}ToJSON),
{{/isContainer}}
{{^isContainer}}
{{^isFreeFormObject}}
'{{baseName}}': {{datatype}}ToJSON(value.{{name}}),
{{/isFreeFormObject}}
{{#isFreeFormObject}}
'{{baseName}}': value.{{name}},
{{/isFreeFormObject}}
{{/isContainer}}
{{/isPrimitiveType}}
{{/isReadOnly}}