mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 19:06:32 +00:00
feat: update codegen to consider model new x-alias
field
This commit is contained in:
parent
3d408d99ba
commit
c00c8abace
2 changed files with 7 additions and 3 deletions
|
@ -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 a new issue