public async Task <HttpResponseMessage> Get(bool hidden = false) { HyakUtils.CSMUrl = HyakUtils.CSMUrl ?? Utils.GetCSMUrl(Request.RequestUri.Host); var watch = new Stopwatch(); watch.Start(); var specs = Directory.Exists(HostingEnvironment.MapPath("~/App_Data/HydraSpecs")) ? Directory.GetFiles(HostingEnvironment.MapPath("~/App_Data/HydraSpecs")) .Select(Assembly.LoadFile) .Select(assembly => assembly.GetTypes()) .SelectMany(t => t) .Where(type => type.IsSubclassOf(typeof(BaseClient)) && !type.IsAbstract) .Select(client => HyakUtils.GetOperationsAsync(hidden, client)) .SelectMany(j => j) : Enumerable.Empty <MetadataObject>(); var speclessCsmApis = await HyakUtils.GetSpeclessCsmOperationsAsync(); var json = specs.Concat(speclessCsmApis); watch.Stop(); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(json), Encoding.UTF8, "application/json"); response.Headers.Add(Utils.X_MS_Ellapsed, watch.ElapsedMilliseconds + "ms"); return(response); }
public HttpResponseMessage GetPost([FromBody] List <string> providersList) { HyakUtils.CSMUrl = HyakUtils.CSMUrl ?? Utils.GetCSMUrl(Request.RequestUri.Host); var response = Request.CreateResponse(HttpStatusCode.NoContent); if (providersList != null) { var watch = new Stopwatch(); watch.Start(); var swaggerSpecs = providersList.Select(GetSpecFor).SelectMany(objects => objects); var metadataObjects = HyakUtils.GetSpeclessCsmOperations().Concat(swaggerSpecs); watch.Stop(); response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(metadataObjects), Encoding.UTF8, "application/json"); response.Headers.Add(Utils.X_MS_Ellapsed, watch.ElapsedMilliseconds + "ms"); } return(response); }