mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 19:06:32 +00:00
fix: codgen handle field name collisions
This commit is contained in:
parent
1ce54275ce
commit
ca6149b0ed
1 changed files with 7 additions and 1 deletions
|
@ -49,10 +49,16 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
|
|||
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
|
||||
pub struct {{= schemaName }} {
|
||||
{{
|
||||
const usedNames = new Set();
|
||||
for (let [ propKey, prop ] of Object.entries(props))
|
||||
{
|
||||
const name = dotUtils.normalizePropName(propKey);
|
||||
const optional = !requiredSet.has(propKey);
|
||||
|
||||
let name = dotUtils.normalizePropName(propKey);
|
||||
while (usedNames.has(name)) {
|
||||
name += '_';
|
||||
}
|
||||
usedNames.add(name);
|
||||
}}
|
||||
{{? prop.description }}
|
||||
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
|
||||
|
|
Loading…
Reference in a new issue