mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 02:46:31 +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) {
|
||||
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 a new issue