azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Build method gives Object Reference exception when called with Assembly.GetExecutingAssembly()

Open SapnaSoni123 opened this issue 4 years ago • 1 comments

Hi,

I have written unit tests to check if the Open API document is getting generated successfully or not. The method is as below: async Task CoreAsync() { var helper = new DocumentHelper(new RouteConstraintFilter(), new OpenApiSchemaAcceptor()); var document = new Document(helper); return await document.InitialiseDocument() .AddMetadata(oaiInfo) .AddNamingStrategy(new CamelCaseNamingStrategy()) .Build(assembly) .RenderAsync(OpenApiSpecVersion.OpenApi3_0, OpenApiFormat.Json); } where assembly= Assembly.GetExecutingAssembly() and oaiInfo is a custom OpenApiInfo() object. This method always fails while trying to Build(assembly) giving the Object reference not set to an instance exception. Has anyone encountered this issue before? Please also not that I am able to generate on the fly Swagger Json. It's only that the Build method fails.

SapnaSoni123 avatar Jan 06 '22 16:01 SapnaSoni123

@SapnaSoni123 Thanks for the issue! It's a known issue the CLI project. But it's de-priotised over other issues. Let's keep this issue open for further discussion.

justinyoo avatar Feb 14 '22 03:02 justinyoo

As the PR, #489, has been merged, you can generate the OpenAPI doc on-the-fly, within the GitHub Actions workflow.

justinyoo avatar Sep 20 '22 07:09 justinyoo