From 6eba02d6ba1b5746a91f7c9b4d1ea04f8422b841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=B2=D0=BE=D1=80=D1=83=D1=85=D0=B8=D0=BD=20?= =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Thu, 19 Sep 2024 12:14:43 +0300 Subject: [PATCH] fix: allow PropertyNamingPolicy = null --- .../Binding/JsonRpcParameterModelConvention.cs | 2 +- .../Routing/JsonRpcActionModelConvention.cs | 4 ++-- .../Services/OpenRpcDocumentGeneratorTests.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tochka.JsonRpc.Server/Binding/JsonRpcParameterModelConvention.cs b/src/Tochka.JsonRpc.Server/Binding/JsonRpcParameterModelConvention.cs index a5f0d371..5996bccc 100644 --- a/src/Tochka.JsonRpc.Server/Binding/JsonRpcParameterModelConvention.cs +++ b/src/Tochka.JsonRpc.Server/Binding/JsonRpcParameterModelConvention.cs @@ -44,7 +44,7 @@ public void Apply(ParameterModel parameter) foreach (var actionSelector in parameter.Action.Selectors) { var jsonSerializerOptions = ServerUtils.GetDataJsonSerializerOptions(actionSelector.EndpointMetadata, options, serializerOptionsProviders); - var propertyName = jsonSerializerOptions.PropertyNamingPolicy!.ConvertName(parameter.ParameterName); + var propertyName = jsonSerializerOptions.ConvertName(parameter.ParameterName); var parametersMetadata = actionSelector.EndpointMetadata.Get(); if (parametersMetadata == null) { diff --git a/src/Tochka.JsonRpc.Server/Routing/JsonRpcActionModelConvention.cs b/src/Tochka.JsonRpc.Server/Routing/JsonRpcActionModelConvention.cs index 62ea8c67..e8214731 100644 --- a/src/Tochka.JsonRpc.Server/Routing/JsonRpcActionModelConvention.cs +++ b/src/Tochka.JsonRpc.Server/Routing/JsonRpcActionModelConvention.cs @@ -75,8 +75,8 @@ private string GetMethodName(ActionModel action, SelectorModel selector) var methodStyleAttribute = selector.EndpointMetadata.Get(); var methodStyle = methodStyleAttribute?.MethodStyle ?? options.DefaultMethodStyle; - var controllerName = jsonSerializerOptions.PropertyNamingPolicy!.ConvertName(action.Controller.ControllerName); - var actionName = jsonSerializerOptions.PropertyNamingPolicy.ConvertName(action.ActionName); + var controllerName = jsonSerializerOptions.ConvertName(action.Controller.ControllerName); + var actionName = jsonSerializerOptions.ConvertName(action.ActionName); return methodStyle switch { JsonRpcMethodStyle.ControllerAndAction => $"{controllerName}{JsonRpcConstants.ControllerMethodSeparator}{actionName}", diff --git a/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcDocumentGeneratorTests.cs b/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcDocumentGeneratorTests.cs index 1a42d7da..db3bb19d 100644 --- a/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcDocumentGeneratorTests.cs +++ b/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcDocumentGeneratorTests.cs @@ -1028,7 +1028,7 @@ private static void ValidMethod() { } - private class ValidJsonRpcController : JsonRpcControllerBase + private sealed class ValidJsonRpcController : JsonRpcControllerBase { public void ValidJsonRpcMethod() {