unknown formatting changes?

This commit is contained in:
chris.watts90@outlook.com 2019-10-18 09:27:27 +01:00
parent 9f41286708
commit f286498540
7 changed files with 370 additions and 370 deletions

View File

@ -1,28 +1,28 @@
@using System.Web.Http.Description @using System.Web.Http.Description
@using DalSoft.WebApi.HelpPage @using DalSoft.WebApi.HelpPage
@model IGrouping<string, ApiDescription> @model IGrouping<string, ApiDescription>
<h2 id="@Model.Key">@Model.Key</h2> <h2 id="@Model.Key">@Model.Key</h2>
<table class="help-page-table"> <table class="help-page-table">
<thead> <thead>
<tr><th>API</th><th>Description</th></tr> <tr><th>API</th><th>Description</th></tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var api in Model) @foreach (var api in Model)
{ {
<tr> <tr>
<td class="api-name"><a href="@ViewBag.HelpRoute/api?apiId=@api.GetFriendlyId()">@api.HttpMethod.Method @api.RelativePath</a></td> <td class="api-name"><a href="@ViewBag.HelpRoute/api?apiId=@api.GetFriendlyId()">@api.HttpMethod.Method @api.RelativePath</a></td>
<td class="api-documentation"> <td class="api-documentation">
@if (api.Documentation !=null) @if (api.Documentation !=null)
{ {
<p>@api.Documentation</p> <p>@api.Documentation</p>
} }
else else
{ {
<p>No documentation available.</p> <p>No documentation available.</p>
} }
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</table> </table>

View File

@ -1,49 +1,49 @@
@using System.Collections.Generic @using System.Collections.Generic
@using System.Net.Http.Headers @using System.Net.Http.Headers
@using DalSoft.WebApi.HelpPage.Models @using DalSoft.WebApi.HelpPage.Models
@model HelpPageApiModel @model HelpPageApiModel
@{ @{
var description = Model.ApiDescription; var description = Model.ApiDescription;
var hasParameters = description.ParameterDescriptions.Count > 0; var hasParameters = description.ParameterDescriptions.Count > 0;
var hasRequestSamples = Model.SampleRequests.Count > 0; var hasRequestSamples = Model.SampleRequests.Count > 0;
var hasResponseSamples = Model.SampleResponses.Count > 0; var hasResponseSamples = Model.SampleResponses.Count > 0;
} }
<h1>@description.HttpMethod.Method @description.RelativePath</h1> <h1>@description.HttpMethod.Method @description.RelativePath</h1>
<div> <div>
@{ @{
if (description.Documentation != null) if (description.Documentation != null)
{ {
<p>@description.Documentation</p> <p>@description.Documentation</p>
} }
else else
{ {
<p>No documentation available.</p> <p>No documentation available.</p>
} }
if (hasParameters || hasRequestSamples) if (hasParameters || hasRequestSamples)
{ {
<h2>Request Information</h2> <h2>Request Information</h2>
if (hasParameters) if (hasParameters)
{ {
<h3>Parameters</h3> <h3>Parameters</h3>
@Include("Parameters.cshtml", Model, typeof(HelpPageApiModel)) @Include("Parameters.cshtml", Model, typeof(HelpPageApiModel))
} }
if (hasRequestSamples) if (hasRequestSamples)
{ {
<h3>Request body formats</h3> <h3>Request body formats</h3>
var ModelSamples = Model.SampleRequests; var ModelSamples = Model.SampleRequests;
@Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>)) @Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>))
} }
} }
if (hasResponseSamples) if (hasResponseSamples)
{ {
<h2>Response Information</h2> <h2>Response Information</h2>
<h3>Response body formats</h3> <h3>Response body formats</h3>
var ModelSamples = Model.SampleResponses; var ModelSamples = Model.SampleResponses;
@Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>)) @Include("Samples.cshtml", ModelSamples, typeof(IDictionary<MediaTypeHeaderValue, object>))
} }
} }
</div> </div>

View File

@ -1,55 +1,55 @@
@using System.Collections.ObjectModel @using System.Collections.ObjectModel
@using System.Threading @using System.Threading
@using System.Web.Http.Description @using System.Web.Http.Description
@{ Collection<ApiParameterDescription> parameters = Model.ApiDescription.ParameterDescriptions; } @{ Collection<ApiParameterDescription> parameters = Model.ApiDescription.ParameterDescriptions; }
@if (parameters.Count > 0) @if (parameters.Count > 0)
{ {
<table class="help-page-table"> <table class="help-page-table">
<thead> <thead>
<tr><th>Name</th><th>Description</th><th>Additional information</th></tr> <tr><th>Name</th><th>Description</th><th>Additional information</th></tr>
</thead> </thead>
<tbody> <tbody>
@{ @{
foreach (ApiParameterDescription parameter in parameters) foreach (ApiParameterDescription parameter in parameters)
{ {
var parameterDocumentation = parameter.Documentation ?? "No documentation available."; var parameterDocumentation = parameter.Documentation ?? "No documentation available.";
// Don't show CancellationToken because it's a special parameter // Don't show CancellationToken because it's a special parameter
if (!typeof (CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType)) if (!typeof (CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType))
{ {
<tr> <tr>
<td class="parameter-name">@parameter.Name</td> <td class="parameter-name">@parameter.Name</td>
<td class="parameter-documentation"> <td class="parameter-documentation">
<p>@parameterDocumentation</p> <p>@parameterDocumentation</p>
</td> </td>
<td class="parameter-type"> <td class="parameter-type">
@{ @{
switch (parameter.Source) switch (parameter.Source)
{ {
case ApiParameterSource.FromBody: case ApiParameterSource.FromBody:
<p>Define this parameter in the request <b>body</b>. <p>Define this parameter in the request <b>body</b>.
</p> </p>
break; break;
case ApiParameterSource.FromUri: case ApiParameterSource.FromUri:
<p>Define this parameter in the request <b>URI</b>. <p>Define this parameter in the request <b>URI</b>.
</p> </p>
break; break;
case ApiParameterSource.Unknown: case ApiParameterSource.Unknown:
default: default:
<p>None.</p> <p>None.</p>
break; break;
} }
} }
</td> </td>
</tr> </tr>
} }
} }
} }
</tbody> </tbody>
</table> </table>
} }
else else
{ {
<p>None.</p> <p>None.</p>
} }

View File

@ -1,37 +1,37 @@
@using System.Net.Http.Headers @using System.Net.Http.Headers
@using DalSoft.WebApi.HelpPage.SampleGeneration @using DalSoft.WebApi.HelpPage.SampleGeneration
@model IDictionary<MediaTypeHeaderValue, object> @model IDictionary<MediaTypeHeaderValue, object>
@{ @{
// Group the samples into a single tab if they are the same. // 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 samples = Model.GroupBy(x => x.Value).ToDictionary(x => string.Join(", ", x.Select(m => m.Key.ToString()).ToArray()), x => x.Key);
var mediaTypes = samples.Keys; var mediaTypes = samples.Keys;
} }
<div> <div>
@{ @{
foreach (var mediaType in mediaTypes) foreach (var mediaType in mediaTypes)
{ {
<h4 class="sample-header">@mediaType</h4> <h4 class="sample-header">@mediaType</h4>
<div class="sample-content"> <div class="sample-content">
<span><b>Sample:</b></span> <span><b>Sample:</b></span>
@{ var sample = samples[mediaType]; } @{ var sample = samples[mediaType]; }
@if (sample == null) @if (sample == null)
{ {
<p>Sample not available.</p> <p>Sample not available.</p>
} }
else if (sample is TextSample) else if (sample is TextSample)
{ {
<pre class="wrapped">@(((TextSample)sample).Text)</pre> <pre class="wrapped">@(((TextSample)sample).Text)</pre>
} }
else if (sample is ImageSample) else if (sample is ImageSample)
{ {
<img src="@(((ImageSample)sample).Src)"/> <img src="@(((ImageSample)sample).Src)"/>
} }
else if (sample is InvalidSample) else if (sample is InvalidSample)
{ {
<div class="warning-message-container">@(((InvalidSample)sample).ErrorMessage)</div> <div class="warning-message-container">@(((InvalidSample)sample).ErrorMessage)</div>
} }
</div> </div>
} }
} }
</div> </div>

