Skip to content

Commit

Permalink
Updates to reflect changes introduced by Swashbuckle 6.0.0-beta902 (d…
Browse files Browse the repository at this point in the history
…otnet#1794)

Thanks!
  • Loading branch information
domaindrivendev authored and spboyer committed Aug 21, 2016
1 parent 16ea69e commit ec28c0e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 44 deletions.
6 changes: 3 additions & 3 deletions aspnet/tutorials/web-api-help-pages-using-swagger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Understanding the various methods of an API can be a challenge for a developer w

Generating good documentation and help pages as a part of your Web API using `Swagger <a href="http://swagger.io/">`_ with the .NET Core implementation `Swashbuckle <a href="https://github.com/domaindrivendev/Ahoy">`_ is as easy as adding a couple of NuGet packages and modifying the *Startup.cs*.

- `Swashbuckle <a href="https://github.com/domaindrivendev/Ahoy">`_ is an open source project for generating Swagger documents for Web APIs and built with ASP.NET Core MVC.
- `Swashbuckle <a href="https://github.com/domaindrivendev/Ahoy">`_ is an open source project for generating Swagger documents for Web APIs that are built with ASP.NET Core MVC.

- `Swagger <a href="http://swagger.io/">`_ is a machine readable representation of a RESTful API that enables support for interactive documentation, client SDK generation and discoverability.

Expand All @@ -23,7 +23,7 @@ Getting Started
---------------
There are two core components to Swashbuckle

- *Swashbuckle.SwaggerGen* : provides the functionality to scaffold your Web API and generate JSON Swagger documents that describe the objects, methods, return types, etc.
- *Swashbuckle.SwaggerGen* : provides the functionality to generate JSON Swagger documents that describe the objects, methods, return types, etc.
- *Swashbuckle.SwaggerUI* : an embedded version of the Swagger UI tool which uses the above documents for a rich customizable experience for describing the Web API functionality and includes built in test harness capabilities for the public methods.

NuGet Packages
Expand All @@ -40,7 +40,7 @@ You can add Swashbuckle with any of the following approaches:

.. code-block:: javascript
"Swashbuckle": "6.0.0-*"
"Swashbuckle": "6.0.0-beta902"
- In Visual Studio:
- Right click your project in Solution Explorer > Manage NuGet Packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using Microsoft.AspNetCore.Mvc;
using TodoApi.Models;
using System.ComponentModel.DataAnnotations;
using System.Net;
using Swashbuckle.SwaggerGen.Annotations;

namespace TodoApi.Controllers
{
Expand Down Expand Up @@ -72,11 +70,11 @@ public IActionResult GetById(string id)
/// </remarks>
/// <param name="item"></param>
/// <returns>New Created Todo Item</returns>
/// <response code="201">Todo Item created</response>
/// <response code="400">Todo Item invalid</response>
/// <response code="201">Returns the newly created item</response>
/// <response code="400">If the item is null</response>
[HttpPost]
[SwaggerResponse(HttpStatusCode.Created, "Returns the newly created Todo item.", typeof(TodoItem))]
[SwaggerResponse(HttpStatusCode.BadRequest, "If the item is null", typeof(TodoItem))]
[ProducesResponseType(typeof(TodoItem), 201)]
[ProducesResponseType(typeof(TodoItem), 400)]
public IActionResult Create([FromBody, Required] TodoItem item)
{
if (item == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
"Swashbuckle": "6.0.0-beta901",
"Swashbuckle": "6.0.0-beta902",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*"
},
"frameworks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
<link href='custom.css' media='screen' rel='stylesheet' type='text/css' />

<script src='lib/object-assign-pollyfill.js' type='text/javascript'></script>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/handlebars-4.0.5.js' type='text/javascript'></script>
<script src='lib/lodash.min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script src='swagger-ui.min.js' type='text/javascript'></script>
<script src='lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
<script src='lib/highlight.9.1.0.pack_extended.js' type='text/javascript'></script>
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
<script src='lib/marked.js' type='text/javascript'></script>
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
Expand All @@ -32,19 +35,17 @@

<script type="text/javascript">
$(function () {
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "/swagger/v1/swagger.json";
}

hljs.configure({
highlightSizeThreshold: 5000
});

// Pre load translate...
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
window.swaggerUi = new SwaggerUi({
url: url,
url: "/swagger/v1/swagger.json",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
Expand All @@ -62,12 +63,6 @@
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}

$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});

addApiKeyAuthorization();
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
Expand All @@ -79,23 +74,6 @@
showRequestHeaders: false
});

function addApiKeyAuthorization(){
var key = encodeURIComponent($('#input_apiKey')[0].value);
if(key && key.trim() != "") {
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
log("added key " + key);
}
}

$('#input_apiKey').change(addApiKeyAuthorization);

// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
*/

window.swaggerUi.load();

function log() {
Expand Down

0 comments on commit ec28c0e

Please sign in to comment.