Skip to content

Commit 4e51e86

Browse files
authored
fix: dump correct types via Swagger UI, including strings for enums (#2457)
* fix: correct api types and api type serialization note: LookupKey not showing in components/schemas because it's a string type, unknown if there's a way to force it to display anyway * fix: Swashbuckle.AspNetCore.Annotations should be a PackageReference not a Reference * fix: return types for 400/404 for player/user/guild variables * fix: game object types should be included in swagger with a functioning type hierarchy * fix: lookups for stats/vitals since exposing the enums isn't working * fix: get LookupKey to show in Swagger schemas * chore: removed unused filters * fix: collection responses * fix: corrected weird parameter error by switching from struct to class * rename count on paging info * feat: dictionary enum key type in schemas * fix: change to object initializer to avoid compile error * fix: update property name
1 parent 5dcb0b5 commit 4e51e86

File tree

164 files changed

+2151
-1133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+2151
-1133
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ resharper_place_expr_property_on_single_line = true
146146
resharper_place_simple_initializer_on_single_line = false
147147
resharper_trailing_comma_in_multiline_lists = true
148148
resharper_wrap_array_initializer_style = chop_if_long
149+
resharper_wrap_before_primary_constructor_declaration_rpar = true
149150
###############################
150151
# VB Coding Conventions #
151152
###############################

Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public partial class DatabaseOptions
2020

2121
public ushort Port { get; set; } = 3306;
2222

23-
public string Database { get; set; } = "";
23+
public string Database { get; set; } = string.Empty;
2424

25-
public string Username { get; set; } = "";
25+
public string Username { get; set; } = string.Empty;
2626

27-
public string Password { get; set; } = "";
27+
public string Password { get; set; } = string.Empty;
2828

2929
[JsonConverter(typeof(StringEnumConverter))]
3030
[JsonProperty(

Framework/Intersect.Framework.Core/Config/Options.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Intersect;
88
public partial class Options
99
{
1010
//Caching Json
11-
private static string optionsCompressed = "";
11+
private static string optionsCompressed = string.Empty;
1212

1313
[JsonProperty("AdminOnly", Order = -3)]
1414
protected bool _adminOnly = false;

Framework/Intersect.Framework.Core/Config/SmtpSettings.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
public partial class SmtpSettings
44
{
5-
public string FromAddress { get; set; } = "";
5+
public string FromAddress { get; set; } = string.Empty;
66

7-
public string FromName { get; set; } = "";
7+
public string FromName { get; set; } = string.Empty;
88

9-
public string Host { get; set; } = "";
9+
public string Host { get; set; } = string.Empty;
1010

1111
public int Port { get; set; } = 587;
1212

1313
public bool UseSsl { get; set; } = true;
1414

15-
public string Username { get; set; } = "";
15+
public string Username { get; set; } = string.Empty;
1616

17-
public string Password { get; set; } = "";
17+
public string Password { get; set; } = string.Empty;
1818

1919
public bool IsValid()
2020
{

Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ public void Validate()
202202
/// <summary>
203203
/// The address for the update manifest file generated by the editor.
204204
/// </summary>
205-
public string UpdateUrl { get; set; } = "";
205+
public string UpdateUrl { get; set; } = string.Empty;
206206

207207
/// <summary>
208208
/// Sets a custom mouse cursor.
209209
/// </summary>
210-
public string MouseCursor { get; set; } = "";
210+
public string MouseCursor { get; set; } = string.Empty;
211211

212212
/// <summary>
213213
/// Determines the time it takes to fade-in or fade-out a song when no other instructions are given.

Framework/Intersect.Framework.Core/Descriptors/GameObjectTypeExtensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ public static DatabaseObjectLookup GetLookup(this GameObjectType gameObjectType)
5353
return DatabaseObjectLookup.GetLookup(GetObjectType(gameObjectType));
5454
}
5555

56+
public static bool TryGetLookup(this GameObjectType gameObjectType,
57+
[NotNullWhen(true)] out DatabaseObjectLookup? lookup)
58+
{
59+
lookup = GetLookup(gameObjectType);
60+
return lookup != default;
61+
}
62+
5663
public static IDatabaseObject CreateNew(this GameObjectType gameObjectType)
5764
{
5865
var instance = Activator.CreateInstance(

Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ public AnimationBase()
7777
public bool CompleteSound { get; set; }
7878

7979
/// <inheritdoc />
80-
public string Folder { get; set; } = "";
80+
public string Folder { get; set; } = string.Empty;
8181
}

Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public override string Format(Type stringsType, object value)
2323
throw new InvalidOperationException($"{stringsType.FullName}.{nameof(stringsType)} is missing.");
2424
}
2525

26-
return formatBooleanMethodInfo.Invoke(null, new[] { value, Style })?.ToString();
26+
return formatBooleanMethodInfo.Invoke(null, [value, Style])?.ToString();
2727
}
2828
}

Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private static GetStringFromLocaleDictionaryGeneric CreateWeaklyTypedDelegate<TK
129129
var dictionaryType = dictionaryObject.GetType();
130130
if (!_cachedFormatters.TryGetValue(dictionaryType, out var formatter))
131131
{
132-
var createdDelegate = _methodInfoCreateWeaklyTypedDelegate.MakeGenericMethod(key.GetType()).Invoke(null, Array.Empty<object>());
132+
var createdDelegate = _methodInfoCreateWeaklyTypedDelegate.MakeGenericMethod(key.GetType()).Invoke(null, []);
133133
if (createdDelegate is not GetStringFromLocaleDictionaryGeneric genericFormatter)
134134
{
135135
throw new InvalidOperationException();

Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static object InvokeFormatterMethod(IEnumerable<MethodInfo> methodInfos,
8484

8585
if (formatterMethodInfo.GetParameters().Length == 1)
8686
{
87-
return formatterMethodInfo.Invoke(default, new[] { value });
87+
return formatterMethodInfo.Invoke(default, [value]);
8888
}
8989

9090
return formatterMethodInfo.Invoke(

0 commit comments

Comments
 (0)