View File

@ -1,134 +1,134 @@
.help-page h1, .help-page h1,
.help-page .h1, .help-page .h1,
.help-page h2, .help-page h2,
.help-page .h2, .help-page .h2,
.help-page h3, .help-page h3,
.help-page .h3, .help-page .h3,
#body.help-page, #body.help-page,
.help-page-table th, .help-page-table th,
.help-page-table pre, .help-page-table pre,
.help-page-table p { .help-page-table p {
font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
} }
.help-page pre.wrapped { .help-page pre.wrapped {
white-space: -moz-pre-wrap; white-space: -moz-pre-wrap;
white-space: -pre-wrap; white-space: -pre-wrap;
white-space: -o-pre-wrap; white-space: -o-pre-wrap;
white-space: pre-wrap; white-space: pre-wrap;
} }
.help-page .warning-message-container { .help-page .warning-message-container {
margin-top: 20px; margin-top: 20px;
padding: 0 10px; padding: 0 10px;
color: #525252; color: #525252;
background: #EFDCA9; background: #EFDCA9;
border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
} }
.help-page-table { .help-page-table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
text-align: left; text-align: left;
margin: 0px 0px 20px 0px; margin: 0px 0px 20px 0px;
border-top: 1px solid #D4D4D4; border-top: 1px solid #D4D4D4;
} }
.help-page-table th { .help-page-table th {
text-align: left; text-align: left;
font-weight: bold; font-weight: bold;
border-bottom: 1px solid #D4D4D4; border-bottom: 1px solid #D4D4D4;
padding: 5px 6px 5px 6px; padding: 5px 6px 5px 6px;
} }
.help-page-table td { .help-page-table td {
border-bottom: 1px solid #D4D4D4; border-bottom: 1px solid #D4D4D4;
padding: 10px 8px 10px 8px; padding: 10px 8px 10px 8px;
vertical-align: top; vertical-align: top;
} }
.help-page-table pre, .help-page-table pre,
.help-page-table p { .help-page-table p {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
font-family: inherit; font-family: inherit;
font-size: 100%; font-size: 100%;
} }
.help-page-table tbody tr:hover td { .help-page-table tbody tr:hover td {
background-color: #F3F3F3; background-color: #F3F3F3;
} }
.help-page a:hover { .help-page a:hover {
background-color: transparent; background-color: transparent;
} }
.help-page .sample-header { .help-page .sample-header {
border: 2px solid #D4D4D4; border: 2px solid #D4D4D4;
background: #00497E; background: #00497E;
color: #FFFFFF; color: #FFFFFF;
padding: 8px 15px; padding: 8px 15px;
border-bottom: none; border-bottom: none;
display: inline-block; display: inline-block;
margin: 10px 0px 0px 0px; margin: 10px 0px 0px 0px;
} }
.help-page .sample-content { .help-page .sample-content {
display: block; display: block;
border-width: 0; border-width: 0;
padding: 15px 20px; padding: 15px 20px;
background: #FFFFFF; background: #FFFFFF;
border: 2px solid #D4D4D4; border: 2px solid #D4D4D4;
margin: 0px 0px 10px 0px; margin: 0px 0px 10px 0px;
} }
.help-page .api-name { .help-page .api-name {
width: 40%; width: 40%;
} }
.help-page .api-documentation { .help-page .api-documentation {
width: 60%; width: 60%;
} }
.help-page .parameter-name { .help-page .parameter-name {
width: 20%; width: 20%;
} }
.help-page .parameter-documentation { .help-page .parameter-documentation {
width: 40%; width: 40%;
} }
.help-page .parameter-type { .help-page .parameter-type {
width: 20%; width: 20%;
} }
.help-page .parameter-annotations { .help-page .parameter-annotations {
width: 20%; width: 20%;
} }
.help-page h1, .help-page h1,
.help-page .h1 { .help-page .h1 {
font-size: 36px; font-size: 36px;
line-height: normal; line-height: normal;
} }
.help-page h2, .help-page h2,
.help-page .h2 { .help-page .h2 {
font-size: 24px; font-size: 24px;
} }
.help-page h3, .help-page h3,
.help-page .h3 { .help-page .h3 {
font-size: 20px; font-size: 20px;
} }
#body.help-page { #body.help-page {
font-size: 14px; font-size: 14px;
line-height: 143%; line-height: 143%;
color: #333; color: #333;
} }
.help-page a { .help-page a {
color: #0000EE; color: #0000EE;
text-decoration: none; text-decoration: none;
} }

