Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentNullException at ...SwaggerGeneratorOptions.DefaultOperationIdSelector #2194

Closed
icnocop opened this issue Aug 13, 2021 · 2 comments · Fixed by #2195
Closed

ArgumentNullException at ...SwaggerGeneratorOptions.DefaultOperationIdSelector #2194

icnocop opened this issue Aug 13, 2021 · 2 comments · Fixed by #2195

Comments

@icnocop
Copy link
Contributor

icnocop commented Aug 13, 2021

Hi.

Upgrading from 6.1.4 to 6.1.5 causes System.ArgumentNullException: Value cannot be null. (Parameter 'source') to be thrown when generating swagger.json.

I've created a repository which can reproduce the issue here:
https://github.com/icnocop/Swashbuckle.AspNetCore.InheritanceExample

Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate Operation for action - WebApplication9.Controllers.AnimalsController.Post (WebApplication9). See inner exception
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'source')
   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions.DefaultOperationIdSelector(ApiDescription apiDescription)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)
   --- End of inner exception stack trace ---
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

I believe it's caused by the most recent code changes in #2173, related to #2165.

Thank you.

@domaindrivendev
Copy link
Owner

@captainsafia, @bradygaster looks like the PR to use endpoint metadata for operationId may be causing a regression with the latest release. Could you possibly take a quick look to see if there's an easy fix? Thx

@davidfowl
Copy link
Contributor

I guess the EndpointMetadata collection itself is null. Should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants