Regen for Viego, val-ranked-v1

pull/23/head
Mingwei Samuel 2021-01-16 14:16:56 -08:00
parent 6c3d51a071
commit 19eeeae637
6 changed files with 4244 additions and 4159 deletions

View File

@ -298,6 +298,8 @@ pub enum Champion {
#[strum(to_string="Vel'Koz", serialize="Velkoz")] VelKoz = 161, #[strum(to_string="Vel'Koz", serialize="Velkoz")] VelKoz = 161,
/// Vi (`Vi`, 254). /// Vi (`Vi`, 254).
#[strum(to_string="Vi")] Vi = 254, #[strum(to_string="Vi")] Vi = 254,
/// Viego (`Viego`, 234).
#[strum(to_string="Viego")] Viego = 234,
/// Viktor (`Viktor`, 112). /// Viktor (`Viktor`, 112).
#[strum(to_string="Viktor")] Viktor = 112, #[strum(to_string="Viktor")] Viktor = 112,
/// Vladimir (`Vladimir`, 8). /// Vladimir (`Vladimir`, 8).
@ -497,6 +499,7 @@ impl Champion {
Self::Veigar => "Veigar", Self::Veigar => "Veigar",
Self::VelKoz => "Velkoz", Self::VelKoz => "Velkoz",
Self::Vi => "Vi", Self::Vi => "Vi",
Self::Viego => "Viego",
Self::Viktor => "Viktor", Self::Viktor => "Viktor",
Self::Vladimir => "Vladimir", Self::Vladimir => "Vladimir",
Self::Volibear => "Volibear", Self::Volibear => "Volibear",

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version ece6f45a4d6232f4e9940219258f1bd3ae1fee6d // Version 0c5382b0f4b74c9e27cee3043c02faa4acef0f25
//! Metadata about the Riot API and Riven. //! Metadata about the Riot API and Riven.
//! //!
@ -76,6 +76,7 @@ lazy_static! {
map.insert("/val/match/v1/matches/{matchId}", "val-match-v1.getMatch"); map.insert("/val/match/v1/matches/{matchId}", "val-match-v1.getMatch");
map.insert("/val/match/v1/matchlists/by-puuid/{puuid}", "val-match-v1.getMatchlist"); map.insert("/val/match/v1/matchlists/by-puuid/{puuid}", "val-match-v1.getMatchlist");
map.insert("/val/match/v1/recent-matches/by-queue/{queue}", "val-match-v1.getRecent"); map.insert("/val/match/v1/recent-matches/by-queue/{queue}", "val-match-v1.getRecent");
map.insert("/val/ranked/v1/leaderboards/by-act/{actId}", "val-ranked-v1.getLeaderboard");
map.insert("/val/status/v1/platform-data", "val-status-v1.getPlatformData"); map.insert("/val/status/v1/platform-data", "val-status-v1.getPlatformData");
map map
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,164 +1,164 @@
{{ {{
const spec = require('./.spec.json'); const spec = require('./.spec.json');
const dotUtils = require('./dotUtils.js'); const dotUtils = require('./dotUtils.js');
}}{{= dotUtils.preamble() }} }}{{= dotUtils.preamble() }}
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version {{= spec.info.version }} // Version {{= spec.info.version }}
//! Automatically generated endpoint handles. //! Automatically generated endpoint handles.
use crate::models::*; use crate::models::*;
use std::future::Future; use std::future::Future;
use std::vec::Vec; use std::vec::Vec;
use url::form_urlencoded::Serializer; use url::form_urlencoded::Serializer;
use crate::Result; use crate::Result;
use crate::consts::Region; use crate::consts::Region;
use crate::riot_api::RiotApi; use crate::riot_api::RiotApi;
{{ {{
const endpointGroups = {}; const endpointGroups = {};
for (let path of Object.entries(spec.paths)) { for (let path of Object.entries(spec.paths)) {
let ep = path[1]['x-endpoint']; let ep = path[1]['x-endpoint'];
endpointGroups[ep] = endpointGroups[ep] || []; endpointGroups[ep] = endpointGroups[ep] || [];
endpointGroups[ep].push(path); endpointGroups[ep].push(path);
} }
}} }}
impl RiotApi { impl RiotApi {
{{ {{
for (const endpointName of Object.keys(endpointGroups)) { for (const endpointName of Object.keys(endpointGroups)) {
const method = dotUtils.changeCase.snakeCase(endpointName); const method = dotUtils.changeCase.snakeCase(endpointName);
const type = dotUtils.changeCase.pascalCase(endpointName); const type = dotUtils.changeCase.pascalCase(endpointName);
}} }}
/// Returns a handle for accessing [{{= type }}](crate::endpoints::{{= type }}) endpoints. /// Returns a handle for accessing [{{= type }}](crate::endpoints::{{= type }}) endpoints.
/// # Riot Developer API Reference /// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a> /// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a>
/// ///
/// Note: this method is automatically generated. /// Note: this method is automatically generated.
#[inline] #[inline]
pub fn {{= method }}(&self) -> {{= type }} { pub fn {{= method }}(&self) -> {{= type }} {
{{= type }} { base: self } {{= type }} { base: self }
} }
{{ {{
} }
}} }}
} }
{{ {{
for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) { for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) {
let endpoint = dotUtils.changeCase.pascalCase(endpointName); let endpoint = dotUtils.changeCase.pascalCase(endpointName);
const endpoint_snake_case = dotUtils.changeCase.snakeCase(endpointName); const endpoint_snake_case = dotUtils.changeCase.snakeCase(endpointName);
}} }}
/// {{= endpoint }} endpoints handle, accessed by calling [`{{= endpoint_snake_case }}()`](crate::RiotApi::{{= endpoint_snake_case }}) on a [`RiotApi`](crate::RiotApi) instance. /// {{= endpoint }} endpoints handle, accessed by calling [`{{= endpoint_snake_case }}()`](crate::RiotApi::{{= endpoint_snake_case }}) on a [`RiotApi`](crate::RiotApi) instance.
/// # Riot Developer API Reference /// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a> /// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
pub struct {{= endpoint }}<'a> { pub struct {{= endpoint }}<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
impl<'a> {{= endpoint }}<'a> { impl<'a> {{= endpoint }}<'a> {
{{ {{
for (let [ route, path ] of endpointMethods) for (let [ route, path ] of endpointMethods)
{ {
let get = path.get; let get = path.get;
if (!get) if (!get)
continue; continue;
let operationId = get.operationId; let operationId = get.operationId;
let method = dotUtils.changeCase.snakeCase(operationId.slice(operationId.indexOf('.') + 1)); let method = dotUtils.changeCase.snakeCase(operationId.slice(operationId.indexOf('.') + 1));
let jsonInfo = get.responses['200'].content['application/json']; let jsonInfo = get.responses['200'].content['application/json'];
let returnOptional = !!get['x-nullable-404']; let returnOptional = !!get['x-nullable-404'];
let parseType = dotUtils.stringifyType(jsonInfo.schema, { endpoint, fullpath: false }); let parseType = dotUtils.stringifyType(jsonInfo.schema, { endpoint, fullpath: false });
let returnType = returnOptional ? `Option<${parseType}>` : parseType; let returnType = returnOptional ? `Option<${parseType}>` : parseType;
/* Cases if not rate limited. */ /* Cases if not rate limited. */
let rateLimitExcluded = get['x-app-rate-limit-excluded'] ? true : false; let rateLimitExcluded = get['x-app-rate-limit-excluded'] ? true : false;
/* Description processing. */ /* Description processing. */
let descArr = get.description.split('\n'); let descArr = get.description.split('\n');
/* Build argument comment & string. */ /* Build argument comment & string. */
let argBuilder = []; let argBuilder = [];
let makeParamCode = ''; let makeParamCode = '';
let allParams = get.parameters; let allParams = get.parameters;
let queryParams = []; let queryParams = [];
let routeArgument = dotUtils.formatRouteArgument(route); let routeArgument = dotUtils.formatRouteArgument(route);
if (allParams && allParams.length) if (allParams && allParams.length)
{ {
let pathParams = allParams.filter(p => 'path' === p.in) let pathParams = allParams.filter(p => 'path' === p.in)
.sortBy(({ name }) => route.indexOf(name)); .sortBy(({ name }) => route.indexOf(name));
let reqParams = allParams.filter(p => 'path' !== p.in && p.required); let reqParams = allParams.filter(p => 'path' !== p.in && p.required);
let optParams = allParams.filter(p => 'path' !== p.in && !p.required) let optParams = allParams.filter(p => 'path' !== p.in && !p.required)
.sortBy(({ name }) => { .sortBy(({ name }) => {
let match = /(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)/.exec(name); let match = /(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)/.exec(name);
return match.slice(1).reverse().join(''); return match.slice(1).reverse().join('');
}); });
queryParams = reqParams.concat(optParams); queryParams = reqParams.concat(optParams);
for (let paramList of [ pathParams, reqParams, optParams ]) for (let paramList of [ pathParams, reqParams, optParams ])
{ {
let required = paramList === pathParams; let required = paramList === pathParams;
for (let param of paramList) for (let param of paramList)
{ {
argBuilder.push(', ', dotUtils.changeCase.snakeCase(param.name), ': ', argBuilder.push(', ', dotUtils.changeCase.snakeCase(param.name), ': ',
dotUtils.stringifyType(param.schema, { endpoint, optional: !required, owned: false })); dotUtils.stringifyType(param.schema, { endpoint, optional: !required, owned: false }));
} }
} }
routeArgument = dotUtils.formatRouteArgument(route, pathParams); routeArgument = dotUtils.formatRouteArgument(route, pathParams);
} }
for (var descLine of descArr) for (var descLine of descArr)
{ {
}} }}
///{{= descLine ? ' ' + descLine : '' }} ///{{= descLine ? ' ' + descLine : '' }}
{{ {{
} }
}} }}
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
{{ {{
if (allParams) if (allParams)
{ {
for (let param of allParams) for (let param of allParams)
{ {
}} }}
/// * `{{= param.name }}`{{= param.required ? '' : ' (optional)' }}{{= param.description ? ' - ' + param.description : ''}} /// * `{{= param.name }}`{{= param.required ? '' : ' (optional)' }}{{= param.description ? ' - ' + param.description : ''}}
{{ {{
} }
} }
}} }}
/// # Riot Developer API Reference /// # Riot Developer API Reference
/// <a href="{{= get.externalDocs.url }}" target="_blank">`{{= operationId }}`</a> /// <a href="{{= get.externalDocs.url }}" target="_blank">`{{= operationId }}`</a>
/// ///
/// Note: this method is automatically generated. /// Note: this method is automatically generated.
pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }}) pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }})
-> impl Future<Output = Result<{{= returnType }}>> + 'a -> impl Future<Output = Result<{{= returnType }}>> + 'a
{ {
{{? queryParams.length }} {{? queryParams.length }}
let mut query_params = Serializer::new(String::new()); let mut query_params = Serializer::new(String::new());
{{ {{
for (let queryParam of queryParams) for (let queryParam of queryParams)
{ {
}} }}
{{= dotUtils.formatAddQueryParam(queryParam) }}; {{= dotUtils.formatAddQueryParam(queryParam) }};
{{ {{
} }
}} }}
let query_string = query_params.finish(); let query_string = query_params.finish();
{{?}} {{?}}
let path_string = {{= routeArgument }}; let path_string = {{= routeArgument }};
self.base.get{{= returnOptional ? '_optional' : '' }}::<{{= parseType }}>("{{= operationId }}", region.into(), path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }}) self.base.get{{= returnOptional ? '_optional' : '' }}::<{{= parseType }}>("{{= operationId }}", region.into(), path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }})
} }
{{ {{
} }
}} }}
} }
{{ {{
} }
}} }}

