public static async Task <SwaggerDocObject> ReadSwagger(HttpClient client, TestRun testRun)
 {
     return(await Get(client));
 }
        static string MapUrl(KeyValuePair <string, SwaggerEndpoint> keyValuePair, string basePath, TestRun testRun)
        {
            var initial         = string.Concat(basePath ?? string.Empty, keyValuePair.Key);
            var queryParameters = (keyValuePair.Value.get?.parameters ?? keyValuePair.Value.post?.parameters)?.Where(
                x => testRun.TreatParametersAsRequired.Contains(x.name) ||
                (x.required && x._in == "query")).ToArray() ?? Array.Empty <Parameter>();

            return(string.Concat(
                       initial,
                       queryParameters.Any() ? "?" : string.Empty,
                       string.Join("&", queryParameters.Select(x => $"{x.name}={{{x.name}}}"))));
        }
        static IEnumerable <SwaggerUrlWithData> ExpandUrls(IEnumerable <SwaggerUrl> swaggerUrls, TestRun testRun)
        {
            foreach (var swaggerUrl in swaggerUrls)
            {
                if (testRun.ExcludeEndpoints.Any(s => IsMatch(swaggerUrl, s, HttpMethod.Get)))
                {
                    continue;
                }

                foreach (var specificallyIncludedEndpoint in testRun.IncludeEndpoints)
                {
                    var httpMethod = new HttpMethod(specificallyIncludedEndpoint.Method);
                    if (IsMatch(swaggerUrl, specificallyIncludedEndpoint.Endpoint, httpMethod))
                    {
                        var files = string.IsNullOrEmpty(specificallyIncludedEndpoint.DataFolder)
                            ? Array.Empty <string>()
                            : Directory.GetFiles(specificallyIncludedEndpoint.DataFolder);
                        foreach (var file in files.Any() ? files : new[] { string.Empty })
                        {
                            yield return(new SwaggerUrlWithData
                            {
                                Method = httpMethod,
                                Url = ReplaceUrlParts(swaggerUrl, testRun),
                                Data = File.Exists(file) ? File.ReadAllText(file) : httpMethod == HttpMethod.Post ? "{}" : null,
                                FileNameFullPath = file,
                                FileName = Path.GetFileName(file),
                                DisregardJsonResponseProperties = specificallyIncludedEndpoint.DisregardJsonResponseProperties
                            });
                        }
                    }
                }

                if (IsMatch(swaggerUrl, swaggerUrl.Url, HttpMethod.Get))
                {
                    yield return(new SwaggerUrlWithData
                    {
                        Method = HttpMethod.Get,
                        Url = ReplaceUrlParts(swaggerUrl, testRun),
                        FileNameFullPath = string.Empty,
                        FileName = string.Empty
                    });
                }
            }
        }
        public static async Task <List <SwaggerUrlWithData> > GetAllEndpoints(HttpClient client, TestRun testRun)
        {
            var swaggerDocObject = await SwaggerClient.ReadSwagger(client, testRun);

            if (swaggerDocObject == null)
            {
                return(null);
            }
            return(Map(swaggerDocObject, testRun));
        }