public object CreateModel(Type type) { var properties = new Dictionary <string, object>(); if (type.IsEnum) { var allowableVals = new AllowableValues(type); var itemDocs = _docProvider.GetDocumentation(type); var item = new { allowableValues = allowableVals, description = itemDocs, type = "string" }; properties["PossibleValues"] = item; } else { foreach (var prop in type.GetProperties()) { properties[prop.Name] = GetProperty(prop); } } return(new ApiModel { id = type.Name, properties = properties, description = _docProvider.GetDocumentation(type) }); }
public void GetModels() { Setup(); // Act var result = _docProvider.GetDocumentation(typeof(BlogPost)); Assert.IsNotNull(result, "Result is null"); Debug.WriteLine(JsonConvert.SerializeObject(result)); }
public ApiDeclaration CreateApiDeclaration(string rootUrl, HttpControllerDescriptor controller) { var rootCtlrName = controller.ControllerName; var apiDescripts = GetFilteredApiDescriptions(rootCtlrName); var dataModels = _modelFactory.GetModels(apiDescripts); var apis = CreateApis(apiDescripts, rootCtlrName); var docs = _docProvider.GetDocumentation(controller.ControllerType); return(new ApiDeclaration() { description = docs, swaggerVersion = G.SWAGGER_VERSION, basePath = rootUrl + _appVirtualPath, resourcePath = controller.ControllerName, apis = apis.ToList(), models = dataModels, apiVersion = Assembly.GetCallingAssembly().GetName().Version.ToString() }); }