Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creating Custom Connector from Azure Functions with Swagger
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)
{
...
}
}
}
# PowerShell
(Invoke-WebRequest `
-Uri "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.ps1" `
-UseBasicParsing).Content | Out-File "scripts/Install-OpenApiHttpTriggerTemplates.ps1"
dotnet add <PROJECT> package Aliencube.AzureFunctions.Extensions.OpenApi
# Bash
curl -X GET "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.sh" > \
"scripts/Install-OpenApiHttpTriggerTemplates.sh"
# 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
# PowerShell
scripts/Install-OpenApiHttpTriggerTemplates.ps1 `
-ProjectPath <FUNCTION_APP_PROJECT> `
-Namespace <NAMESPACE>
# PowerShell
scripts/Install-OpenApiHttpTriggerTemplates.ps1 `
-ProjectPath <FUNCTION_APP_PROJECT> `
-Namespace <NAMESPACE>
-IsVersion1
# Bash
./scripts/Install-OpenApiHttpTriggerTemplates.sh \
<FUNCTION_APP_PROJECT> \
<NAMESPACE>
[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
You can’t perform that action at this time.