Skip to content

Commit

Permalink
#109 Update DocumentHelper to avoid dictionary key dups
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo committed Aug 25, 2020
1 parent 98e8ba3 commit ed7a28d
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Aliencube.AzureFunctions.FunctionApp.Models
{
public class DummyListModel
{
public List<DummyStringModel> ListValues { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Aliencube.AzureFunctions.FunctionApp.Models
{
public class DummyStringModel
{
public string StringValue { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,19 @@ public static async Task<HttpResponseMessage> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public static async Task<HttpResponseMessage> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequestMessage req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = req.CreateResponse(HttpStatusCode.OK, content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,19 @@ public static async Task<HttpResponseMessage> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public static async Task<HttpResponseMessage> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequestMessage req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = req.CreateResponse(HttpStatusCode.OK, content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,19 @@ public async Task<IActionResult> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public async Task<IActionResult> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = new OkObjectResult(content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,19 @@ public static async Task<IActionResult> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public static async Task<IActionResult> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = new OkObjectResult(content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,19 @@ public async Task<IActionResult> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public async Task<IActionResult> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = new OkObjectResult(content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,19 @@ public static async Task<IActionResult> 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<DummyStringModel>), Summary = "Dummy response", Description = "This returns the dummy response")]
public static async Task<IActionResult> UpdateDummies(
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "dummies")] HttpRequest req,
ILogger log)
{
var content = new List<DummyStringModel>();
var result = new OkObjectResult(content);

return await Task.FromResult(result).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> 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,
Expand Down

0 comments on commit ed7a28d

Please sign in to comment.