mirror of https://github.com/MingweiSamuel/Riven
fix: codgen handle field name collisions
parent
1ce54275ce
commit
ca6149b0ed
|
@ -49,10 +49,16 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
|
||||||
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
|
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
|
||||||
pub struct {{= schemaName }} {
|
pub struct {{= schemaName }} {
|
||||||
{{
|
{{
|
||||||
|
const usedNames = new Set();
|
||||||
for (let [ propKey, prop ] of Object.entries(props))
|
for (let [ propKey, prop ] of Object.entries(props))
|
||||||
{
|
{
|
||||||
const name = dotUtils.normalizePropName(propKey);
|
|
||||||
const optional = !requiredSet.has(propKey);
|
const optional = !requiredSet.has(propKey);
|
||||||
|
|
||||||
|
let name = dotUtils.normalizePropName(propKey);
|
||||||
|
while (usedNames.has(name)) {
|
||||||
|
name += '_';
|
||||||
|
}
|
||||||
|
usedNames.add(name);
|
||||||
}}
|
}}
|
||||||
{{? prop.description }}
|
{{? prop.description }}
|
||||||
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
|
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
|
||||||
|
|
Loading…
Reference in New Issue