Add Function with HTTP trigger and attributes [OpenApiOperation] and [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, bodyType: typeof(ListDistributionsResponse), contentType: "application/json")]
Index was outside the bounds of the array.
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions.TypeExtensions.GetUnderlyingType(Type type)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ListObjectTypeVisitor.Visit(IAcceptor acceptor, KeyValuePair`2 type, NamingStrategy namingStrategy, Attribute[] attributes)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.OpenApiSchemaAcceptor.Accept(VisitorCollection collection, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ObjectTypeVisitor.ProcessProperties(IOpenApiSchemaAcceptor instance, String schemaName, Dictionary`2 properties, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ObjectTypeVisitor.Visit(IAcceptor acceptor, KeyValuePair`2 type, NamingStrategy namingStrategy, Attribute[] attributes)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.OpenApiSchemaAcceptor.Accept(VisitorCollection collection, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ListObjectTypeVisitor.Visit(IAcceptor acceptor, KeyValuePair`2 type, NamingStrategy namingStrategy, Attribute[] attributes)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.OpenApiSchemaAcceptor.Accept(VisitorCollection collection, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ObjectTypeVisitor.ProcessProperties(IOpenApiSchemaAcceptor instance, String schemaName, Dictionary`2 properties, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.ObjectTypeVisitor.Visit(IAcceptor acceptor, KeyValuePair`2 type, NamingStrategy namingStrategy, Attribute[] attributes)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors.OpenApiSchemaAcceptor.Accept(VisitorCollection collection, NamingStrategy namingStrategy)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.DocumentHelper.GetOpenApiSchemas(List`1 elements, NamingStrategy namingStrategy, VisitorCollection collection)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Build(Assembly assembly, OpenApiVersionType version)
at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiTriggerFunctions.RenderSwaggerDocument(OpenApiHttpTriggerContext openApiContext, HttpRequest req, String extension, ExecutionContext ctx, ILogger log)
Removing the line [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, bodyType: typeof(ListDistributionsResponse), contentType: "application/json")] makes the problem go away, however I need this to make the return type of the API available to users.
Describe the issue Swagger JSON fails to generate when using OpenApiResponseWithBody attribute.
To Reproduce Steps to reproduce the behavior:
dotnet openapi add url https://developer.swift.com/sites/default/files/specs/Swift-Messaging-API-v1.0.0.yaml
[OpenApiOperation]
and[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, bodyType: typeof(ListDistributionsResponse), contentType: "application/json")]
Expected behavior Swagger JSON is generated correctly.
Screenshots If applicable, add screenshots to help explain your issue.
Environment (please complete the following information, if applicable):
Additional context https://github.com/michaelelleby/azure-functions-openapi-extension-bugreport is a small project demonstrating the issue.
This is the response from the Swagger JSON page:
Removing the line
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, bodyType: typeof(ListDistributionsResponse), contentType: "application/json")]
makes the problem go away, however I need this to make the return type of the API available to users.