1
1
// Copyright © WireMock.Net
2
2
3
+ using JsonConverter . Abstractions ;
4
+ using Microsoft . Extensions . Options ;
3
5
using Newtonsoft . Json ;
4
6
using WireMock . Net . Extensions . Routing . Models ;
5
7
@@ -69,14 +71,16 @@ public static WireMockRouter MapPost(
69
71
/// <param name="source">The router to extend.</param>
70
72
/// <param name="pattern">The route pattern.</param>
71
73
/// <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>
73
76
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
74
77
public static WireMockRouter MapPost < TRequest > (
75
78
this WireMockRouter source ,
76
79
string pattern ,
77
80
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 ) ;
80
84
81
85
/// <summary>
82
86
/// Maps a POST request to an asynchronous request handler with a typed body.
@@ -85,14 +89,16 @@ public static WireMockRouter MapPost<TRequest>(
85
89
/// <param name="source">The router to extend.</param>
86
90
/// <param name="pattern">The route pattern.</param>
87
91
/// <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>
89
94
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
90
95
public static WireMockRouter MapPost < TRequest > (
91
96
this WireMockRouter source ,
92
97
string pattern ,
93
98
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 ) ;
96
102
97
103
/// <summary>
98
104
/// Maps a PUT request to a synchronous request handler.
@@ -127,14 +133,16 @@ public static WireMockRouter MapPut(
127
133
/// <param name="source">The router to extend.</param>
128
134
/// <param name="pattern">The route pattern.</param>
129
135
/// <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>
131
138
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
132
139
public static WireMockRouter MapPut < TRequest > (
133
140
this WireMockRouter source ,
134
141
string pattern ,
135
142
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 ) ;
138
146
139
147
/// <summary>
140
148
/// Maps a PUT request to an asynchronous request handler with a typed body.
@@ -143,14 +151,16 @@ public static WireMockRouter MapPut<TRequest>(
143
151
/// <param name="source">The router to extend.</param>
144
152
/// <param name="pattern">The route pattern.</param>
145
153
/// <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>
147
156
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
148
157
public static WireMockRouter MapPut < TRequest > (
149
158
this WireMockRouter source ,
150
159
string pattern ,
151
160
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 ) ;
154
164
155
165
/// <summary>
156
166
/// Maps a DELETE request to a synchronous request handler.
@@ -185,14 +195,16 @@ public static WireMockRouter MapDelete(
185
195
/// <param name="source">The router to extend.</param>
186
196
/// <param name="pattern">The route pattern.</param>
187
197
/// <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>
189
200
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
190
201
public static WireMockRouter MapDelete < TRequest > (
191
202
this WireMockRouter source ,
192
203
string pattern ,
193
204
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 ) ;
196
208
197
209
/// <summary>
198
210
/// Maps a DELETE request to an asynchronous request handler with a typed body.
@@ -201,12 +213,14 @@ public static WireMockRouter MapDelete<TRequest>(
201
213
/// <param name="source">The router to extend.</param>
202
214
/// <param name="pattern">The route pattern.</param>
203
215
/// <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>
205
218
/// <returns>The current <see cref="WireMockRouter"/> instance.</returns>
206
219
public static WireMockRouter MapDelete < TRequest > (
207
220
this WireMockRouter source ,
208
221
string pattern ,
209
222
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 ) ;
212
226
}
0 commit comments