예제 #1
0
 /// <summary>Loads the Swagger spec.</summary>
 public async Task <SwaggerDocument> RunAsync()
 {
     if (!string.IsNullOrEmpty(Swagger))
     {
         if (Swagger.StartsWith("{"))
         {
             return(await SwaggerDocument.FromJsonAsync(Swagger).ConfigureAwait(false));
         }
         else
         {
             return(await SwaggerYamlDocument.FromYamlAsync(Swagger).ConfigureAwait(false));
         }
     }
     else if (Url.StartsWith("http://") || Url.StartsWith("https://"))
     {
         if (Url.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase))
         {
             return(await SwaggerYamlDocument.FromUrlAsync(Url).ConfigureAwait(false));
         }
         else
         {
             return(await SwaggerDocument.FromUrlAsync(Url).ConfigureAwait(false));
         }
     }
     else
     {
         if (Url.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase))
         {
             return(await SwaggerYamlDocument.FromFileAsync(Url).ConfigureAwait(false));
         }
         else
         {
             return(await SwaggerDocument.FromFileAsync(Url).ConfigureAwait(false));
         }
     }
 }