Skip to content

Commit 285901b

Browse files
fix: ensure dynamic structs in OR types are generated
1 parent 8813838 commit 285901b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/dynamic-param-interfaces.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,18 @@ const flushParamInterfaces = (
190190
true,
191191
),
192192
};
193-
// return Object.assign({}, paramPropertyType, { typeName: utils.genMethodString(module.exports, param, paramProperty, paramProperty.parameters, paramProperty.returns, true) })
194-
}
193+
} else if (typeof paramPropertyType.type === 'string' && paramPropertyType.type.toLowerCase() === 'object') {
194+
let argType = (paramProperty as any).__type || _.upperFirst(_.camelCase(paramProperty.name));
195+
if (API.some(a => a.name === argType)) {
196+
paramPropertyType.type = argType;
197+
debug(chalk.red(`Auto-correcting type from Object --> ${argType} in Interface: ${_.upperFirst(param.tName)} --- This should be fixed in the docs`));
198+
} else {
199+
nestedInterfacesToDeclare[argType] = paramPropertyType as ParamInterface;
200+
nestedInterfacesToDeclare[argType].name = paramProperty.name;
201+
nestedInterfacesToDeclare[argType].tName = argType;
202+
paramPropertyType.type = argType;
203+
}
204+
}
195205
return paramPropertyType;
196206
});
197207
}

0 commit comments

Comments
 (0)