Azure / Azure/azure-functions-openapi-extension
Bug report - OpenApiRequestBody not able to serialise the JsonObject datatype
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the issue**
OpenApiRequestBody not able to serialise the JsonObject datatype (System.Text.Json.Nodes) in version 1.2.0 .
**To Reproduce**
Steps to reproduce the behavior:
1. Create new Azure Function POST API
2. Add OpenApiRequestBody attribute with customModel
3. In Model, use JsonObject for one the parameter.
4. Run the application
5. See error
**Expected behavior**
OpenApiRequestBody should able to serialise the JsonObject data type and should able to generate the swagger.json file and swagger UI.
**Screenshots**

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.DocumentHelper.GetOpenApiSchemas(List`1 elements, NamingStrategy namingStrategy, VisitorCollection collection)
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Document.Build(Assembly assembly, OpenApiVersionType version)
at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Functions.OpenApiTriggerFunction.RenderSwaggerDocument(HttpRequestData req, String extension, FunctionContext ctx)
**Environment (please complete the following information, if applicable):**
- OS: [Mac]
- Browser [chrome]
- Version [1.2.0, 1.1.0]
Contributor guide
Research direction
Reproduce the Azure Function POST API case using a model with a System.Text.Json.Nodes JsonObject and an OpenApiRequestBody attribute. Start at TypeExtensions.GetUnderlyingType and ListObjectTypeVisitor.Visit in the stack trace, then follow swagger document generation through Document.Build. Done means the swagger.json file and Swagger UI generate successfully without the array-bounds error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100