added static files owin host and dalsoft webapi help pages package manually to merge in branch. (preventing app from running after merge otherwise, no idea why)
This commit is contained in:
parent
de57353511
commit
ff20c6abdf
@ -0,0 +1,28 @@
|
|||||||
|
@using System.Web.Http.Description
|
||||||
|
@using DalSoft.WebApi.HelpPage
|
||||||
|
@model IGrouping<string, ApiDescription>
|
||||||
|
|
||||||
|
<h2 id="@Model.Key">@Model.Key</h2>
|
||||||
|
<table class="help-page-table">
|
||||||
|
<thead>
|
||||||
|
<tr><th>API</th><th>Description</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var api in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td class="api-name"><a href="@ViewBag.HelpRoute/api?apiId=@api.GetFriendlyId()">@api.HttpMethod.Method @api.RelativePath</a></td>
|
||||||
|
<td class="api-documentation">
|
||||||
|
@if (api.Documentation !=null)
|
||||||
|
{
|
||||||
|
<p>@api.Documentation</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>No documentation available.</p>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
@using System.Collections.Generic
|
||||||
|
@using System.Net.Http.Headers
|
||||||
|
@using DalSoft.WebApi.HelpPage.Models
|
||||||
|
|
||||||
|
@model HelpPageApiModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
var description = Model.ApiDescription;
|
||||||
|
var hasParameters = description.ParameterDescriptions.Count > 0;
|
||||||
|
var hasRequestSamples = Model.SampleRequests.Count > 0;
|
||||||
|
var hasResponseSamples = Model.SampleResponses.Count > 0;
|
||||||
|
}
|
||||||
|
<h1>@description.HttpMethod.Method @description.RelativePath</h1>
|
||||||
|
<div>
|
||||||
|
@{
|
||||||
|
if (description.Documentation != null)
|
||||||
|
{
|
||||||
|
<p>@description.Documentation</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>No documentation available.</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasParameters || hasRequestSamples)
|
||||||
|
{
|
||||||
|
<h2>Request Information</h2>
|
||||||
|
if (hasParameters)
|
||||||
|
{
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
@Include("Parameters.cshtml", Model, typeof(HelpPageApiModel))
|
||||||
|
}
|
||||||
|
if (hasRequestSamples)
|
||||||
|
{
|
||||||
|
<h3>Request body formats</h3>
|
||||||
|
var ModelSamples = Model.SampleRequests;
|
||||||
|
@Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasResponseSamples)
|
||||||
|
{
|
||||||
|
<h2>Response Information</h2>
|
||||||
|
<h3>Response body formats</h3>
|
||||||
|
var ModelSamples = Model.SampleResponses;
|
||||||
|
@Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
@using System.Collections.ObjectModel
|
||||||
|
@using System.Threading
|
||||||
|
@using System.Web.Http.Description
|
||||||
|
|
||||||
|
@{ Collection<ApiParameterDescription> parameters = Model.ApiDescription.ParameterDescriptions; }
|
||||||
|
@if (parameters.Count > 0)
|
||||||
|
{
|
||||||
|
<table class="help-page-table">
|
||||||
|
<thead>
|
||||||
|
<tr><th>Name</th><th>Description</th><th>Additional information</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@{
|
||||||
|
foreach (ApiParameterDescription parameter in parameters)
|
||||||
|
{
|
||||||
|
var parameterDocumentation = parameter.Documentation ?? "No documentation available.";
|
||||||
|
|
||||||
|
// Don't show CancellationToken because it's a special parameter
|
||||||
|
if (!typeof (CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType))
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td class="parameter-name">@parameter.Name</td>
|
||||||
|
<td class="parameter-documentation">
|
||||||
|
<p>@parameterDocumentation</p>
|
||||||
|
</td>
|
||||||
|
<td class="parameter-type">
|
||||||
|
@{
|
||||||
|
switch (parameter.Source)
|
||||||
|
{
|
||||||
|
case ApiParameterSource.FromBody:
|
||||||
|
<p>Define this parameter in the request <b>body</b>.
|
||||||
|
</p>
|
||||||
|
break;
|
||||||
|
case ApiParameterSource.FromUri:
|
||||||
|
<p>Define this parameter in the request <b>URI</b>.
|
||||||
|
</p>
|
||||||
|
break;
|
||||||
|
case ApiParameterSource.Unknown:
|
||||||
|
default:
|
||||||
|
<p>None.</p>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>None.</p>
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
@using System.Net.Http.Headers
|
||||||
|
@using DalSoft.WebApi.HelpPage.SampleGeneration
|
||||||
|
@model IDictionary<MediaTypeHeaderValue, object>
|
||||||
|
|
||||||
|
@{
|
||||||
|
// Group the samples into a single tab if they are the same.
|
||||||
|
var samples = Model.GroupBy(x => x.Value).ToDictionary(x => string.Join(", ", x.Select(m => m.Key.ToString()).ToArray()), x => x.Key);
|
||||||
|
var mediaTypes = samples.Keys;
|
||||||
|
}
|
||||||
|
<div>
|
||||||
|
@{
|
||||||
|
foreach (var mediaType in mediaTypes)
|
||||||
|
{
|
||||||
|
<h4 class="sample-header">@mediaType</h4>
|
||||||
|
<div class="sample-content">
|
||||||
|
<span><b>Sample:</b></span>
|
||||||
|
@{ var sample = samples[mediaType]; }
|
||||||
|
@if (sample == null)
|
||||||
|
{
|
||||||
|
<p>Sample not available.</p>
|
||||||
|
}
|
||||||
|
else if (sample is TextSample)
|
||||||
|
{
|
||||||
|
<pre class="wrapped">@(((TextSample)sample).Text)</pre>
|
||||||
|
}
|
||||||
|
else if (sample is ImageSample)
|
||||||
|
{
|
||||||
|
<img src="@(((ImageSample)sample).Src)"/>
|
||||||
|
}
|
||||||
|
else if (sample is InvalidSample)
|
||||||
|
{
|
||||||
|
<div class="warning-message-container">@(((InvalidSample)sample).ErrorMessage)</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@ -0,0 +1,134 @@
|
|||||||
|
.help-page h1,
|
||||||
|
.help-page .h1,
|
||||||
|
.help-page h2,
|
||||||
|
.help-page .h2,
|
||||||
|
.help-page h3,
|
||||||
|
.help-page .h3,
|
||||||
|
#body.help-page,
|
||||||
|
.help-page-table th,
|
||||||
|
.help-page-table pre,
|
||||||
|
.help-page-table p {
|
||||||
|
font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page pre.wrapped {
|
||||||
|
white-space: -moz-pre-wrap;
|
||||||
|
white-space: -pre-wrap;
|
||||||
|
white-space: -o-pre-wrap;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .warning-message-container {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 0 10px;
|
||||||
|
color: #525252;
|
||||||
|
background: #EFDCA9;
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
text-align: left;
|
||||||
|
margin: 0px 0px 20px 0px;
|
||||||
|
border-top: 1px solid #D4D4D4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page-table th {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 1px solid #D4D4D4;
|
||||||
|
padding: 5px 6px 5px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page-table td {
|
||||||
|
border-bottom: 1px solid #D4D4D4;
|
||||||
|
padding: 10px 8px 10px 8px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page-table pre,
|
||||||
|
.help-page-table p {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page-table tbody tr:hover td {
|
||||||
|
background-color: #F3F3F3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page a:hover {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .sample-header {
|
||||||
|
border: 2px solid #D4D4D4;
|
||||||
|
background: #00497E;
|
||||||
|
color: #FFFFFF;
|
||||||
|
padding: 8px 15px;
|
||||||
|
border-bottom: none;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 10px 0px 0px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .sample-content {
|
||||||
|
display: block;
|
||||||
|
border-width: 0;
|
||||||
|
padding: 15px 20px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 2px solid #D4D4D4;
|
||||||
|
margin: 0px 0px 10px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .api-name {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .api-documentation {
|
||||||
|
width: 60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .parameter-name {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .parameter-documentation {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .parameter-type {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page .parameter-annotations {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page h1,
|
||||||
|
.help-page .h1 {
|
||||||
|
font-size: 36px;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page h2,
|
||||||
|
.help-page .h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page h3,
|
||||||
|
.help-page .h3 {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#body.help-page {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 143%;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-page a {
|
||||||
|
color: #0000EE;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
@using DalSoft.WebApi.HelpPage.Models
|
||||||
|
@model HelpPageApiModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
var description = Model.ApiDescription;
|
||||||
|
var title = description.HttpMethod.Method + " " + description.RelativePath;
|
||||||
|
}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>@title</title>
|
||||||
|
<link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="body" class="help-page">
|
||||||
|
<section class="featured">
|
||||||
|
<div class="content-wrapper">
|
||||||
|
<p>
|
||||||
|
<a href="/@ViewBag.HelpRoute">Help Page Home</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="content-wrapper main-content clear-fix">
|
||||||
|
@Include("HelpPageApiModel.cshtml", Model, typeof(HelpPageApiModel))
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
@using System.Web.Http.Description
|
||||||
|
@using System.Collections.ObjectModel
|
||||||
|
@using System.Linq
|
||||||
|
@model Collection<ApiDescription>
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "ASP.NET Web API Help Page";
|
||||||
|
|
||||||
|
// Group APIs by controller
|
||||||
|
ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
|
||||||
|
}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>@ViewBag.Title</title>
|
||||||
|
<link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="help-page">
|
||||||
|
<div class="content-wrapper">
|
||||||
|
<div class="float-left">
|
||||||
|
<h1>@ViewBag.Title</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div id="body" class="help-page">
|
||||||
|
<section class="featured">
|
||||||
|
<div class="content-wrapper">
|
||||||
|
<h2>Introduction</h2>
|
||||||
|
<p>
|
||||||
|
Provide a general description of your APIs here.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="content-wrapper main-content clear-fix">
|
||||||
|
@foreach (IGrouping<string, ApiDescription> controllerGroup in apiGroups)
|
||||||
|
{
|
||||||
|
@Include("ApiGroup.cshtml", controllerGroup, typeof (IGrouping<string, ApiDescription>))
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="DalSoft.WebApi.HelpPage" version="0.0.7.0" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
|
||||||
@ -12,4 +14,5 @@
|
|||||||
<package id="Ninject.Web.Common" version="3.2.0.0" targetFramework="net452" />
|
<package id="Ninject.Web.Common" version="3.2.0.0" targetFramework="net452" />
|
||||||
<package id="Ninject.Web.WebApi" version="3.2.4.0" targetFramework="net452" />
|
<package id="Ninject.Web.WebApi" version="3.2.4.0" targetFramework="net452" />
|
||||||
<package id="Owin" version="1.0" targetFramework="net452" />
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
|
<package id="RazorEngine" version="3.7.2" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
@ -1,4 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.Owin.FileSystems" version="3.0.1" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net452" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.Owin.StaticFiles" version="3.0.1" targetFramework="net452" />
|
||||||
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
Reference in New Issue
Block a user