Skip to content

Commit 35b530d

Browse files
committed
OpenAPI broke
1 parent 63df5fd commit 35b530d

9 files changed

Lines changed: 26 additions & 28 deletions

‎Common/DataAnnotations/EmailAddressAttribute.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22
using System.Net.Mail;
3-
using Microsoft.OpenApi.Any;
4-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
54
using OpenShock.Common.Constants;
65
using OpenShock.Common.DataAnnotations.Interfaces;
76

@@ -13,7 +12,7 @@ namespace OpenShock.Common.DataAnnotations;
1312
/// <remarks>
1413
/// Inherits from <see cref="ValidationAttribute"/>.
1514
/// </remarks>
16-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
15+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
1716
public sealed class EmailAddressAttribute : ValidationAttribute, IParameterAttribute
1817
{
1918
/// <summary>
@@ -61,7 +60,7 @@ public void Apply(OpenApiSchema schema)
6160
{
6261
//if (ShouldValidate) schema.Pattern = ???;
6362

64-
schema.Example = new OpenApiString(ExampleValue);
63+
schema.Example = ExampleValue;
6564
}
6665

6766
/// <inheritdoc/>

‎Common/DataAnnotations/Interfaces/IOperationAttribute.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Models;
1+
using Microsoft.OpenApi;
22

33
namespace OpenShock.Common.DataAnnotations.Interfaces;
44

‎Common/DataAnnotations/Interfaces/IParameterAttribute.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Models;
1+
using Microsoft.OpenApi;
22

33
namespace OpenShock.Common.DataAnnotations.Interfaces;
44

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
using Microsoft.OpenApi.Any;
2-
using Microsoft.OpenApi.Models;
1+
using Microsoft.OpenApi;
32
using OpenShock.Common.Models;
43

54
namespace OpenShock.Common.DataAnnotations;
65

76
public static class OpenApiSchemas
87
{
9-
public static OpenApiSchema SemVerSchema => new OpenApiSchema {
8+
public static OpenApiSchema SemVerSchema => new()
9+
{
1010
Title = "SemVer",
11-
Type = "string",
12-
Pattern = /* lang=regex */ "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
13-
Example = new OpenApiString("1.0.0-dev+a16f2")
11+
Type = JsonSchemaType.String,
12+
Pattern = /* lang=regex */ @"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",
13+
Example = "1.0.0-dev+a16f2"
1414
};
1515

16-
public static OpenApiSchema PauseReasonEnumSchema => new OpenApiSchema {
16+
public static OpenApiSchema PauseReasonEnumSchema => new()
17+
{
1718
Title = nameof(PauseReason),
18-
Type = "integer",
19+
Type = JsonSchemaType.Integer,
1920
Description = """
2021
An integer representing the reason(s) for the shocker being paused, expressed as a bitfield where reasons are OR'd together.
2122
@@ -26,6 +27,6 @@ public static class OpenApiSchemas
2627
2728
For example, a value of 6 (2 | 4) indicates both 'UserShare' and 'PublicShare' reasons.
2829
""",
29-
Example = new OpenApiInteger(6)
30+
Example = 6
3031
};
3132
}

‎Common/DataAnnotations/PasswordAttribute.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.ComponentModel.DataAnnotations;
2-
using Microsoft.OpenApi.Any;
3-
using Microsoft.OpenApi.Models;
2+
using Microsoft.OpenApi;
43
using OpenShock.Common.Constants;
54
using OpenShock.Common.DataAnnotations.Interfaces;
65

@@ -12,7 +11,7 @@ namespace OpenShock.Common.DataAnnotations;
1211
/// <remarks>
1312
/// Inherits from <see cref="ValidationAttribute"/>.
1413
/// </remarks>
15-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
14+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
1615
public sealed class PasswordAttribute : ValidationAttribute, IParameterAttribute
1716
{
1817
/// <summary>
@@ -60,7 +59,7 @@ public void Apply(OpenApiSchema schema)
6059
{
6160
//if (ShouldValidate) schema.Pattern = ???;
6261

63-
schema.Example = new OpenApiString(ExampleValue);
62+
schema.Example = ExampleValue;
6463
}
6564

6665
/// <inheritdoc/>

‎Common/DataAnnotations/UsernameAttribute.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.ComponentModel.DataAnnotations;
2-
using Microsoft.OpenApi.Any;
3-
using Microsoft.OpenApi.Models;
2+
using Microsoft.OpenApi;
43
using OpenShock.Common.DataAnnotations.Interfaces;
54
using OpenShock.Common.Validation;
65

@@ -12,7 +11,7 @@ namespace OpenShock.Common.DataAnnotations;
1211
/// <remarks>
1312
/// Inherits from <see cref="ValidationAttribute"/>.
1413
/// </remarks>
15-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
14+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
1615
public sealed class UsernameAttribute : ValidationAttribute, IParameterAttribute
1716
{
1817
/// <summary>
@@ -56,7 +55,7 @@ public void Apply(OpenApiSchema schema)
5655
{
5756
//if (ShouldValidate) schema.Pattern = ???;
5857

59-
schema.Example = new OpenApiString(ExampleValue);
58+
schema.Example = ExampleValue;
6059
}
6160

6261
/// <inheritdoc/>

‎Common/Swagger/AttributeFilter.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Microsoft.AspNetCore.Authorization;
2-
using Microsoft.OpenApi.Models;
2+
using Microsoft.OpenApi;
33
using OpenShock.Common.Authentication;
44
using OpenShock.Common.DataAnnotations.Interfaces;
55
using Swashbuckle.AspNetCore.SwaggerGen;
@@ -8,7 +8,7 @@ namespace OpenShock.Common.Swagger;
88

99
public sealed class AttributeFilter : ISchemaFilter, IParameterFilter, IOperationFilter
1010
{
11-
public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
11+
public void Apply(IOpenApiParameter parameter, ParameterFilterContext context)
1212
{
1313
// Apply OpenShock Parameter Attributes
1414
foreach (var attribute in context.ParameterInfo?.GetCustomAttributes(true).OfType<IParameterAttribute>() ?? [])
@@ -23,7 +23,7 @@ public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
2323
}
2424
}
2525

26-
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
26+
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
2727
{
2828
// Apply OpenShock Parameter Attributes
2929
foreach (var attribute in context.MemberInfo?.GetCustomAttributes(true).OfType<IParameterAttribute>() ?? [])

‎Common/Swagger/SwaggerGenExtensions.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Models;
1+
using Microsoft.OpenApi;
22
using OpenShock.Common.Constants;
33
using OpenShock.Common.DataAnnotations;
44
using OpenShock.Common.Models;

‎Common/Utils/ConfigureSwaggerOptions.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Asp.Versioning.ApiExplorer;
22
using Microsoft.Extensions.Options;
3-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
44
using Swashbuckle.AspNetCore.SwaggerGen;
55

66
namespace OpenShock.Common.Utils;

0 commit comments

Comments
 (0)