2019-10-19 02:25:09 -07:00
|
|
|
{{
|
|
|
|
const spec = require('./.spec.json');
|
|
|
|
const dotUtils = require('./dotUtils.js');
|
2019-10-23 00:49:02 -07:00
|
|
|
}}{{= dotUtils.preamble() }}
|
2019-10-19 02:25:09 -07:00
|
|
|
|
|
|
|
// http://www.mingweisamuel.com/riotapi-schema/tool/
|
|
|
|
// Version {{= spec.info.version }}
|
|
|
|
|
2019-11-03 10:48:45 -08:00
|
|
|
//! Automatically generated data transfer structs.
|
|
|
|
|
2019-10-19 02:25:09 -07:00
|
|
|
{{
|
|
|
|
let schemas = spec.components.schemas;
|
|
|
|
let schemaKeyByEndpoint = Object.keys(schemas)
|
|
|
|
.filter(schemaKey => 'Error' != schemaKey)
|
|
|
|
.groupBy(schemaKey => schemaKey.split('.')[0]);
|
|
|
|
|
|
|
|
for (let [endpoint, schemaKeyGroup] of schemaKeyByEndpoint) {
|
|
|
|
}}
|
2019-11-03 10:36:51 -08:00
|
|
|
/// {{= dotUtils.changeCase.pascalCase(endpoint) }} data objects. This module is automatically generated.
|
2019-10-19 02:25:09 -07:00
|
|
|
#[allow(dead_code)]
|
2019-10-19 14:39:53 -07:00
|
|
|
pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
|
2019-10-19 02:25:09 -07:00
|
|
|
{{
|
|
|
|
for (let schemaKey of schemaKeyGroup) {
|
2019-11-03 10:36:51 -08:00
|
|
|
const [, rawSchemaName] = schemaKey.split('.');
|
2019-10-31 01:09:20 -07:00
|
|
|
const schemaName = dotUtils.normalizeSchemaName(rawSchemaName);
|
|
|
|
const schema = schemas[schemaKey];
|
|
|
|
const props = schema.properties;
|
|
|
|
const requiredSet = new Set(schema.required);
|
2019-10-19 02:25:09 -07:00
|
|
|
}}
|
2019-10-22 00:01:11 -07:00
|
|
|
/// {{= schemaName }} data object. This struct is automatically generated.
|
2019-10-19 02:25:09 -07:00
|
|
|
{{? schema.description }}
|
|
|
|
/// # Description
|
|
|
|
/// {{= schema.description }}
|
|
|
|
{{?}}
|
2019-10-19 14:39:53 -07:00
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(serde::Serialize, serde::Deserialize)]
|
2019-10-19 02:25:09 -07:00
|
|
|
pub struct {{= schemaName }} {
|
2019-10-19 14:39:53 -07:00
|
|
|
{{
|
|
|
|
for (let [ propKey, prop ] of Object.entries(props))
|
|
|
|
{
|
2019-10-31 01:09:20 -07:00
|
|
|
const name = dotUtils.normalizePropName(propKey);
|
|
|
|
const required = requiredSet.has(propKey);
|
2019-10-19 14:39:53 -07:00
|
|
|
}}
|
|
|
|
{{? prop.description }}
|
2019-10-27 01:56:22 -07:00
|
|
|
/// {{= prop.description.split('\n').map(x => x.trim()).join('<br>\r\n /// ') }}
|
2019-10-19 14:39:53 -07:00
|
|
|
{{?}}
|
|
|
|
{{= dotUtils.formatJsonProperty(propKey) }}
|
2019-10-31 01:09:20 -07:00
|
|
|
pub {{= name }}: {{= dotUtils.stringifyType(prop, { optional: !required }) }},
|
2019-10-19 14:39:53 -07:00
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
2019-10-19 02:25:09 -07:00
|
|
|
}
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
{{
|
|
|
|
}
|
|
|
|
}}
|