Exemple #1
0
        public IReadOnlyCollection <SwaggerDefinition> Create(IReadOnlyCollection <IApiActionRegistration> registrations)
        {
            var typeQueue = new Queue <Type>(registrations
                                             .SelectMany(r => _responseInfoFactory.CreateResponses(r.ApiActionType)).Select(ri => ri.ResponseData)
                                             .Where(t => t != null).Select(t => _typeProvider.GetTypeToDocument(t)));

            // Add Requests to Queue


            var resultsLookup = new Dictionary <string, SwaggerDefinition>();

            while (typeQueue.Count > 0)
            {
                var type = typeQueue.Dequeue();
                var name = _definitionNameProvider.GetDefinitionName(type);

                if (!resultsLookup.ContainsKey(name))
                {
                    resultsLookup.Add(name, new SwaggerDefinition
                    {
                        Name   = name,
                        Schema = _schemaFactory.Create(type, type.GetTypeDetails().PropertyReaders, typeQueue)
                    });
                }
            }

            return(resultsLookup.Values.ToList());
        }
 private IApiActionInfo CreateInfo(Type apiActionType)
 {
     return(new ApiActionInfo
     {
         Summary = _summaryFactory.CreateSummary(apiActionType),
         Description = _descriptionFactory.CreateDescription(apiActionType),
         Methods = _requestMethodsFactory.CreateRequestMethods(apiActionType),
         RequestType = _requestTypeFactory.CreateRequestType(apiActionType),
         Responses = _responseInfoFactory.CreateResponses(apiActionType),
         Categories = _tagFactory.CreateCategories(apiActionType),
         IsDeprecated = _deprecationFactory.CreateIsDeprecated(apiActionType)
     });
 }