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()); }