File tree Expand file tree Collapse file tree
Source/Vinder.Federation.WebApi/Binders Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace Vinder . Federation . WebApi . Binders ;
22
3+ // oauth 2.0 requires form parameters to be sent in snake_case.
4+ // this binder converts snake_case form fields into pascal case model properties.
5+
6+ // https://www.rfc-editor.org/rfc/rfc6749#section-4.4.2
7+
38public sealed class SnakeCaseFormModelBinder : IModelBinder
49{
5- #pragma warning disable S2325
610 public async Task BindModelAsync ( ModelBindingContext bindingContext )
711 {
812 if ( ! bindingContext . HttpContext . Request . HasFormContentType )
@@ -36,8 +40,7 @@ public async Task BindModelAsync(ModelBindingContext bindingContext)
3640 bindingContext . Result = ModelBindingResult . Success ( model ) ;
3741 }
3842
39- private static string ToSnakeCase ( string input )
40- {
41- return Regex . Replace ( input , @"([a-z0-9])([A-Z])" , "$1_$2" ) . ToLowerInvariant ( ) ;
42- }
43- }
43+ private static string ToSnakeCase ( string input ) => Regex
44+ . Replace ( input , @"([a-z0-9])([A-Z])" , "$1_$2" )
45+ . ToLowerInvariant ( ) ;
46+ }
You can’t perform that action at this time.
0 commit comments