mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 10:56:34 +00:00
feat: srcgen for unknown/empty json objects
This commit is contained in:
parent
d13ab723c2
commit
6ee5687437
1 changed files with 3 additions and 0 deletions
|
@ -91,6 +91,9 @@ function stringifyType(prop, { endpoint = null, optional = false, fullpath = tru
|
|||
return (owned ? (fullpath ? 'std::vec::' : '') + `Vec<${subprop}>` : `&[${subprop}]`);
|
||||
case 'string': return (owned ? 'String' : '&str');
|
||||
case 'object':
|
||||
if (1 === Object.keys(prop).length) { // Only `{ "type": "object" }`.
|
||||
return 'serde_json::Map<String, serde_json::Value>'
|
||||
}
|
||||
return 'std::collections::HashMap<' + stringifyType(prop['x-key'], { endpoint, optional, fullpath, owned }) + ', ' +
|
||||
stringifyType(prop.additionalProperties, { endpoint, optional, fullpath, owned }) + '>';
|
||||
default: return prop.type;
|
||||
|
|
Loading…
Reference in a new issue