Skip to content

Commit 47b23a6

Browse files
authored
[codegen] Support generic object property (#22)
1 parent 1265a4b commit 47b23a6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

codegen/src/codegen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class Codegen {
7777
`#ifndef RPCINTERFACE_H
7878
#define RPCINTERFACE_H\n
7979
#include <jsonrpccxx/server.hpp>
80+
#include <map>
8081
#include <optional>
8182
#include <string>
8283
#include <vector>\n
@@ -215,6 +216,10 @@ using namespace jsonrpccxx;\n`;
215216
if (item.properties) {
216217
tsType = this.getTypeName(name, suffix);
217218
cppType = `${prefix ?? ''}${tsType}`;
219+
} else if (item.additionalProperties) {
220+
const {cpp, ts} = this.getType(name, item.additionalProperties, suffix);
221+
tsType = `Record<string, ${ts}>`;
222+
cppType = `map<string, ${cpp}>`;
218223
} else {
219224
console.error('unknown type:', item.type);
220225
}

0 commit comments

Comments
 (0)