@@ -199,35 +199,22 @@ private HttpMethod GetHttpMethod(KeyValuePair<OperationType, OpenApiOperation> o
199199
200200 private HttpStatusCode ? GetHttpStatus ( string statusCode )
201201 {
202- switch ( statusCode )
203- {
204- case "200" :
205- return HttpStatusCode . OK ;
206- case "201" :
207- return HttpStatusCode . Created ;
208- case "202" :
209- return HttpStatusCode . Accepted ;
210- case "204" :
211- return HttpStatusCode . NoContent ;
212- case "400" :
213- return HttpStatusCode . BadRequest ;
214- case "401" :
215- return HttpStatusCode . Unauthorized ;
216- case "403" :
217- return HttpStatusCode . Forbidden ;
218- case "404" :
219- return HttpStatusCode . NotFound ;
220- case "405" :
221- return HttpStatusCode . MethodNotAllowed ;
222- case "409" :
223- return HttpStatusCode . Conflict ;
224- case "500" :
225- return HttpStatusCode . InternalServerError ;
226- case "default" :
227- return null ;
228- default :
229- throw new QAToolKitSwaggerException ( "HttpStatusCode not found." ) ;
230- }
202+ return statusCode switch
203+ {
204+ "200" => HttpStatusCode . OK ,
205+ "201" => HttpStatusCode . Created ,
206+ "202" => HttpStatusCode . Accepted ,
207+ "204" => HttpStatusCode . NoContent ,
208+ "400" => HttpStatusCode . BadRequest ,
209+ "401" => HttpStatusCode . Unauthorized ,
210+ "403" => HttpStatusCode . Forbidden ,
211+ "404" => HttpStatusCode . NotFound ,
212+ "405" => HttpStatusCode . MethodNotAllowed ,
213+ "409" => HttpStatusCode . Conflict ,
214+ "500" => HttpStatusCode . InternalServerError ,
215+ "default" => null ,
216+ _ => throw new QAToolKitSwaggerException ( "HttpStatusCode not found." ) ,
217+ } ;
231218 }
232219
233220 private string GetSummary ( KeyValuePair < OperationType , OpenApiOperation > openApiOperation )
@@ -311,7 +298,7 @@ private List<RequestBody> GetRequestBodies(KeyValuePair<OperationType, OpenApiOp
311298 {
312299 var requestBody = new RequestBody
313300 {
314- Name = contentType . Value . Schema . Reference != null ? contentType . Value . Schema . Reference . Id : null ,
301+ Name = contentType . Value . Schema . Reference ? . Id ,
315302 ContentType = ContentType . ToEnum ( contentType . Key ) ,
316303 Properties = null ,
317304 Required = openApiOperation . Value . RequestBody . Required
@@ -334,9 +321,8 @@ private List<RequestBody> GetRequestBodies(KeyValuePair<OperationType, OpenApiOp
334321
335322 return requests ;
336323 }
337- catch ( Exception ex )
324+ catch
338325 {
339- var msg = ex . Message ;
340326 return new List < RequestBody > ( ) ;
341327 }
342328 }
@@ -357,7 +343,7 @@ private List<Property> GetPropertiesRecursively(KeyValuePair<string, OpenApiSche
357343 Format = source . Value . Items . Description ,
358344 Type = source . Value . Items . Type ,
359345 Properties = null ,
360- Name = source . Value . Items . Reference != null ? source . Value . Items . Reference . Id : null
346+ Name = source . Value . Items . Reference ? . Id
361347 } ;
362348 itemsProperty . Required = source . Value . Items . Required . Contains ( itemsProperty . Name ) ;
363349
@@ -390,7 +376,7 @@ private List<Property> GetPropertiesRecursively(KeyValuePair<string, OpenApiSche
390376 Format = null ,
391377 Type = "enum" ,
392378 Properties = new List < Property > ( ) ,
393- Name = source . Value . Reference != null ? source . Value . Reference . Id : null ,
379+ Name = source . Value . Reference ? . Id ,
394380 } ;
395381 enumProperty . Required = source . Value . Required . Contains ( enumProperty . Name ) ;
396382
0 commit comments