Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rast1234 committed Jul 26, 2024
1 parent b594663 commit b6ba163
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 57 deletions.
16 changes: 16 additions & 0 deletions src/Tochka.JsonRpc.OpenRpc/Services/JsonSchemaBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Json.Schema;

namespace Tochka.JsonRpc.OpenRpc.Services;

internal static class JsonSchemaBuilderExtensions
{
public static JsonSchemaBuilder TryAppendTitle(this JsonSchemaBuilder builder, string? propertySummary)
{
if (propertySummary is { Length: > 0 })
{
builder.Title(propertySummary);
}

return builder;
}
}
15 changes: 1 addition & 14 deletions src/Tochka.JsonRpc.OpenRpc/Services/OpenRpcSchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,4 @@ private void TryAddRequiredMember(string typeName, string propertyName, JsonSeri

requiredPropsForSchemas.TryAdd(typeName, requiredProperties);
}
}

internal static class JsonSchemaBuilderExtensions
{
public static JsonSchemaBuilder TryAppendTitle(this JsonSchemaBuilder builder, string? propertySummary)
{
if (propertySummary is { Length: > 0 })
{
builder.Title(propertySummary);
}

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;

public record ClassWithEmptyConstructor
{
public string A { get; init; }
public object B { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;

public record ClassWithoutEmptyConstructor(string A, object B);
3 changes: 3 additions & 0 deletions src/tests/Tochka.JsonRpc.ApiExplorer.Tests/NonPublicClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;

internal sealed record NonPublicClass;
3 changes: 3 additions & 0 deletions src/tests/Tochka.JsonRpc.ApiExplorer.Tests/SealedClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;

public sealed record SealedClass;
11 changes: 1 addition & 10 deletions src/tests/Tochka.JsonRpc.ApiExplorer.Tests/TypeEmitterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,8 @@ public void CreateResponseType_ResultTypeIsVoid_GenericArgumentIsObject()
public record NestedClass;
}

internal sealed record NonPublicClass;

// ReSharper disable once MemberCanBeInternal
public sealed record SealedClass;

// ReSharper disable once MemberCanBeInternal
public record ClassWithEmptyConstructor
{
public string A { get; init; }
public object B { get; init; }
}

// ReSharper disable once MemberCanBeInternal
public record ClassWithoutEmptyConstructor(string A, object B);
// ReSharper disable once MemberCanBeInternal
9 changes: 1 addition & 8 deletions src/tests/Tochka.JsonRpc.TestUtils/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,4 @@ public record TestData(bool BoolField, string StringField, int IntField, double
""";

#endregion
}

public enum TestEnum
{
One,
Two,
ThreeFour
}
}
8 changes: 8 additions & 0 deletions src/tests/Tochka.JsonRpc.TestUtils/TestEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Tochka.JsonRpc.TestUtils;

public enum TestEnum
{
One,
Two,
ThreeFour
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

namespace Tochka.JsonRpc.Tests.WebApplication.Controllers;

public class TestObject
{
public TimeSpan Ts { get; set; } = DateTime.Now.TimeOfDay;
}

[ApiExplorerSettings(GroupName = "custom")]
public class CustomGroupNameJsonRpcController : JsonRpcControllerBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentValidation;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Mvc;
using Tochka.JsonRpc.Server;
using Tochka.JsonRpc.Server.Attributes;
Expand Down Expand Up @@ -27,22 +26,4 @@ public async Task<IActionResult> Validate([FromParams(BindingStyle.Object)] Vali
? Ok(errorFactory.InternalError(validationResult.ToDictionary()))
: Ok(model.Str);
}
}

public record ValidationModel(string? Str);

[UsedImplicitly]
public class ModelValidator : AbstractValidator<ValidationModel>
{
public ModelValidator() => RuleFor(static m => m.Str).NotEmpty().WithMessage(Error);

internal const string Error = "Str is empty";
}

[UsedImplicitly]
public class StringValidator : AbstractValidator<string>
{
public StringValidator() => RuleFor(static x => x).MinimumLength(3).WithMessage(Error);

internal const string Error = "Str is too short";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using FluentValidation;
using JetBrains.Annotations;

namespace Tochka.JsonRpc.Tests.WebApplication.Controllers;

[UsedImplicitly]
public class ModelValidator : AbstractValidator<ValidationModel>
{
public ModelValidator() => RuleFor(static m => m.Str).NotEmpty().WithMessage(Error);

internal const string Error = "Str is empty";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using FluentValidation;
using JetBrains.Annotations;

namespace Tochka.JsonRpc.Tests.WebApplication.Controllers;

[UsedImplicitly]
public class StringValidator : AbstractValidator<string>
{
public StringValidator() => RuleFor(static x => x).MinimumLength(3).WithMessage(Error);

internal const string Error = "Str is too short";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Tochka.JsonRpc.Tests.WebApplication.Controllers;

public class TestObject
{
public TimeSpan Ts { get; set; } = DateTime.Now.TimeOfDay;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Tochka.JsonRpc.Tests.WebApplication.Controllers;

public record ValidationModel(string? Str);

0 comments on commit b6ba163

Please sign in to comment.