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) {
|
function formatJsonProperty(name, prop) {
|
||||||
return `#[serde(rename = "${name}")]`;
|
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) {
|
function formatAddQueryParam(param) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
|
||||||
{{? 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 /// ') }}
|
||||||
{{?}}
|
{{?}}
|
||||||
{{= dotUtils.formatJsonProperty(propKey) }}
|
{{= dotUtils.formatJsonProperty(propKey, prop) }}
|
||||||
{{? optional }}
|
{{? optional }}
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
{{?}}
|
{{?}}
|
||||||
|
|
Loading…
Reference in New Issue