From 91a020df4f1aafa655fc968dd4689852f8367251 Mon Sep 17 00:00:00 2001 From: Justin Yoo Date: Sun, 19 Jul 2020 15:23:56 +0900 Subject: [PATCH] Add Swagger Pet Store samples --- Aliencube.AzureFunctions.Extensions.sln | 15 ++- .../ApiResponse.cs | 23 +++++ .../Category.cs | 18 ++++ .../Order.cs | 40 ++++++++ .../OrderStatus.cs | 27 ++++++ .../Pet.cs | 44 +++++++++ .../PetStatus.cs | 27 ++++++ .../Tag.cs | 18 ++++ .../User.cs | 48 ++++++++++ ...ube.AzureFunctions.FunctionAppV1IoC.csproj | 15 ++- .../PetStoreHttpTrigger.cs | 90 ++++++++++++++++++ .../SampleHttpTrigger.cs | 4 +- ....AzureFunctions.FunctionAppV1Static.csproj | 14 ++- .../PetStoreHttpTrigger.cs | 83 +++++++++++++++++ .../SampleHttpTrigger.cs | 6 +- .../.gitignore | 2 +- ...ube.AzureFunctions.FunctionAppV2IoC.csproj | 14 ++- .../PetStoreHttpTrigger.cs | 93 +++++++++++++++++++ .../SampleHttpTrigger.cs | 2 +- .../local.settings.json | 9 ++ .../.gitignore | 2 +- ....AzureFunctions.FunctionAppV2Static.csproj | 14 ++- .../PetStoreHttpTrigger.cs | 84 +++++++++++++++++ .../SampleHttpTrigger.cs | 2 +- .../local.settings.json | 9 ++ ...ube.AzureFunctions.FunctionAppV3IoC.csproj | 14 ++- .../PetStoreHttpTrigger.cs | 93 +++++++++++++++++++ .../SampleHttpTrigger.cs | 2 +- ....AzureFunctions.FunctionAppV3Static.csproj | 14 ++- .../PetStoreHttpTrigger.cs | 84 +++++++++++++++++ .../SampleHttpTrigger.cs | 2 +- ...e.AzureFunctions.Extensions.OpenApi.csproj | 1 + .../OpenApiEndpints/OpenApiHttpTriggerV1.cs | 12 +-- 33 files changed, 901 insertions(+), 24 deletions(-) create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/ApiResponse.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/Category.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/Order.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/OrderStatus.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/Pet.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/PetStatus.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/Tag.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionApp.Models/User.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV1IoC/PetStoreHttpTrigger.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV1Static/PetStoreHttpTrigger.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV2IoC/PetStoreHttpTrigger.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV2IoC/local.settings.json create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV2Static/PetStoreHttpTrigger.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV2Static/local.settings.json create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV3IoC/PetStoreHttpTrigger.cs create mode 100644 samples/Aliencube.AzureFunctions.FunctionAppV3Static/PetStoreHttpTrigger.cs diff --git a/Aliencube.AzureFunctions.Extensions.sln b/Aliencube.AzureFunctions.Extensions.sln index 196d492..77a437d 100644 --- a/Aliencube.AzureFunctions.Extensions.sln +++ b/Aliencube.AzureFunctions.Extensions.sln @@ -69,9 +69,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aliencube.AzureFunctions.Fu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aliencube.AzureFunctions.FunctionAppV1IoC", "samples\Aliencube.AzureFunctions.FunctionAppV1IoC\Aliencube.AzureFunctions.FunctionAppV1IoC.csproj", "{7FD855AB-EB0E-42AE-A26D-E164D375D6A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aliencube.AzureFunctions.FunctionAppV2Static", "samples\Aliencube.AzureFunctions.FunctionAppV2Static\Aliencube.AzureFunctions.FunctionAppV2Static.csproj", "{848EDB8F-9C45-462B-A544-EA237774F3BA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aliencube.AzureFunctions.FunctionAppV2Static", "samples\Aliencube.AzureFunctions.FunctionAppV2Static\Aliencube.AzureFunctions.FunctionAppV2Static.csproj", "{848EDB8F-9C45-462B-A544-EA237774F3BA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aliencube.AzureFunctions.FunctionAppV2IoC", "samples\Aliencube.AzureFunctions.FunctionAppV2IoC\Aliencube.AzureFunctions.FunctionAppV2IoC.csproj", "{D6C3806E-2685-4E8D-9F4F-7A93E5270891}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aliencube.AzureFunctions.FunctionAppV2IoC", "samples\Aliencube.AzureFunctions.FunctionAppV2IoC\Aliencube.AzureFunctions.FunctionAppV2IoC.csproj", "{D6C3806E-2685-4E8D-9F4F-7A93E5270891}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{56A43630-87E6-4E94-B24A-859258202578}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenApiEndpoints", "OpenApiEndpoints", "{41695443-A292-4909-89A6-2D9846753164}" + ProjectSection(SolutionItems) = preProject + templates\OpenApiEndpints\IOpenApiHttpTriggerContext.cs = templates\OpenApiEndpints\IOpenApiHttpTriggerContext.cs + templates\OpenApiEndpints\OpenApiHttpTrigger.cs = templates\OpenApiEndpints\OpenApiHttpTrigger.cs + templates\OpenApiEndpints\OpenApiHttpTriggerContext.cs = templates\OpenApiEndpints\OpenApiHttpTriggerContext.cs + templates\OpenApiEndpints\OpenApiHttpTriggerV1.cs = templates\OpenApiEndpints\OpenApiHttpTriggerV1.cs + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -220,6 +230,7 @@ Global {7FD855AB-EB0E-42AE-A26D-E164D375D6A5} = {66D8DEA8-B477-497F-95BB-E8F9A5BAC352} {848EDB8F-9C45-462B-A544-EA237774F3BA} = {66D8DEA8-B477-497F-95BB-E8F9A5BAC352} {D6C3806E-2685-4E8D-9F4F-7A93E5270891} = {66D8DEA8-B477-497F-95BB-E8F9A5BAC352} + {41695443-A292-4909-89A6-2D9846753164} = {56A43630-87E6-4E94-B24A-859258202578} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {70FEC644-BB3C-4441-AF91-DC694803C8F2} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/ApiResponse.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/ApiResponse.cs new file mode 100644 index 0000000..8ead04e --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/ApiResponse.cs @@ -0,0 +1,23 @@ +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for API response of Swagger Pet Store. + /// + public class ApiResponse + { + /// + /// Gets or sets the code. + /// + public int? Code { get; set; } + + /// + /// Gets or sets the type. + /// + public string Type { get; set; } + + /// + /// Gets or sets the message. + /// + public string Message { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/Category.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Category.cs new file mode 100644 index 0000000..e8e5aa2 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Category.cs @@ -0,0 +1,18 @@ +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for category of Swagger Pet Store. + /// + public class Category + { + /// + /// Gets or sets the category ID. + /// + public long? Id { get; set; } + + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/Order.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Order.cs new file mode 100644 index 0000000..8da4872 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Order.cs @@ -0,0 +1,40 @@ +using System; + +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for order of Swagger Pet Store. + /// + public class Order + { + /// + /// Gets or sets the order ID. + /// + public long? Id { get; set; } + + /// + /// Gets or sets the pet ID. + /// + public long? PetId { get; set; } + + /// + /// Gets or sets the quantity. + /// + public int? Quantity { get; set; } + + /// + /// Gets or seets the date/time shipped. + /// + public DateTime? ShipDate { get; set; } + + /// + /// Gets or sets the value. + /// + public OrderStatus? Status { get; set; } + + /// + /// Gets or sets the value indicating whether the order is complete or not. + /// + public bool? Complete { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/OrderStatus.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/OrderStatus.cs new file mode 100644 index 0000000..c860ab3 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/OrderStatus.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This specifies the order status. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OrderStatus + { + /// + /// Identifies as "placed". + /// + Placed = 1, + + /// + /// Identifies as "approved". + /// + Approved = 2, + + /// + /// Identifies as "delivered". + /// + Delivered = 3 + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/Pet.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Pet.cs new file mode 100644 index 0000000..40d2fde --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Pet.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; + +using Newtonsoft.Json; + +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for pet of Swagger Pet Store. + /// + public class Pet + { + /// + /// Gets or sets the pet ID. + /// + public long? Id { get; set; } + + /// + /// Gets or sets the category. + /// + public Category Category { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonRequired] + public string Name { get; set; } + + /// + /// Gets or sets the list of photo URLs. + /// + [JsonRequired] + public List PhotoUrls { get; set; } = new List(); + + /// + /// Gets or sets the list of tags. + /// + public List Tags { get; set; } + + /// + /// Gets or sets the value. + /// + public PetStatus? Status { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/PetStatus.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/PetStatus.cs new file mode 100644 index 0000000..d4dd3c8 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/PetStatus.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This specifices the pet status. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PetStatus + { + /// + /// Identifies as "available". + /// + Available = 1, + + /// + /// Identifies as "pending". + /// + Pending = 2, + + /// + /// Identifies as "sold". + /// + Sold = 3 + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/Tag.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Tag.cs new file mode 100644 index 0000000..3a7cb97 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/Tag.cs @@ -0,0 +1,18 @@ +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for tag of Swagger Pet Store. + /// + public class Tag + { + /// + /// Gets or sets the tag ID. + /// + public long? Id { get; set; } + + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/User.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/User.cs new file mode 100644 index 0000000..bd83a0d --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/User.cs @@ -0,0 +1,48 @@ +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + /// + /// This represents the model entity for user of Swagger Pet Store. + /// + public class User + { + /// + /// Gets or sets the user ID. + /// + public long? Id { get; set; } + + /// + /// Gets or sets the username. + /// + public string Username { get; set; } + + /// + /// Gets or sets the first name. + /// + public string FirstName { get; set; } + + /// + /// Gets or sets the last name. + /// + public string LastName { get; set; } + + /// + /// Gets or sets the email. + /// + public string Email { get; set; } + + /// + /// Gets or sets the password. + /// + public string Password { get; set; } + + /// + /// Gets or sets the phone number. + /// + public string Phone { get; set; } + + /// + /// Gets or sets the user status value. + /// + public int? UserStatus { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/Aliencube.AzureFunctions.FunctionAppV1IoC.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/Aliencube.AzureFunctions.FunctionAppV1IoC.csproj index 7670656..7d5aab8 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/Aliencube.AzureFunctions.FunctionAppV1IoC.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/Aliencube.AzureFunctions.FunctionAppV1IoC.csproj @@ -6,11 +6,11 @@ - + @@ -27,4 +27,17 @@ Never + + + + Compile + + + Compile + + + Compile + + + diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..4c6a3a8 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/PetStoreHttpTrigger.cs @@ -0,0 +1,90 @@ +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.DependencyInjection; +using Aliencube.AzureFunctions.Extensions.DependencyInjection.Abstractions; +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; + +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV1IoC +{ + public static class PetStoreHttpTrigger + { + /// + /// Gets the instance as an IoC container. + /// + public static IFunctionFactory Factory = new FunctionFactory(); + + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public static async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public static async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public static async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public static async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public static async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequestMessage req, + long petId, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/SampleHttpTrigger.cs index 53746cc..8300e74 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/SampleHttpTrigger.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -21,11 +22,12 @@ public static class SampleHttpTrigger /// /// Gets the instance as an IoC container. /// + [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "")] public static IFunctionFactory Factory = new FunctionFactory(); [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public static async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequestMessage req, ILogger log) diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/Aliencube.AzureFunctions.FunctionAppV1Static.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/Aliencube.AzureFunctions.FunctionAppV1Static.csproj index 21fd214..e3113bc 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/Aliencube.AzureFunctions.FunctionAppV1Static.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/Aliencube.AzureFunctions.FunctionAppV1Static.csproj @@ -6,11 +6,11 @@ - + @@ -28,4 +28,16 @@ + + + Compile + + + Compile + + + Compile + + + diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..cfe4b89 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/PetStoreHttpTrigger.cs @@ -0,0 +1,83 @@ +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; + +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV1Static +{ + public static class PetStoreHttpTrigger + { + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public static async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public static async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public static async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public static async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequestMessage req, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public static async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequestMessage req, + long petId, + ILogger log) + { + return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/SampleHttpTrigger.cs index f1bfdc2..d234683 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/SampleHttpTrigger.cs @@ -9,7 +9,7 @@ using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Extensions.Http; -using Microsoft.Azure.WebJobs.Host; +using Microsoft.Extensions.Logging; namespace Aliencube.AzureFunctions.FunctionAppV1Static { @@ -17,10 +17,10 @@ public static class SampleHttpTrigger { [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public static async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequestMessage req, - TraceWriter log) + ILogger log) { var content = new List() { diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/.gitignore b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/.gitignore index ff5b00c..fea9bfe 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/.gitignore +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/.gitignore @@ -2,7 +2,7 @@ ## files generated by popular Visual Studio add-ons. # Azure Functions localsettings file -local.settings.json +#local.settings.json # User-specific files *.suo diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/Aliencube.AzureFunctions.FunctionAppV2IoC.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/Aliencube.AzureFunctions.FunctionAppV2IoC.csproj index 6e65c9a..c7210c4 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/Aliencube.AzureFunctions.FunctionAppV2IoC.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/Aliencube.AzureFunctions.FunctionAppV2IoC.csproj @@ -6,12 +6,12 @@ - + @@ -28,4 +28,16 @@ + + + Compile + + + Compile + + + Compile + + + \ No newline at end of file diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..78c4829 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/PetStoreHttpTrigger.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; +using Aliencube.AzureFunctions.FunctionApp.Services; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV2IoC +{ + public class PetStoreHttpTrigger + { + private readonly ISampleHttpService _service; + + public PetStoreHttpTrigger(ISampleHttpService service) + { + this._service = service ?? throw new ArgumentNullException(nameof(service)); + } + + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequest req, + long petId, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/SampleHttpTrigger.cs index e379f8c..e751f75 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/SampleHttpTrigger.cs @@ -27,7 +27,7 @@ public SampleHttpTrigger(ISampleHttpService service) [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequest req, ILogger log) diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/local.settings.json b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/local.settings.json new file mode 100644 index 0000000..5176821 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/local.settings.json @@ -0,0 +1,9 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + + "OpenApi__ApiKey": "" + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/.gitignore b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/.gitignore index ff5b00c..fea9bfe 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/.gitignore +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/.gitignore @@ -2,7 +2,7 @@ ## files generated by popular Visual Studio add-ons. # Azure Functions localsettings file -local.settings.json +#local.settings.json # User-specific files *.suo diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/Aliencube.AzureFunctions.FunctionAppV2Static.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/Aliencube.AzureFunctions.FunctionAppV2Static.csproj index a21a421..93a2c98 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/Aliencube.AzureFunctions.FunctionAppV2Static.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/Aliencube.AzureFunctions.FunctionAppV2Static.csproj @@ -6,11 +6,11 @@ - + @@ -24,4 +24,16 @@ + + + Compile + + + Compile + + + Compile + + + \ No newline at end of file diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..a1ce127 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/PetStoreHttpTrigger.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV2Static +{ + public static class PetStoreHttpTrigger + { + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public static async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public static async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public static async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public static async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public static async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequest req, + long petId, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/SampleHttpTrigger.cs index 6ae55c5..c568de1 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/SampleHttpTrigger.cs @@ -18,7 +18,7 @@ public static class SampleHttpTrigger { [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public static async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequest req, ILogger log) diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/local.settings.json b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/local.settings.json new file mode 100644 index 0000000..5176821 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/local.settings.json @@ -0,0 +1,9 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + + "OpenApi__ApiKey": "" + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/Aliencube.AzureFunctions.FunctionAppV3IoC.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/Aliencube.AzureFunctions.FunctionAppV3IoC.csproj index 2a31612..2ba55f7 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/Aliencube.AzureFunctions.FunctionAppV3IoC.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/Aliencube.AzureFunctions.FunctionAppV3IoC.csproj @@ -6,12 +6,12 @@ - + @@ -28,4 +28,16 @@ + + + Compile + + + Compile + + + Compile + + + \ No newline at end of file diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..437f9fa --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/PetStoreHttpTrigger.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; +using Aliencube.AzureFunctions.FunctionApp.Services; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV3IoC +{ + public class PetStoreHttpTrigger + { + private readonly ISampleHttpService _service; + + public PetStoreHttpTrigger(ISampleHttpService service) + { + this._service = service ?? throw new ArgumentNullException(nameof(service)); + } + + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequest req, + long petId, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/SampleHttpTrigger.cs index 4a70a56..119edce 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/SampleHttpTrigger.cs @@ -27,7 +27,7 @@ public SampleHttpTrigger(ISampleHttpService service) [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequest req, ILogger log) diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/Aliencube.AzureFunctions.FunctionAppV3Static.csproj b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/Aliencube.AzureFunctions.FunctionAppV3Static.csproj index d20d128..0705386 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/Aliencube.AzureFunctions.FunctionAppV3Static.csproj +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/Aliencube.AzureFunctions.FunctionAppV3Static.csproj @@ -6,11 +6,11 @@ - + @@ -24,4 +24,16 @@ + + + Compile + + + Compile + + + Compile + + + \ No newline at end of file diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/PetStoreHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/PetStoreHttpTrigger.cs new file mode 100644 index 0000000..382799b --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/PetStoreHttpTrigger.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; + +using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; +using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; +using Aliencube.AzureFunctions.FunctionApp.Models; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; + +namespace Aliencube.AzureFunctions.FunctionAppV3Static +{ + public static class PetStoreHttpTrigger + { + [FunctionName(nameof(PetStoreHttpTrigger.AddPet))] + [OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] + public static async Task AddPet( + [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] + [OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] + public static async Task UpdatePet( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] + [OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] + public static async Task FindByStatus( + [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] + [OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] + public static async Task FindByTags( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequest req, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + + [FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] + [OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] + [OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] + [OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] + public static async Task GetPetById( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequest req, + long petId, + ILogger log) + { + return await Task.FromResult(new OkResult()).ConfigureAwait(false); + } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/SampleHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/SampleHttpTrigger.cs index c45fad1..30eb0fc 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/SampleHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/SampleHttpTrigger.cs @@ -18,7 +18,7 @@ public static class SampleHttpTrigger { [FunctionName(nameof(SampleHttpTrigger.GetSamples))] [OpenApiOperation(operationId: "list", tags: new[] { "sample" }, Summary = "Gets the list of samples", Description = "This gets the list of samples.", Visibility = OpenApiVisibilityType.Important)] - [OpenApiResponseBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "List of the sample responses")] public static async Task GetSamples( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "samples")] HttpRequest req, ILogger log) diff --git a/src/Aliencube.AzureFunctions.Extensions.OpenApi/Aliencube.AzureFunctions.Extensions.OpenApi.csproj b/src/Aliencube.AzureFunctions.Extensions.OpenApi/Aliencube.AzureFunctions.Extensions.OpenApi.csproj index b9878d6..c784226 100644 --- a/src/Aliencube.AzureFunctions.Extensions.OpenApi/Aliencube.AzureFunctions.Extensions.OpenApi.csproj +++ b/src/Aliencube.AzureFunctions.Extensions.OpenApi/Aliencube.AzureFunctions.Extensions.OpenApi.csproj @@ -95,4 +95,5 @@ contentFiles\any\net461\OpenApi\; + diff --git a/templates/OpenApiEndpints/OpenApiHttpTriggerV1.cs b/templates/OpenApiEndpints/OpenApiHttpTriggerV1.cs index db7c2f5..272853f 100644 --- a/templates/OpenApiEndpints/OpenApiHttpTriggerV1.cs +++ b/templates/OpenApiEndpints/OpenApiHttpTriggerV1.cs @@ -59,9 +59,9 @@ public static async Task RenderSwaggerDocumentInJson( /// instance. /// instance. /// Swagger document in a format in YAML. - [FunctionName(nameof(OpenApiHttpTrigger.RenderSwaggerDocumentInYaml))] + [FunctionName(nameof(OpenApiHttpTrigger.RenderSwaggerDocumentInYml))] [OpenApiIgnore] - public static async Task RenderSwaggerDocumentInYaml( + public static async Task RenderSwaggerDocumentInYml( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger.yml")] HttpRequestMessage req, ILogger log) { @@ -143,9 +143,9 @@ public static async Task RenderOpenApiDocumentV2InJson( /// instance. /// instance. /// Open API document v2 in a format of YAML. - [FunctionName(nameof(OpenApiHttpTrigger.RenderOpenApiDocumentV2InYaml))] + [FunctionName(nameof(OpenApiHttpTrigger.RenderOpenApiDocumentV2InYml))] [OpenApiIgnore] - public static async Task RenderOpenApiDocumentV2InYaml( + public static async Task RenderOpenApiDocumentV2InYml( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "openapi/v2.yml")] HttpRequestMessage req, ILogger log) { @@ -227,9 +227,9 @@ public static async Task RenderOpenApiDocumentV3InJson( /// instance. /// instance. /// Open API document v3 in a format of YAML. - [FunctionName(nameof(OpenApiHttpTrigger.RenderOpenApiDocumentV3InYaml))] + [FunctionName(nameof(OpenApiHttpTrigger.RenderOpenApiDocumentV3InYml))] [OpenApiIgnore] - public static async Task RenderOpenApiDocumentV3InYaml( + public static async Task RenderOpenApiDocumentV3InYml( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "openapi/v3.yml")] HttpRequestMessage req, ILogger log) {