From 6ee5687437dac9f27f18a119dd0def15b0bd4602 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Fri, 19 Apr 2024 13:19:32 -0700 Subject: [PATCH] feat: srcgen for unknown/empty json objects --- riven/srcgen/dotUtils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/riven/srcgen/dotUtils.js b/riven/srcgen/dotUtils.js index de99a05..47e6c25 100644 --- a/riven/srcgen/dotUtils.js +++ b/riven/srcgen/dotUtils.js @@ -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' + } return 'std::collections::HashMap<' + stringifyType(prop['x-key'], { endpoint, optional, fullpath, owned }) + ', ' + stringifyType(prop.additionalProperties, { endpoint, optional, fullpath, owned }) + '>'; default: return prop.type;