riotapi-schema
riotapi-schema copied to clipboard
encryptedSummonerId description miss match
Hi, I have noticed, that the description of encryptedSummonerId
parameters
is miss matching, not sure if there is more like this, but I was wondering where the right place would be to overwrite it.
[
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "Summoner ID associated with the player"
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
}
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "The ID of the summoner."
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "Summoner ID"
}
]
Example:
https://developer.riotgames.com/apis#champion-mastery-v4/GET_getAllChampionMasteries
https://developer.riotgames.com/apis#spectator-v4/GET_getCurrentGameInfoBySummoner
Full list of what I found:
encryptedSummonerId
[
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "Summoner ID associated with the player"
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
}
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "The ID of the summoner."
},
{
"name": "encryptedSummonerId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "Summoner ID"
}
]
Authorization
[
{
"name": "Authorization",
"in": "header",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"required": true,
"schema": {
"type": "string",
"x-type": "String"
}
}
]
puuid
[
{
"name": "puuid",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
}
},
{
"name": "puuid",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "String"
}
},
{
"name": "encryptedPUUID",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
}
},
{
"name": "encryptedPUUID",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "Summoner ID"
}
]
tournamentId
[
{
"name": "tournamentId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32",
"x-type": "int"
}
},
{
"name": "tournamentId",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"format": "int64",
"x-type": "long"
},
"description": "The tournament ID"
}
]
queue
[
{
"name": "queue",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string",
"x-enum": "queueType",
"enum": [
"RANKED_SOLO_5x5",
"RANKED_FLEX_SR",
"RANKED_FLEX_TT"
]
}
},
{
"name": "queue",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string",
"x-enum": "queueType",
"enum": [
"RANKED_SOLO_5x5",
"RANKED_FLEX_SR",
"RANKED_FLEX_TT"
]
},
"description": "Note that the queue value must be a valid ranked queue."
}
]
division
[
{
"name": "division",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string",
"x-enum": "division",
"enum": [
"I",
"II",
"III",
"IV"
]
}
},
{
"name": "division",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string",
"enum": [
"I",
"II",
"III",
"IV"
]
}
}
]
tournamentCode
[
{
"name": "tournamentCode",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "The short code to look up lobby events for"
},
{
"name": "tournamentCode",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "The tournament code string."
},
{
"name": "tournamentCode",
"in": "path",
"required": true,
"schema": {
"type": "string",
"x-type": "string"
},
"description": "The tournament code to update"
}
]
Also, you could argue that in some cases it does make sense to have a different description
like tournamentCode: The tournament code to update
and The short code to look up lobby events for
but I don't like it.
Also, if there is no reason, puuid is split into encryptedPUUID
and puuid
this should all be puuid
You ran a script to detect field keys with different values?
not exactly, I needed a list of all possible parameters and ran a script, to gather all different parameter objects, and manually checkt the file, but I already found a few more errors by now.
But I could write a script, that will detect all mismatches.
This script should spot all mismatching parameter objects, but I did not implement the aliases yet, later this day I will most likely have time for it.
import ujson
schema = ujson.load(open('schema/openapi-3.0.0.json'))
paths = schema['paths']
params = {}
'''
aliases = [
[
'puuid',
'encryptedPUUID'
],
[
'summonerId',
'encryptedSummonerId'
],
[
'queueType',
'queue'
],
]
'''
for path, path_obj in schema['paths'].items():
methods = [method for method in path_obj if method.startswith(
'x-') or method.upper() in ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')]
for method in methods:
if 'parameters' in schema['paths'][path][method]:
for param in schema['paths'][path][method]['parameters']:
if param['name'] not in params:
params[param['name']] = []
if param not in params[param['name']]:
params[param['name']].append(param)
with open('mismatches.json', 'w') as f:
ujson.dump(params, f, indent=2, escape_forward_slashes=False)
OK, here is the extended version of the script:
import json
import requests
schema = requests.get('http://www.mingweisamuel.com/riotapi-schema/openapi-3.0.0.json').json()
# The first item in the alias pair is the one that will be mapped to
aliases = [
['puuid', 'encryptedPUUID'],
['summonerId', 'encryptedSummonerId'],
['queueType', 'queue'],
]
# Create a reverse mapping of aliases
reverse_aliases = {}
for alias_pair in aliases:
for alias in alias_pair:
reverse_aliases[alias] = alias_pair[0].lower()
'''
{
'puuid': 'puuid',
'encryptedPUUID': 'puuid',
'encryptedSummonerId': 'summonerid',
'summonerId': 'summonerid',
'queueType': 'queue',
'queue': 'queue'
}
'''
# Const to only check for parameters that are required
REQUIRED = True
# Const to only keep parameters in the list that have more than one entry
MULTIPLE = True
# Const to add the source of the parameter to the output
ADD_SOURCE = True
# Const to sort the output
SORT = True
SORT_BY = 'count' # 'name' or 'count'
params = {}
if ADD_SOURCE:
params_with_source = {}
for path, path_obj in schema['paths'].items():
methods = [method for method in path_obj.keys() if method.startswith(
'x-') or method.upper() in ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')]
for method in methods:
if 'parameters' in schema['paths'][path][method]:
for param in schema['paths'][path][method]['parameters']:
# Check if the parameter is required
if REQUIRED and not param.get('required', False):
continue
# Keep the original name for aliases
original_name = param['name']
if original_name in reverse_aliases:
original_name = reverse_aliases[original_name]
if original_name not in params:
params[original_name] = []
if ADD_SOURCE:
params_with_source[original_name] = []
# Check if the parameter is already in the list
if param not in params[original_name]:
params[original_name].append(param)
if ADD_SOURCE:
source = {'path': path, 'method': method}
param_with_source = param.copy()
param_with_source['source'] = source
params_with_source[original_name].append(param_with_source)
if ADD_SOURCE:
params = params_with_source
if MULTIPLE:
# Remove all parameters that have fewer than two entries:
for param in list(params.keys()):
if len(params[param]) < 2:
del params[param]
if SORT:
if SORT_BY == 'name':
params = dict(sorted(params.items(), key=lambda item: item[0]))
elif SORT_BY == 'count':
params = dict(
sorted(params.items(), key=lambda item: len(item[1]), reverse=True))
with open('mismatches.json', 'w') as f:
json.dump(params, f, indent=2)
Here are some pre generated outputs:
# Const to only check for parameters that are required
REQUIRED = True
# Const to only keep parameters in the list that have more than one entry
MULTIPLE = True
# Const to add the source of the parameter to the output
ADD_SOURCE = True
# Const to sort the output
SORT = True
SORT_BY = 'count' # 'name' or 'count'
https://gist.github.com/renja-grotemeyer/3d40886aadbf67d8aaf749c55e1febe5
# Const to only check for parameters that are required
REQUIRED = False
# Const to only keep parameters in the list that have more than one entry
MULTIPLE = True
# Const to add the source of the parameter to the output
ADD_SOURCE = True
# Const to sort the output
SORT = True
SORT_BY = 'count' # 'name' or 'count'
https://gist.github.com/renja-grotemeyer/1b3f13d977484a3014c4e94d65762583