View File

@ -1,28 +1,28 @@
@using DalSoft.WebApi.HelpPage.Models @using DalSoft.WebApi.HelpPage.Models
@model HelpPageApiModel @model HelpPageApiModel
@{ @{
var description = Model.ApiDescription; var description = Model.ApiDescription;
var title = description.HttpMethod.Method + " " + description.RelativePath; var title = description.HttpMethod.Method + " " + description.RelativePath;
} }
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>@title</title> <title>@title</title>
<link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" /> <link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" />
</head> </head>
<body> <body>
<div id="body" class="help-page"> <div id="body" class="help-page">
<section class="featured"> <section class="featured">
<div class="content-wrapper"> <div class="content-wrapper">
<p> <p>
<a href="/@ViewBag.HelpRoute">Help Page Home</a> <a href="/@ViewBag.HelpRoute">Help Page Home</a>
</p> </p>
</div> </div>
</section> </section>
<section class="content-wrapper main-content clear-fix"> <section class="content-wrapper main-content clear-fix">
@Include("HelpPageApiModel.cshtml", Model, typeof(HelpPageApiModel)) @Include("HelpPageApiModel.cshtml", Model, typeof(HelpPageApiModel))
</section> </section>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,43 +1,43 @@
@using System.Web.Http.Description @using System.Web.Http.Description
@using System.Collections.ObjectModel @using System.Collections.ObjectModel
@using System.Linq @using System.Linq
@model Collection<ApiDescription> @model Collection<ApiDescription>
@{ @{
ViewBag.Title = "ASP.NET Web API Help Page"; ViewBag.Title = "ASP.NET Web API Help Page";
// Group APIs by controller // Group APIs by controller
ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName); ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
} }
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>@ViewBag.Title</title> <title>@ViewBag.Title</title>
<link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" /> <link type="text/css" href="@ViewBag.HelpRoute/HelpPage_css" rel="stylesheet" />
</head> </head>
<body> <body>
<header class="help-page"> <header class="help-page">
<div class="content-wrapper"> <div class="content-wrapper">
<div class="float-left"> <div class="float-left">
<h1>@ViewBag.Title</h1> <h1>@ViewBag.Title</h1>
</div> </div>
</div> </div>
</header> </header>
<div id="body" class="help-page"> <div id="body" class="help-page">
<section class="featured"> <section class="featured">
<div class="content-wrapper"> <div class="content-wrapper">
<h2>Introduction</h2> <h2>Introduction</h2>
<p> <p>
Provide a general description of your APIs here. Provide a general description of your APIs here.
</p> </p>
</div> </div>
</section> </section>
<section class="content-wrapper main-content clear-fix"> <section class="content-wrapper main-content clear-fix">
@foreach (IGrouping<string, ApiDescription> controllerGroup in apiGroups) @foreach (IGrouping<string, ApiDescription> controllerGroup in apiGroups)
{ {
@Include("ApiGroup.cshtml", controllerGroup, typeof (IGrouping<string, ApiDescription>)) @Include("ApiGroup.cshtml", controllerGroup, typeof (IGrouping<string, ApiDescription>))
} }
</section> </section>
</div> </div>
</body> </body>
</html> </html>