Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created April 15, 2019 00:38
Show Gist options
  • Save yuka1984/5c0eeae36091151737b44de2263532a6 to your computer and use it in GitHub Desktop.
Save yuka1984/5c0eeae36091151737b44de2263532a6 to your computer and use it in GitHub Desktop.
using System.Net.Http;
using System.Threading.Tasks;
using AzureFunctions.Extensions.Swashbuckle;
using AzureFunctions.Extensions.Swashbuckle.Attribute;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
namespace SampleFunction
{
public static class SwaggerFunctions
{
[SwaggerIgnore]
[FunctionName("Swagger")]
public static Task<HttpResponseMessage> Swagger(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/json")]
HttpRequestMessage req,
[SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
{
return Task.FromResult(swashBuckleClient.CreateSwaggerDocumentResponse(req));
}
[SwaggerIgnore]
[FunctionName("SwaggerUi")]
public static Task<HttpResponseMessage> SwaggerUi(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/ui")]
HttpRequestMessage req,
[SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
{
return Task.FromResult(swashBuckleClient.CreateSwaggerUIResponse(req, "swagger/json"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment