Exemplo n.º 1
0
 public DocResult(ApiDocumentation vocab, string format, HttpRequestMessage request, string docRoot)
 {
     _vocab = vocab;
     _format = format;
     _request = request;
     _docRoot = docRoot;
 }
Exemplo n.º 2
0
 private HttpContent GetStringContent(ApiDocumentation vocab, string format, string docDir)
 {
     var sbMain = new StringBuilder();
     sbMain.Heading(format, 1, "Vocab");
     foreach (var clazz in vocab.SupportedClasses)
     {
         var sb = new StringBuilder();
         sb.Heading(format, 1, clazz.Label);
         if (!string.IsNullOrWhiteSpace(clazz.UnstableNote))
         {
             sb.Para(format, clazz.UnstableNote, true);
         }
         sb.Para(format, clazz.Description);
         sb.Code(format, clazz.UriTemplate);
         if (clazz.SupportedOperations != null && clazz.SupportedOperations.Length > 0)
         {
             sb.Heading(format, 2, "Supported operations");
             // sb.Code(format, clazz.UriTemplate);
             AppendSupportedOperationsTable(sb, format, clazz.SupportedOperations);
         }
         if (clazz.SupportedProperties != null && clazz.SupportedProperties.Length > 0)
         {
             sb.Heading(format, 2, "Supported properties");
             foreach (SupportedProperty prop in clazz.SupportedProperties)
             {
                 var linkProp = prop.Property as HydraLinkProperty;
                 if (linkProp != null)
                 {
                     sb.Heading(format, 3, prop.Title + " (🔗)");
                 }
                 else
                 {
                     sb.Heading(format, 3, prop.Title);
                 }
                 sb.Para(format, prop.Description);
                 if (!string.IsNullOrWhiteSpace(prop.UnstableNote))
                 {
                     sb.Para(format, prop.UnstableNote, true);
                 }
                 sb.StartTable(format, "domain", "range", "readonly", "writeonly");
                 sb.TableRow(format, NameSpace(prop.Property.Domain), NameSpace(prop.Property.Range), prop.ReadOnly.ToString(), prop.WriteOnly.ToString());
                 sb.EndTable(format);
                 if (linkProp != null)
                 {
                     sb.Code(format, clazz.UriTemplate + "/" + linkProp.Label);
                     AppendSupportedOperationsTable(sb, format, linkProp.SupportedOperations);
                 }
             }
         }
         string classDoc = sb.ToString();
         WriteDocToDisk(format, docDir, clazz, classDoc);
         sbMain.Append(classDoc);
     }
     return new StringContent(sbMain.ToString(), Encoding.UTF8, "text/" + format);
 }
Exemplo n.º 3
0
 public IHttpActionResult Vocab(string format = null)
 {
     EnsureClasses();
     var classes = _supportedClasses.Values.Cast<Class>().ToArray();
     var vocab = new ApiDocumentation(Constants.Vocab, Constants.Vocab, classes);
     if (format != null)
     {
         string docRoot = System.Web.Hosting.HostingEnvironment.MapPath("~/Generated-Docs");
         return new DocResult(vocab, format, Request, docRoot);
     }
     return Json(vocab);
 }