public SwaggerRoot GetSwaggerJson()
        {
            var builder = new SwaggerRootBuilder();

            foreach (var pathItem in this.RetrieveSwaggerPaths())
            {
                builder.Path(pathItem.Key, pathItem.Value.PathItem);
            }

            builder.Info(_info);

            foreach (var model in RetrieveSwaggerModels())
            {
                var name = SwaggerBuilderConfig.ModelIdConvention(model.ModelType);
                builder.Definition(name, model.GetSchema());
            }

            foreach (var tag in RetrieveSwaggerTags())
            {
                builder.Tag(tag);
            }


            foreach (var securityScheme in _securitySchemes)
            {
                builder.SecurityDefinition(securityScheme.Key, securityScheme.Value.Build());
            }

            return(builder.Build());
        }
        public SwaggerRoot GetSwaggerJson(NancyContext context)
        {
            var builder = new SwaggerRootBuilder();

            foreach (var pathItem in this.RetrieveSwaggerPaths(context))
            {
                builder.Path(pathItem.Key, pathItem.Value.PathItem);
            }

            //foreach (var model in this.RetrieveSwaggerModels())
            //{
            //    builder.Definition(model.ModelType.Name, model.);
            //}

            builder.Info(_info);

            foreach (var model in RetrieveSwaggerModels())
            {
                Type   t    = GetType(model.ModelType);
                String name = model.ModelType.Name;
                if (t != model.ModelType)
                {
                    name = t.Name + "[]";
                }
                builder.Definition(name, model.GetSchema());
            }

            foreach (var tag in RetrieveSwaggerTags())
            {
                builder.Tag(tag);
            }


            foreach (var securityScheme in _securitySchemes)
            {
                builder.SecurityDefinition(securityScheme.Key, securityScheme.Value.Build());
            }

            return(builder.Build());
        }
        public SwaggerRoot GetSwaggerJson()
        {
            var builder = new SwaggerRootBuilder();

            foreach (var pathItem in this.RetrieveSwaggerPaths())
            {
                builder.Path(pathItem.Key, pathItem.Value.PathItem);
            }

            //foreach (var model in this.RetrieveSwaggerModels())
            //{
            //    builder.Definition(model.ModelType.Name, model.);
            //}

            builder.Info(_info);
            
            foreach (var model in RetrieveSwaggerModels())
            {
                Type t = GetType(model.ModelType);
                String name = model.ModelType.Name;
                if (t != model.ModelType) name = t.Name + "[]";
                builder.Definition(name, model.GetSchema());
            }

            foreach (var tag in RetrieveSwaggerTags())
            {
                builder.Tag(tag);
            }


            foreach (var securityScheme in _securitySchemes)
            {
                builder.SecurityDefinition(securityScheme.Key, securityScheme.Value.Build());
            }

            return builder.Build();
        }
Exemple #4
0
        public SwaggerRoot GetSwaggerJson(NancyContext context)
        {
            var builder = new SwaggerRootBuilder();

            foreach (var pathItem in this.RetrieveSwaggerPaths(context))
            {
                builder.Path(pathItem.Key, pathItem.Value.PathItem);
            }

            builder.Info(_info);

            foreach (var model in RetrieveSwaggerModels())
            {
                // arrays do not have to be defined in definitions, they are already being declared fully inline
                // either they should use #ref or they shouldn't be in definitions
                if (model.ModelType.IsContainer())
                {
                    continue;
                }

                builder.Definition(SwaggerConfig.ModelIdConvention(model.ModelType), model.GetSchema(true));
            }

            foreach (var tag in RetrieveSwaggerTags())
            {
                builder.Tag(tag);
            }


            foreach (var securityScheme in _securitySchemes)
            {
                builder.SecurityDefinition(securityScheme.Key, securityScheme.Value.Build());
            }

            return(builder.Build());
        }
        public SwaggerRoot GetSwaggerJson(NancyContext context)
        {
            var builder = new SwaggerRootBuilder();

            if (_swaggerRoot?.Host != null)
            {
                builder.Host(_swaggerRoot.Host);
            }

            if (_swaggerRoot?.BasePath != null)
            {
                builder.BasePath(_swaggerRoot.BasePath);
            }

            if (_swaggerRoot?.Schemes != null)
            {
                _swaggerRoot.Schemes.ToList().ForEach(x => builder.Scheme(x));
            }

            if (_swaggerRoot?.Consumes != null)
            {
                builder.ConsumeMimeTypes(_swaggerRoot.Consumes);
            }

            if (_swaggerRoot?.Produces != null)
            {
                builder.ProduceMimeTypes(_swaggerRoot.Produces);
            }

            if (_swaggerRoot?.ExternalDocumentation != null)
            {
                builder.ExternalDocumentation(_swaggerRoot.ExternalDocumentation);
            }

            foreach (var pathItem in this.RetrieveSwaggerPaths(context))
            {
                builder.Path(pathItem.Key, pathItem.Value.PathItem);
            }

            builder.Info(_info);

            foreach (var model in RetrieveSwaggerModels())
            {
                // arrays do not have to be defined in definitions, they are already being declared fully inline
                // either they should use #ref or they shouldn't be in definitions
                if (model.ModelType.IsContainer())
                {
                    continue;
                }

                builder.Definition(SwaggerConfig.ModelIdConvention(model.ModelType), model.GetSchema(true));
            }

            foreach (var tag in RetrieveSwaggerTags().OrderBy(x => x.Name))
            {
                builder.Tag(tag);
            }


            foreach (var securityScheme in _securitySchemes)
            {
                builder.SecurityDefinition(securityScheme.Key, securityScheme.Value.Build());
            }

            return(builder.Build());
        }
Exemple #6
0
 public SwaggerRootBuilderTest()
 {
     this.builder = new SwaggerRootBuilder();
 }