View File

@ -1,70 +1,70 @@
{{ {{
const spec = require('./.spec.json'); const spec = require('./.spec.json');
const dotUtils = require('./dotUtils.js'); const dotUtils = require('./dotUtils.js');
}}{{= dotUtils.preamble() }} }}{{= dotUtils.preamble() }}
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version {{= spec.info.version }} // Version {{= spec.info.version }}
//! Data transfer structs. //! Data transfer structs.
//! //!
//! Separated into separate modules for each endpoint. //! Separated into separate modules for each endpoint.
//! Several modules contain structs with the same name, so be sure to use the right ones. //! Several modules contain structs with the same name, so be sure to use the right ones.
//! //!
//! Note: these modules are automatically generated. //! Note: these modules are automatically generated.
{{ {{
let schemas = spec.components.schemas; let schemas = spec.components.schemas;
let schemaKeyByEndpoint = Object.keys(schemas) let schemaKeyByEndpoint = Object.keys(schemas)
.filter(schemaKey => 'Error' != schemaKey) .filter(schemaKey => 'Error' != schemaKey)
.groupBy(schemaKey => schemaKey.split('.')[0]); .groupBy(schemaKey => schemaKey.split('.')[0]);
for (let [endpoint, schemaKeyGroup] of schemaKeyByEndpoint) { for (let [endpoint, schemaKeyGroup] of schemaKeyByEndpoint) {
const endpoint_pascal_case = dotUtils.changeCase.pascalCase(endpoint); const endpoint_pascal_case = dotUtils.changeCase.pascalCase(endpoint);
}} }}
/// Data structs used by [`{{= endpoint_pascal_case }}`](crate::endpoints::{{= endpoint_pascal_case }}). /// Data structs used by [`{{= endpoint_pascal_case }}`](crate::endpoints::{{= endpoint_pascal_case }}).
/// ///
/// Note: this module is automatically generated. /// Note: this module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} { pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
{{ {{
for (let schemaKey of schemaKeyGroup) { for (let schemaKey of schemaKeyGroup) {
const [, rawSchemaName] = schemaKey.split('.'); const [, rawSchemaName] = schemaKey.split('.');
const schemaName = dotUtils.normalizeSchemaName(rawSchemaName); const schemaName = dotUtils.normalizeSchemaName(rawSchemaName);
const schema = schemas[schemaKey]; const schema = schemas[schemaKey];
const props = schema.properties; const props = schema.properties;
const requiredSet = new Set(schema.required); const requiredSet = new Set(schema.required);
}} }}
/// {{= schemaName }} data object. /// {{= schemaName }} data object.
{{? schema.description }} {{? schema.description }}
/// # Description /// # Description
/// {{= schema.description }} /// {{= schema.description }}
/// ///
/// Note: This struct is automatically generated /// Note: This struct is automatically generated
{{?}} {{?}}
#[derive(Debug)] #[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
pub struct {{= schemaName }} { pub struct {{= schemaName }} {
{{ {{
for (let [ propKey, prop ] of Object.entries(props)) for (let [ propKey, prop ] of Object.entries(props))
{ {
const name = dotUtils.normalizePropName(propKey); const name = dotUtils.normalizePropName(propKey);
const required = requiredSet.has(propKey); const required = requiredSet.has(propKey);
}} }}
{{? 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) }}
pub {{= name }}: {{= dotUtils.stringifyType(prop, { optional: !required }) }}, pub {{= name }}: {{= dotUtils.stringifyType(prop, { optional: !required }) }},
{{ {{
} }
}} }}
} }
{{ {{
} }
}} }}
} }
{{ {{
} }
}} }}