mirror of https://github.com/MingweiSamuel/Riven
feat: update codegen to consider model new `x-alias` field
parent
3d408d99ba
commit
c00c8abace
|
@ -97,8 +97,12 @@ function stringifyType(prop, { endpoint = null, optional = false, fullpath = tru
|
|||
}
|
||||
}
|
||||
|
||||
function formatJsonProperty(name) {
|
||||
return `#[serde(rename = "${name}")]`;
|
||||
function formatJsonProperty(name, prop) {
|
||||
const alias = prop['x-alias'];
|
||||
if (alias)
|
||||
return `#[serde(rename = ${JSON.stringify(name)}, alias = ${JSON.stringify(alias)})]`;
|
||||
else
|
||||
return `#[serde(rename = ${JSON.stringify(name)})]`;
|
||||
}
|
||||
|
||||
function formatAddQueryParam(param) {
|
||||
|
|
|
@ -63,7 +63,7 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
|
|||
{{? prop.description }}
|
||||
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
|
||||
{{?}}
|
||||
{{= dotUtils.formatJsonProperty(propKey) }}
|
||||
{{= dotUtils.formatJsonProperty(propKey, prop) }}
|
||||
{{? optional }}
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
{{?}}
|
||||
|
|
Loading…
Reference in New Issue