mirror of https://github.com/MingweiSamuel/Riven
feat: srcgen for unknown/empty json objects
parent
d13ab723c2
commit
6ee5687437
|
@ -91,6 +91,9 @@ function stringifyType(prop, { endpoint = null, optional = false, fullpath = tru
|
||||||
return (owned ? (fullpath ? 'std::vec::' : '') + `Vec<${subprop}>` : `&[${subprop}]`);
|
return (owned ? (fullpath ? 'std::vec::' : '') + `Vec<${subprop}>` : `&[${subprop}]`);
|
||||||
case 'string': return (owned ? 'String' : '&str');
|
case 'string': return (owned ? 'String' : '&str');
|
||||||
case 'object':
|
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 }) + ', ' +
|
return 'std::collections::HashMap<' + stringifyType(prop['x-key'], { endpoint, optional, fullpath, owned }) + ', ' +
|
||||||
stringifyType(prop.additionalProperties, { endpoint, optional, fullpath, owned }) + '>';
|
stringifyType(prop.additionalProperties, { endpoint, optional, fullpath, owned }) + '>';
|
||||||
default: return prop.type;
|
default: return prop.type;
|
||||||
|
|
Loading…
Reference in New Issue