This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
771 additions
and
604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 64 additions & 64 deletions
128
RiotGames.Client.CodeGeneration/RiotGamesApi/RiotApiModelsHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
using MingweiSamuel; | ||
using MingweiSamuel.RiotApi; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace RiotGames.Client.CodeGeneration.RiotGamesApi | ||
{ | ||
internal static class RiotApiModelsHelper | ||
{ | ||
public static string GetTypeNameFromRef(string @ref) | ||
{ | ||
@ref = RiotApiHacks.EndpointsWithDuplicateSchemas | ||
.FirstOrDefault(kvp => @ref.Contains(kvp.Key)) | ||
.Value + @ref?.Split('.')?.Last(); | ||
return OpenApiComponentHelper.GetTypeNameFromRef(@ref); | ||
} | ||
|
||
public static string GetTypeName(this RiotApiSchemaObject schema) | ||
{ | ||
if (schema.Ref != null) | ||
return GetTypeNameFromRef(schema.Ref); | ||
else if (schema.XType == null && schema.Type == null) | ||
Debugger.Break(); | ||
else | ||
switch (schema.Type) | ||
{ | ||
case "array": | ||
return (schema.XType.Remove("Set[").Remove("List[").TrimEnd(']')).RemoveDtoSuffix() + "[]"; | ||
case "integer": | ||
if (schema.XType == null) | ||
throw new Exception("Schema.XType is null for some reason."); | ||
return schema.XType; | ||
case "string": | ||
return schema.Type; | ||
} | ||
|
||
throw new Exception("Couldn't figure out the response type."); | ||
} | ||
|
||
public static string GetTypeName(this OpenApiComponentPropertyObject property) | ||
{ | ||
if (property.Type == "array" || (property as RiotApiComponentPropertyObject)?.XType == "array") | ||
return GetTypeName(property.Items) + "[]"; | ||
|
||
if (property.Ref != null) | ||
return GetTypeNameFromRef(property.Ref); | ||
|
||
var name = ((property as RiotApiComponentPropertyObject)?.XType ?? property.Format ?? property.Type).RemoveDtoSuffix(); | ||
|
||
return name switch | ||
{ | ||
"int32" => "int", | ||
"int64" => "long", | ||
"boolean" => "bool", | ||
_ => name, | ||
}; | ||
} | ||
|
||
} | ||
} | ||
using MingweiSamuel; | ||
using MingweiSamuel.RiotApi; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace RiotGames.Client.CodeGeneration.RiotGamesApi | ||
{ | ||
internal static class RiotApiModelsHelper | ||
{ | ||
public static string GetTypeNameFromRef(string @ref) | ||
{ | ||
@ref = RiotApiHacks.EndpointsWithDuplicateSchemas | ||
.FirstOrDefault(kvp => @ref.Contains(kvp.Key)) | ||
.Value + @ref?.Split('.')?.Last(); | ||
return OpenApiComponentHelper.GetTypeNameFromRef(@ref); | ||
} | ||
|
||
public static string GetTypeName(this RiotApiSchemaObject schema, Client client) | ||
{ | ||
if (schema.Ref != null) | ||
return GetTypeNameFromRef(schema.Ref); | ||
else if (schema.XType == null && schema.Type == null) | ||
Debugger.Break(); | ||
else | ||
switch (schema.Type) | ||
{ | ||
case "array": | ||
return $"{client}Collection<{schema.XType.RemoveStart("Set[").RemoveStart("List[").TrimEnd(']').RemoveDtoSuffix()}>"; | ||
case "integer": | ||
if (schema.XType == null) | ||
throw new Exception("Schema.XType is null for some reason."); | ||
return schema.XType; | ||
case "string": | ||
return schema.Type; | ||
} | ||
|
||
throw new Exception("Couldn't figure out the response type."); | ||
} | ||
|
||
public static string GetTypeName(this OpenApiComponentPropertyObject property, Client client) | ||
{ | ||
if (property.Type == "array" || (property as RiotApiComponentPropertyObject)?.XType == "array") | ||
return $"{client}Collection<{GetTypeName(property.Items, client)}>"; | ||
|
||
if (property.Ref != null) | ||
return GetTypeNameFromRef(property.Ref); | ||
|
||
var name = ((property as RiotApiComponentPropertyObject)?.XType ?? property.Format ?? property.Type).RemoveDtoSuffix(); | ||
|
||
return name switch | ||
{ | ||
"int32" => "int", | ||
"int64" => "long", | ||
"boolean" => "bool", | ||
_ => name, | ||
}; | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
using Camille.Enums; | ||
|
||
namespace RiotGames | ||
{ | ||
internal class RiotGamesApiHttpClient<TObjectBase> : RiotGamesHttpClient<TObjectBase> | ||
{ | ||
private RiotGamesApiHttpClient(string apiKey, string apiSubDomain) | ||
{ | ||
HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-Token", apiKey); | ||
HttpClient.BaseAddress = new Uri($"https://{apiSubDomain}.api.riotgames.com"); | ||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, RegionalRoute region) : this(apiKey, region.ToString().ToLower()) | ||
{ | ||
|
||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, PlatformRoute platform) : this(apiKey, platform.ToString().ToLower()) | ||
{ | ||
|
||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, ValPlatformRoute platform) : this(apiKey, platform.ToString().ToLower()) | ||
{ | ||
|
||
} | ||
} | ||
using Camille.Enums; | ||
|
||
namespace RiotGames | ||
{ | ||
internal class RiotGamesApiHttpClient<TObjectBase> : RiotGamesHttpClient<TObjectBase> | ||
{ | ||
private RiotGamesApiHttpClient(string apiKey, string apiSubDomain) | ||
{ | ||
HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Riot-Token", apiKey); | ||
HttpClient.BaseAddress = new Uri($"https://{apiSubDomain}.api.riotgames.com"); | ||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, RegionalRoute region) : this(apiKey, region.ToString().ToLower()) | ||
{ | ||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, PlatformRoute platform) : this(apiKey, platform.ToString().ToLower()) | ||
{ | ||
} | ||
|
||
internal RiotGamesApiHttpClient(string apiKey, ValPlatformRoute platform) : this(apiKey, platform.ToString().ToLower()) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.