// [Test]
        public void someTest1()
        {
            var swaggerModels = SwaggerJsonModel.CreateApiModels(JSON);


            swaggerModels.ForEach(model => SwaggerJsonModel.GetTests(model).CreateTests());
        }
Beispiel #2
0
        private List <EndpointInfo> PrepareDocumentationEntries(IEnumerable <string> endpointFiltersStrings, SwaggerJsonModel swaggerJsonJsonModel)
        {
            Logger.Info("Preparing endpoint information");
            var endpointFilters         = endpointFiltersStrings?.Select(EndpointFilterFactory.CreateEndpointFilter).ToList() ?? new List <EndpointFilter>();
            var schemaResolutionContext = _referenceResolver.CreateResolutionContext();

            var swaggerPdfEndpointList = swaggerJsonJsonModel.Paths
                                         .SelectMany(path => BuildEndpointEntry(path, schemaResolutionContext))
                                         .ToList();

            if (!endpointFilters.Any())
            {
                Logger.Info($"No filters applied, endpoints obtained: {swaggerPdfEndpointList.Count}");
                return(swaggerPdfEndpointList);
            }

            var filteredSwaggerPdfEndpointList = new List <EndpointInfo>(swaggerPdfEndpointList.Capacity);

            foreach (var endpointFilter in endpointFilters)
            {
                Logger.Info($"Applying filter to endpoint documentation: {endpointFilter.EndpointFilterString}");
                filteredSwaggerPdfEndpointList.AddRange(swaggerPdfEndpointList.Where(e => endpointFilter.MatchEndpoint(e.HttpMethod, e.EndpointPath)));
            }

            Logger.Info($"Got endpoints: {swaggerPdfEndpointList.Count}, after filtering {filteredSwaggerPdfEndpointList.Count} left");
            return(filteredSwaggerPdfEndpointList);
        }
Beispiel #3
0
 private static Dictionary <string, AuthorizationInfo> PrepareAuthorizationInfos(SwaggerJsonModel swaggerJsonJsonModel)
 {
     return(swaggerJsonJsonModel.SecurityDefinitions.ToDictionary(x => x.Key, x => x.Value.CreateAuthorizationInfo()));
 }