diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyListModel.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyListModel.cs new file mode 100644 index 0000000..e332926 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyListModel.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + public class DummyListModel + { + public List ListValues { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyStringModel.cs b/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyStringModel.cs new file mode 100644 index 0000000..338fc53 --- /dev/null +++ b/samples/Aliencube.AzureFunctions.FunctionApp.Models/DummyStringModel.cs @@ -0,0 +1,7 @@ +namespace Aliencube.AzureFunctions.FunctionApp.Models +{ + public class DummyStringModel + { + public string StringValue { get; set; } + } +} diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/DummyHttpTrigger.cs index 2b32a2f..7fad9d1 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1IoC/DummyHttpTrigger.cs @@ -60,5 +60,19 @@ public static async Task AddDummy( return result; } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public static async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequestMessage req, + ILogger log) + { + var content = new List(); + var result = req.CreateResponse(HttpStatusCode.OK, content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/DummyHttpTrigger.cs index b952031..13c287b 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV1Static/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV1Static/DummyHttpTrigger.cs @@ -50,5 +50,19 @@ public static async Task AddDummy( return await Task.FromResult(result).ConfigureAwait(false); } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public static async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequestMessage req, + ILogger log) + { + var content = new List(); + var result = req.CreateResponse(HttpStatusCode.OK, content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/DummyHttpTrigger.cs index bf86f86..f003f5e 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2IoC/DummyHttpTrigger.cs @@ -60,5 +60,19 @@ public async Task AddDummy( return await Task.FromResult(result).ConfigureAwait(false); } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req, + ILogger log) + { + var content = new List(); + var result = new OkObjectResult(content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/DummyHttpTrigger.cs index 1bc0952..8e0c14c 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV2Static/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV2Static/DummyHttpTrigger.cs @@ -51,5 +51,19 @@ public static async Task AddDummy( return await Task.FromResult(result).ConfigureAwait(false); } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public static async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req, + ILogger log) + { + var content = new List(); + var result = new OkObjectResult(content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/DummyHttpTrigger.cs index fdcb7df..c41396b 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3IoC/DummyHttpTrigger.cs @@ -60,5 +60,19 @@ public async Task AddDummy( return await Task.FromResult(result).ConfigureAwait(false); } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req, + ILogger log) + { + var content = new List(); + var result = new OkObjectResult(content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/DummyHttpTrigger.cs b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/DummyHttpTrigger.cs index 0bd9edd..960ec06 100644 --- a/samples/Aliencube.AzureFunctions.FunctionAppV3Static/DummyHttpTrigger.cs +++ b/samples/Aliencube.AzureFunctions.FunctionAppV3Static/DummyHttpTrigger.cs @@ -51,5 +51,19 @@ public static async Task AddDummy( return await Task.FromResult(result).ConfigureAwait(false); } + + [FunctionName(nameof(DummyHttpTrigger.UpdateDummies))] + [OpenApiOperation(operationId: "updateDummies", tags: new[] { "dummy" }, Summary = "Updates a list of dummies", Description = "This updates a list of dummies.", Visibility = OpenApiVisibilityType.Advanced)] + [OpenApiRequestBody(contentType: "application/json", bodyType: typeof(DummyListModel), Required = true, Description = "Dummy list model")] + [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List), Summary = "Dummy response", Description = "This returns the dummy response")] + public static async Task UpdateDummies( + [HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req, + ILogger log) + { + var content = new List(); + var result = new OkObjectResult(content); + + return await Task.FromResult(result).ConfigureAwait(false); + } } } diff --git a/src/Aliencube.AzureFunctions.Extensions.OpenApi.Core/DocumentHelper.cs b/src/Aliencube.AzureFunctions.Extensions.OpenApi.Core/DocumentHelper.cs index 183447d..57410bb 100644 --- a/src/Aliencube.AzureFunctions.Extensions.OpenApi.Core/DocumentHelper.cs +++ b/src/Aliencube.AzureFunctions.Extensions.OpenApi.Core/DocumentHelper.cs @@ -215,9 +215,8 @@ public Dictionary GetOpenApiSchemas(List elem this._acceptor.Schemas = schemas; this._acceptor.Accept(collection, namingStrategy); - //types.ForEach(p => schemas.AddRange(p.ToOpenApiSchemas(namingStrategy))); - var union = schemas.Union(rootSchemas) + var union = schemas.Concat(rootSchemas.Where(p => !schemas.Keys.Contains(p.Key))) .Distinct() .OrderBy(p => p.Key) .ToDictionary(p => p.Key,