Skip to content

Commit 5a64b15

Browse files
authored
Fix issue with DocumentHelperExceptions.GetOpenApiParameters not passing forward the OpenAPI schema version. (Azure#503)
1 parent df6efcb commit 5a64b15

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Extensions/DocumentHelperExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper h
157157
{
158158
var parameters = element.GetCustomAttributes<OpenApiParameterAttribute>(inherit: false)
159159
.Where(p => p.Deprecated == false)
160-
.Select(p => p.ToOpenApiParameter(namingStrategy, collection))
160+
.Select(p => p.ToOpenApiParameter(namingStrategy, collection, version))
161161
.ToList();
162162

163163
// This is the interim solution to resolve:

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/DocumentHelperExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static List<OpenApiParameter> GetOpenApiParameters(this IDocumentHelper h
152152
{
153153
var parameters = element.GetCustomAttributes<OpenApiParameterAttribute>(inherit: false)
154154
.Where(p => p.Deprecated == false)
155-
.Select(p => p.ToOpenApiParameter(namingStrategy, collection))
155+
.Select(p => p.ToOpenApiParameter(namingStrategy, collection, version))
156156
.ToList();
157157

158158
// This is the interim solution to resolve:

test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/Extensions/OpenApiParameterAttributeExtensionsTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,24 @@ public void Given_Value_With_Deprecated_When_ToOpenApiParameter_Invoked_Then_It_
225225

226226
result.Deprecated.Should().Be(deprecated.GetValueOrDefault());
227227
}
228+
229+
[TestMethod]
230+
public void Given_Value_With_Examples_When_ToOpenApiParameter_Invoked_With_OpenApi_V3_Then_It_Should_Return_Result()
231+
{
232+
var attribute = new OpenApiParameterAttribute("hello")
233+
{
234+
Type = typeof(string),
235+
Summary = "lorem ipsum",
236+
Description = "hello world",
237+
Required = true,
238+
Example = typeof(FakeStringParameterExample),
239+
In = ParameterLocation.Path,
240+
};
241+
242+
var result = OpenApiParameterAttributeExtensions.ToOpenApiParameter(attribute, version: OpenApiVersionType.V3);
243+
244+
result.Example.Should().BeNull();
245+
}
246+
228247
}
229248
}

0 commit comments

Comments
 (0)