-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/vitalybibikov/AzureExtensions.Swashbuckle?tab=read…
…me-ov-file
- Loading branch information
1 parent
63c3906
commit 9d68838
Showing
4 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using AzureFunctions.Extensions.Swashbuckle; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
public class SwaggerController | ||
{ | ||
private readonly ISwashBuckleClient swashBuckleClient; | ||
|
||
public SwaggerController(ISwashBuckleClient swashBuckleClient) | ||
{ | ||
this.swashBuckleClient = swashBuckleClient; | ||
} | ||
|
||
[SwaggerIgnore] | ||
[Function("SwaggerJson")] | ||
public async Task<HttpResponseData> SwaggerJson( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "Swagger/json")] | ||
HttpRequestData req) | ||
{ | ||
return await this.swashBuckleClient.CreateSwaggerJsonDocumentResponse(req); | ||
} | ||
|
||
[SwaggerIgnore] | ||
[Function("SwaggerYaml")] | ||
public async Task<HttpResponseData> SwaggerYaml( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "Swagger/yaml")] | ||
HttpRequestData req) | ||
{ | ||
return await this.swashBuckleClient.CreateSwaggerYamlDocumentResponse(req); | ||
} | ||
|
||
[SwaggerIgnore] | ||
[Function("SwaggerUi")] | ||
public async Task<HttpResponseData> SwaggerUi( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "Swagger/ui")] | ||
HttpRequestData req) | ||
{ | ||
return await this.swashBuckleClient.CreateSwaggerUIResponse(req, "swagger/json"); | ||
} | ||
|
||
/// <summary> | ||
/// This is only needed for OAuth2 client. This redirecting document is normally served | ||
/// as a static content. Functions don't provide this out of the box, so we serve it here. | ||
/// Don't forget to set OAuth2RedirectPath configuration option to reflect this route. | ||
/// </summary> | ||
/// <param name="req"></param> | ||
/// <param name="swashBuckleClient"></param> | ||
/// <returns></returns> | ||
[SwaggerIgnore] | ||
[Function("SwaggerOAuth2Redirect")] | ||
public async Task<HttpResponseData> SwaggerOAuth2Redirect( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/oauth2-redirect")] | ||
HttpRequestData req) | ||
{ | ||
return await this.swashBuckleClient.CreateSwaggerOAuth2RedirectResponse(req); | ||
} | ||
} |