Openapi to have XML documentation of the properties and endpoints.
anyone used openapi document? to get the xml documentation included in the openapi/v1.json ? I was using MartinCostello.OpenApi library. Please suggest to fix that. when i used below logic, it is giving me 500 internal server error.
services.AddOpenApiExtensions(options =>
{
options.AddServerUrls = true;
options.XmlDocumentationAssemblies.Add(Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly());
}
1 Reply
@admin do we have Martin in this group?
I added services.AddHttpContextAccessor(); as well.
throwing object reference null exception.
at MartinCostello.OpenApi.Transformers.DescriptionsTransformer.TransformAsync(OpenApiOperation operation, OpenApiOperationTransformerContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.OpenApi.OpenApiDocumentService.<GetOperationsAsync>d20.MoveNext()
at Microsoft.AspNetCore.OpenApi.OpenApiDocumentService.<GetOpenApiPathsAsync>d19.MoveNext()
at Microsoft.AspNetCore.OpenApi.OpenApiDocumentService.<GetOpenApiDocumentAsync>d12.MoveNext()
at Microsoft.AspNetCore.Builder.OpenApiEndpointRouteBuilderExtensions.<>cDisplayClass0_0.<<MapOpenApi>b0>d.MoveNext()
at Microsoft.AspNetCore.Http.Generated.<GeneratedRouteBuilderExtensions_g>F56B68D2B55B5B7B373BA2E4796D897848BC0F04A969B1AF6260183E8B9E0BAF2GeneratedRouteBuilderExtensionsCore.<>cDisplayClass2_0.<<MapGet0>gRequestHandler|5>d.MoveNext()
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.<Invoke>d11.MoveNext()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d6.MoveNext()
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<<Invoke>g__Awaited|10_0>d.MoveNext()
I did create the context by generating from the assembly for all the types and I was able to build, but it is giving object null reference exception at below line
@martincostello - I did add context for all the types used in the assembly but it is giving me a null exception at below line
"method":"MartinCostello.OpenApi.Transformers.DescriptionsTransformer.TransformAsync"
@captainsafia - could you do needful here?