@@ -22,10 +22,15 @@ public string IfCheck
22
22
{
23
23
get
24
24
{
25
- var parts = this . CsharpMethod . Parts . Where ( p => p . Name != "body" )
26
- . Select ( p => $ "p.RouteValues.{ p . Name . ToPascalCase ( ) } ") . ToList ( ) ;
25
+ var parts = this . CsharpMethod . Parts . Where ( p => p . Name != "body" ) . ToList ( ) ;
27
26
if ( ! parts . Any ( ) ) return string . Empty ;
28
- return $ "AllSet({ string . Join ( ", " , parts ) } )";
27
+
28
+ var allPartsAreRequired = parts . Any ( ) && parts . All ( p => p . Required ) ;
29
+ var call = allPartsAreRequired ? "AllSetNoFallback" : "AllSet" ;
30
+ var assignments = parts
31
+ . Select ( p => $ "p.RouteValues.{ p . Name . ToPascalCase ( ) } ") . ToList ( ) ;
32
+
33
+ return $ "{ call } ({ string . Join ( ", " , assignments ) } )";
29
34
}
30
35
}
31
36
}
@@ -81,7 +86,7 @@ public string OptionallyAppendHttpMethod(IEnumerable<string> availableMethods, s
81
86
//if on operation has two endpoints and one of them is GET always favor the other as default
82
87
return currentHttpMethod == "GET" ? "Get" : string . Empty ;
83
88
}
84
-
89
+
85
90
return availableMethods . First ( ) == currentHttpMethod ? string . Empty : this . PascalCase ( currentHttpMethod ) ;
86
91
}
87
92
@@ -154,7 +159,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
154
159
ReturnType = "ElasticsearchResponse<T>" ,
155
160
ReturnTypeGeneric = "<T>" ,
156
161
CallTypeGeneric = "T" ,
157
- ReturnDescription =
162
+ ReturnDescription =
158
163
"ElasticsearchResponse<T> where the behavior depends on the type of T:"
159
164
+ explanationOfT ,
160
165
FullName = methodName ,
@@ -166,8 +171,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
166
171
} ;
167
172
Generator . PatchMethod ( apiMethod ) ;
168
173
169
- args = args . Concat ( new [ ]
170
- {
174
+ args = args . Concat ( new [ ]
175
+ {
171
176
"Func<" + apiMethod . QueryStringParamName + ", " + apiMethod . QueryStringParamName + "> requestParameters = null"
172
177
} ) . ToList ( ) ;
173
178
apiMethod . Arguments = string . Join ( ", " , args ) ;
@@ -179,7 +184,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
179
184
ReturnType = "Task<ElasticsearchResponse<T>>" ,
180
185
ReturnTypeGeneric = "<T>" ,
181
186
CallTypeGeneric = "T" ,
182
- ReturnDescription =
187
+ ReturnDescription =
183
188
"A task of ElasticsearchResponse<T> where the behaviour depends on the type of T:"
184
189
+ explanationOfT ,
185
190
FullName = methodName + "Async" ,
@@ -192,15 +197,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
192
197
} ;
193
198
Generator . PatchMethod ( apiMethod ) ;
194
199
yield return apiMethod ;
195
-
200
+
196
201
//No need for deserialization state when returning dynamicdictionary
197
202
198
203
var explanationOfDynamic =
199
- paraIndent +
204
+ paraIndent +
200
205
"<para> - Dynamic dictionary is a special dynamic type that allows json to be traversed safely </para>"
201
- + paraIndent +
206
+ + paraIndent +
202
207
"<para> - i.e result.Response.hits.hits[0].property.nested[\" nested_deeper\" ] </para>"
203
- + paraIndent +
208
+ + paraIndent +
204
209
"<para> - can be safely dispatched to a nullable type even if intermediate properties do not exist </para>" ;
205
210
206
211
var defaultBoundGeneric = Url . Path . Contains ( "_cat" ) ? "string" : "DynamicDictionary" ;
@@ -212,7 +217,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
212
217
ReturnTypeGeneric = null ,
213
218
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
214
219
CallTypeGeneric = defaultBoundGeneric ,
215
- ReturnDescription =
220
+ ReturnDescription =
216
221
"ElasticsearchResponse<DynamicDictionary>"
217
222
+ explanationOfDynamic ,
218
223
FullName = methodName ,
@@ -225,15 +230,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
225
230
} ;
226
231
Generator . PatchMethod ( apiMethod ) ;
227
232
yield return apiMethod ;
228
-
233
+
229
234
apiMethod = new CsharpMethod
230
235
{
231
236
QueryStringParamName = queryStringParamName ,
232
237
ReturnType = $ "Task<ElasticsearchResponse<{ defaultBoundGeneric } >>",
233
238
ReturnTypeGeneric = null ,
234
239
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
235
240
CallTypeGeneric = defaultBoundGeneric ,
236
- ReturnDescription =
241
+ ReturnDescription =
237
242
"A task of ElasticsearchResponse<DynamicDictionary$gt;"
238
243
+ explanationOfDynamic ,
239
244
FullName = methodName + "Async" ,
@@ -251,4 +256,4 @@ public IEnumerable<CsharpMethod> CsharpMethods
251
256
}
252
257
}
253
258
}
254
- }
259
+ }
0 commit comments