Last active
February 8, 2021 07:42
-
-
Save justinyoo/2b4bc731ff8f2cdb5e80e28bd7dff9e7 to your computer and use it in GitHub Desktop.
Creating Custom Connector from Azure Functions with Swagger
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
namespace FeedReaders.FunctionApp | |
{ | |
public static class FeedReaderHttpTrigger | |
{ | |
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemsAsync))] | |
public static async Task<IActionResult> GetFeedItemsAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/items")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} | |
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemAsync))] | |
public async Task<IActionResult> GetFeedItemAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/item")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} | |
} | |
} |
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
# PowerShell | |
(Invoke-WebRequest ` | |
-Uri "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.ps1" ` | |
-UseBasicParsing).Content | Out-File "scripts/Install-OpenApiHttpTriggerTemplates.ps1" |
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
dotnet add <PROJECT> package Microsoft.Azure.WebJobs.Extensions.OpenApi |
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
dotnet add <PROJECT> package Aliencube.AzureFunctions.Extensions.OpenApi |
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
# Bash | |
curl -X GET "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.sh" > \ | |
"scripts/Install-OpenApiHttpTriggerTemplates.sh" |
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
# Bash | |
curl -X GET "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.sh" > \ | |
"scripts/Install-OpenApiHttpTriggerTemplates.sh" | |
chmod +x scripts/Install-OpenApiHttpTriggerTemplates.sh |
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
# PowerShell | |
scripts/Install-OpenApiHttpTriggerTemplates.ps1 ` | |
-ProjectPath <FUNCTION_APP_PROJECT> ` | |
-Namespace <NAMESPACE> |
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
# PowerShell | |
scripts/Install-OpenApiHttpTriggerTemplates.ps1 ` | |
-ProjectPath <FUNCTION_APP_PROJECT> ` | |
-Namespace <NAMESPACE> | |
-IsVersion1 |
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
# Bash | |
./scripts/Install-OpenApiHttpTriggerTemplates.sh \ | |
<FUNCTION_APP_PROJECT> \ | |
<NAMESPACE> |
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
[OpenApiOperation(operationId: "getFeedItems", tags: new[] { "feedItem" }, Summary = "Gets a list of feed items from the given feed", Description = "This operation returns a list of feed items from the given feed URI.", Visibility = OpenApiVisibilityType.Important)] | |
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "x-functions-key", In = OpenApiSecurityLocationType.Header)] | |
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(FeedReaderRequest), Description = "Feed reader request payload")] | |
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List<FeedReaderResponse>), Summary = "List of feed reader response payload")] | |
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemsAsync))] | |
public static async Task<IActionResult> GetFeedItemsAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/items")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} | |
[OpenApiOperation(operationId: "getFeedItem", tags: new[] { "feedItem" }, Summary = "Gets a single feed item from the given feed", Description = "This operation returns a single feed item from the given feed URI.", Visibility = OpenApiVisibilityType.Important)] | |
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "x-functions-key", In = OpenApiSecurityLocationType.Header)] | |
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(FeedReaderRequest), Description = "Feed reader request payload")] | |
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(FeedReaderResponse), Summary = "Feed reader response payload")] | |
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemAsync))] | |
public async Task<IActionResult> GetFeedItemAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/item")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} |
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
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemsAsync))] | |
[OpenApiOperation(operationId: "getFeedItems", tags: new[] { "feedItem" }, Summary = "Gets a list of feed items from the given feed", Description = "This operation returns a list of feed items from the given feed URI.", Visibility = OpenApiVisibilityType.Important)] | |
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(FeedReaderRequest), Description = "Feed reader request payload")] | |
[OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List<FeedReaderResponse>), Summary = "List of feed reader response payload")] | |
public static async Task<IActionResult> GetFeedItemsAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/items")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} | |
[FunctionName(nameof(FeedReaderHttpTrigger.GetFeedItemAsync))] | |
[OpenApiOperation(operationId: "getFeedItem", tags: new[] { "feedItem" }, Summary = "Gets a single feed item from the given feed", Description = "This operation returns a single feed item from the given feed URI.", Visibility = OpenApiVisibilityType.Important)] | |
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(FeedReaderRequest), Description = "Feed reader request payload")] | |
[OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(FeedReaderResponse), Summary = "Feed reader response payload")] | |
public async Task<IActionResult> GetFeedItemAsync( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "feeds/item")] HttpRequest req, | |
ILogger log) | |
{ | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment