diff --git a/src/Http/Wolverine.Http.Tests/from_form_binding.cs b/src/Http/Wolverine.Http.Tests/from_form_binding.cs index 64c112c44..9e804b4c1 100644 --- a/src/Http/Wolverine.Http.Tests/from_form_binding.cs +++ b/src/Http/Wolverine.Http.Tests/from_form_binding.cs @@ -119,6 +119,18 @@ public async Task int_array_as_property() (await forForm([new("name", "Jones"), new("number", "95"), new("numbers", "1"), new("Numbers", "3"), new("Numbers", "4")])).Numbers.ShouldBe([1, 3, 4]); } + [Fact] + public async Task from_form_respects_custom_kebab_name() + { + var result = await Host.Scenario(x => x + .Post.FormData(new Dictionary + { + { "form-custom-kebab", "hello" } + }) + .ToUrl("/form/kebab-name")); + result.ReadAsText().ShouldBe("hello"); + } + [Fact] public async Task value_with_alias() { diff --git a/src/Http/Wolverine.Http/HttpChain.cs b/src/Http/Wolverine.Http/HttpChain.cs index 2a6cc6f88..d2e29e508 100644 --- a/src/Http/Wolverine.Http/HttpChain.cs +++ b/src/Http/Wolverine.Http/HttpChain.cs @@ -409,11 +409,13 @@ private void applyMetadata() if (parameterType == typeof(string)) { variable = new ReadHttpFrame(BindingSource.Form, parameterType,key).Variable; + variable.Name = key; _formValueVariables.Add(variable); } if (parameterType == typeof(string[])) { variable = new ParsedArrayFormValue(parameterType, parameterName).Variable; + variable.Name = key; _formValueVariables.Add(variable); } diff --git a/src/Http/WolverineWebApi/Forms/FormEndpoints.cs b/src/Http/WolverineWebApi/Forms/FormEndpoints.cs index 1b8ade198..cc0d82c37 100644 --- a/src/Http/WolverineWebApi/Forms/FormEndpoints.cs +++ b/src/Http/WolverineWebApi/Forms/FormEndpoints.cs @@ -22,6 +22,12 @@ public static string UsingEnumQuerystring([FromForm(Name = "name")] string value return value ?? ""; } + [WolverinePost("/form/kebab-name")] + public static string KebabFormName([FromForm(Name = "form-custom-kebab")] string value) + { + return value ?? ""; + } + [WolverinePost("/form/enum/nullable")] public static string UsingNullableEnumQuerystring([FromForm]Direction? direction) {