11// Copyright © WireMock.Net
22
3+ using JsonConverter . Abstractions ;
4+ using Microsoft . Extensions . Options ;
35using Newtonsoft . Json ;
46using WireMock . Net . Extensions . Routing . Models ;
57
@@ -69,14 +71,16 @@ public static WireMockRouter MapPost(
6971 /// <param name="source">The router to extend.</param>
7072 /// <param name="pattern">The route pattern.</param>
7173 /// <param name="requestHandler">The request handler function.</param>
72- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
74+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
75+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
7376 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
7477 public static WireMockRouter MapPost < TRequest > (
7578 this WireMockRouter source ,
7679 string pattern ,
7780 Func < WireMockRequestInfo < TRequest > , object ? > requestHandler ,
78- JsonSerializerSettings ? jsonSettings = null ) =>
79- source . Map ( HttpMethod . Post . Method , pattern , requestHandler , jsonSettings ) ;
81+ IJsonConverter ? jsonConverter = null ,
82+ JsonConverterOptions ? jsonOptions = null ) =>
83+ source . Map ( HttpMethod . Post . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
8084
8185 /// <summary>
8286 /// Maps a POST request to an asynchronous request handler with a typed body.
@@ -85,14 +89,16 @@ public static WireMockRouter MapPost<TRequest>(
8589 /// <param name="source">The router to extend.</param>
8690 /// <param name="pattern">The route pattern.</param>
8791 /// <param name="requestHandler">The asynchronous request handler function.</param>
88- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
92+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
93+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
8994 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
9095 public static WireMockRouter MapPost < TRequest > (
9196 this WireMockRouter source ,
9297 string pattern ,
9398 Func < WireMockRequestInfo < TRequest > , Task < object ? > > requestHandler ,
94- JsonSerializerSettings ? jsonSettings = null ) =>
95- source . Map ( HttpMethod . Post . Method , pattern , requestHandler , jsonSettings ) ;
99+ IJsonConverter ? jsonConverter = null ,
100+ JsonConverterOptions ? jsonOptions = null ) =>
101+ source . Map ( HttpMethod . Post . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
96102
97103 /// <summary>
98104 /// Maps a PUT request to a synchronous request handler.
@@ -127,14 +133,16 @@ public static WireMockRouter MapPut(
127133 /// <param name="source">The router to extend.</param>
128134 /// <param name="pattern">The route pattern.</param>
129135 /// <param name="requestHandler">The request handler function.</param>
130- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
136+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
137+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
131138 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
132139 public static WireMockRouter MapPut < TRequest > (
133140 this WireMockRouter source ,
134141 string pattern ,
135142 Func < WireMockRequestInfo < TRequest > , object ? > requestHandler ,
136- JsonSerializerSettings ? jsonSettings = null ) =>
137- source . Map ( HttpMethod . Put . Method , pattern , requestHandler , jsonSettings ) ;
143+ IJsonConverter ? jsonConverter = null ,
144+ JsonConverterOptions ? jsonOptions = null ) =>
145+ source . Map ( HttpMethod . Put . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
138146
139147 /// <summary>
140148 /// Maps a PUT request to an asynchronous request handler with a typed body.
@@ -143,14 +151,16 @@ public static WireMockRouter MapPut<TRequest>(
143151 /// <param name="source">The router to extend.</param>
144152 /// <param name="pattern">The route pattern.</param>
145153 /// <param name="requestHandler">The asynchronous request handler function.</param>
146- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
154+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
155+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
147156 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
148157 public static WireMockRouter MapPut < TRequest > (
149158 this WireMockRouter source ,
150159 string pattern ,
151160 Func < WireMockRequestInfo < TRequest > , Task < object ? > > requestHandler ,
152- JsonSerializerSettings ? jsonSettings = null ) =>
153- source . Map ( HttpMethod . Put . Method , pattern , requestHandler , jsonSettings ) ;
161+ IJsonConverter ? jsonConverter = null ,
162+ JsonConverterOptions ? jsonOptions = null ) =>
163+ source . Map ( HttpMethod . Put . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
154164
155165 /// <summary>
156166 /// Maps a DELETE request to a synchronous request handler.
@@ -185,14 +195,16 @@ public static WireMockRouter MapDelete(
185195 /// <param name="source">The router to extend.</param>
186196 /// <param name="pattern">The route pattern.</param>
187197 /// <param name="requestHandler">The request handler function.</param>
188- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
198+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
199+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
189200 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
190201 public static WireMockRouter MapDelete < TRequest > (
191202 this WireMockRouter source ,
192203 string pattern ,
193204 Func < WireMockRequestInfo < TRequest > , object ? > requestHandler ,
194- JsonSerializerSettings ? jsonSettings = null ) =>
195- source . Map ( HttpMethod . Delete . Method , pattern , requestHandler , jsonSettings ) ;
205+ IJsonConverter ? jsonConverter = null ,
206+ JsonConverterOptions ? jsonOptions = null ) =>
207+ source . Map ( HttpMethod . Delete . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
196208
197209 /// <summary>
198210 /// Maps a DELETE request to an asynchronous request handler with a typed body.
@@ -201,12 +213,14 @@ public static WireMockRouter MapDelete<TRequest>(
201213 /// <param name="source">The router to extend.</param>
202214 /// <param name="pattern">The route pattern.</param>
203215 /// <param name="requestHandler">The asynchronous request handler function.</param>
204- /// <param name="jsonSettings">Optional JSON serializer settings.</param>
216+ /// <param name="jsonConverter">The <see cref="IJsonConverter"/> [optional]. Default value is NewtonsoftJsonConverter.</param>
217+ /// <param name="jsonOptions">The <see cref="JsonConverterOptions"/> [optional].</param>
205218 /// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
206219 public static WireMockRouter MapDelete < TRequest > (
207220 this WireMockRouter source ,
208221 string pattern ,
209222 Func < WireMockRequestInfo < TRequest > , Task < object ? > > requestHandler ,
210- JsonSerializerSettings ? jsonSettings = null ) =>
211- source . Map ( HttpMethod . Delete . Method , pattern , requestHandler , jsonSettings ) ;
223+ IJsonConverter ? jsonConverter = null ,
224+ JsonConverterOptions ? jsonOptions = null ) =>
225+ source . Map ( HttpMethod . Delete . Method , pattern , requestHandler , jsonConverter , jsonOptions ) ;
212226}
0 commit comments