@@ -22,10 +22,15 @@ public string IfCheck
2222 {
2323 get
2424 {
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 ( ) ;
2726 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 ) } )";
2934 }
3035 }
3136 }
@@ -81,7 +86,7 @@ public string OptionallyAppendHttpMethod(IEnumerable<string> availableMethods, s
8186 //if on operation has two endpoints and one of them is GET always favor the other as default
8287 return currentHttpMethod == "GET" ? "Get" : string . Empty ;
8388 }
84-
89+
8590 return availableMethods . First ( ) == currentHttpMethod ? string . Empty : this . PascalCase ( currentHttpMethod ) ;
8691 }
8792
@@ -154,7 +159,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
154159 ReturnType = "ElasticsearchResponse<T>" ,
155160 ReturnTypeGeneric = "<T>" ,
156161 CallTypeGeneric = "T" ,
157- ReturnDescription =
162+ ReturnDescription =
158163 "ElasticsearchResponse<T> where the behavior depends on the type of T:"
159164 + explanationOfT ,
160165 FullName = methodName ,
@@ -166,8 +171,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
166171 } ;
167172 Generator . PatchMethod ( apiMethod ) ;
168173
169- args = args . Concat ( new [ ]
170- {
174+ args = args . Concat ( new [ ]
175+ {
171176 "Func<" + apiMethod . QueryStringParamName + ", " + apiMethod . QueryStringParamName + "> requestParameters = null"
172177 } ) . ToList ( ) ;
173178 apiMethod . Arguments = string . Join ( ", " , args ) ;
@@ -179,7 +184,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
179184 ReturnType = "Task<ElasticsearchResponse<T>>" ,
180185 ReturnTypeGeneric = "<T>" ,
181186 CallTypeGeneric = "T" ,
182- ReturnDescription =
187+ ReturnDescription =
183188 "A task of ElasticsearchResponse<T> where the behaviour depends on the type of T:"
184189 + explanationOfT ,
185190 FullName = methodName + "Async" ,
@@ -192,15 +197,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
192197 } ;
193198 Generator . PatchMethod ( apiMethod ) ;
194199 yield return apiMethod ;
195-
200+
196201 //No need for deserialization state when returning dynamicdictionary
197202
198203 var explanationOfDynamic =
199- paraIndent +
204+ paraIndent +
200205 "<para> - Dynamic dictionary is a special dynamic type that allows json to be traversed safely </para>"
201- + paraIndent +
206+ + paraIndent +
202207 "<para> - i.e result.Response.hits.hits[0].property.nested[\" nested_deeper\" ] </para>"
203- + paraIndent +
208+ + paraIndent +
204209 "<para> - can be safely dispatched to a nullable type even if intermediate properties do not exist </para>" ;
205210
206211 var defaultBoundGeneric = Url . Path . Contains ( "_cat" ) ? "string" : "DynamicDictionary" ;
@@ -212,7 +217,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
212217 ReturnTypeGeneric = null ,
213218 //CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
214219 CallTypeGeneric = defaultBoundGeneric ,
215- ReturnDescription =
220+ ReturnDescription =
216221 "ElasticsearchResponse<DynamicDictionary>"
217222 + explanationOfDynamic ,
218223 FullName = methodName ,
@@ -225,15 +230,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
225230 } ;
226231 Generator . PatchMethod ( apiMethod ) ;
227232 yield return apiMethod ;
228-
233+
229234 apiMethod = new CsharpMethod
230235 {
231236 QueryStringParamName = queryStringParamName ,
232237 ReturnType = $ "Task<ElasticsearchResponse<{ defaultBoundGeneric } >>",
233238 ReturnTypeGeneric = null ,
234239 //CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
235240 CallTypeGeneric = defaultBoundGeneric ,
236- ReturnDescription =
241+ ReturnDescription =
237242 "A task of ElasticsearchResponse<DynamicDictionary$gt;"
238243 + explanationOfDynamic ,
239244 FullName = methodName + "Async" ,
@@ -251,4 +256,4 @@ public IEnumerable<CsharpMethod> CsharpMethods
251256 }
252257 }
253258 }
254- }
259+ }
0 commit comments