From fa73019da04d519c4f6d79a247ce1457512b0283 Mon Sep 17 00:00:00 2001 From: yuka1984 Date: Sat, 14 Dec 2019 14:55:49 +0900 Subject: [PATCH] #9 breaking changes --- .../Attribute/QueryStringParamaterAttribute.cs | 4 ++-- .../QueryStringParameterAttributeFilter.cs | 4 ++-- .../TestFunction/TestController.cs | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/Attribute/QueryStringParamaterAttribute.cs b/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/Attribute/QueryStringParamaterAttribute.cs index 122f3e7..5c55321 100644 --- a/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/Attribute/QueryStringParamaterAttribute.cs +++ b/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/Attribute/QueryStringParamaterAttribute.cs @@ -5,9 +5,9 @@ namespace AzureFunctions.Extensions.Swashbuckle.Attribute { [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)] - public class QueryStringParamaterAttribute : System.Attribute + public class QueryStringParameterAttribute : System.Attribute { - public QueryStringParamaterAttribute(string name, string description) + public QueryStringParameterAttribute(string name, string description) { Name = name; Description = description; diff --git a/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/QueryStringParameterAttributeFilter.cs b/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/QueryStringParameterAttributeFilter.cs index 2e09d46..d68120c 100644 --- a/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/QueryStringParameterAttributeFilter.cs +++ b/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/QueryStringParameterAttributeFilter.cs @@ -14,7 +14,7 @@ public void Apply(Operation operation, OperationFilterContext context) { var attributes = context.MethodInfo.DeclaringType.GetCustomAttributes(true) .Union(context.MethodInfo.GetCustomAttributes(true)) - .OfType(); + .OfType(); foreach (var attribute in attributes) operation.Parameters.Add(new NonBodyParameter @@ -23,7 +23,7 @@ public void Apply(Operation operation, OperationFilterContext context) Description = attribute.Description, In = "query", Required = attribute.Required, - Type = context.SchemaRegistry.GetOrRegister(attribute.DataType).Type + Type = context.SchemaRegistry.GetOrRegister(attribute.DataType ?? typeof(string)).Type }); } } diff --git a/src/AzureFunctions.Extensions.Swashbuckle/TestFunction/TestController.cs b/src/AzureFunctions.Extensions.Swashbuckle/TestFunction/TestController.cs index 489cd4c..0abd0c9 100644 --- a/src/AzureFunctions.Extensions.Swashbuckle/TestFunction/TestController.cs +++ b/src/AzureFunctions.Extensions.Swashbuckle/TestFunction/TestController.cs @@ -27,7 +27,7 @@ public class TestController /// すべてのテスト [ProducesResponseType(typeof(TestModel[]), (int)HttpStatusCode.OK)] [FunctionName("TestGets")] - [QueryStringParamater("expand", "it is expand parameter", DataType = typeof(int))] + [QueryStringParameter("expand", "it is expand parameter", DataType = typeof(int))] public async Task Gets([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "test")] HttpRequest request) { return new OkObjectResult(new[] {new TestModel(), new TestModel(),}); @@ -54,6 +54,7 @@ public async Task Gets([HttpTrigger(AuthorizationLevel.Anonymous, /// テストId /// 指定されたテスト [ProducesResponseType(typeof(TestModel), (int)HttpStatusCode.OK)] + [QueryStringParameter("name", "this is name", DataType = typeof(string), Required = true)] [FunctionName("TestGetCat")] public Task GetCat([HttpTrigger(AuthorizationLevel.Function, "get", Route = "cat/{id}/{testId?}")] HttpRequest request, int id, int? testId) @@ -79,6 +80,7 @@ public Task Add([HttpTrigger(AuthorizationLevel.Anonymous, "post" /// テストモデル /// 追加結果 [ProducesResponseType(typeof(TestModel), (int)HttpStatusCode.Created)] + [QueryStringParameter("test", "test", Required = false)] [FunctionName("TestAddGet")] public async Task AddAndGet([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "testandget")]HttpRequest httpRequest) {