Swashbuckle.AspNetCore: Swagger UI hangs on expanding method details

Last working version: Swashbuckle.AspNetCore 6.2.3 Updating it to 6.3.0 causes the error.

Expanding method hangs the whole page. image If I check ‘Pause on exception’ it shows the following error: TypeError: Cannot read properties of undefined (reading 'declaringType')

If I let it continue, the following exceptions appears in the loop:

TypeError: Cannot read properties of undefined (reading 'declaringType')
TypeError: Cannot read properties of undefined (reading 'reflectedType')
TypeError: Cannot read properties of undefined (reading 'module')
TypeError: Cannot read properties of undefined (reading 'customAttributes')

image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I was able to figure out what caused that. In some of my controllers, I had the following annotation:

[ProducesResponseType(typeof(WebException), StatusCodes.Status401Unauthorized)]

that caused a whole bunch of System.Net classes to be serialized. I guess something inside that hierarchy causes the circular references and the SwaggerUi just hanged. I’ve removed this from my controllers and it started working fine.

@martincostello I was able to reproduce the hang with the minimal project (https://github.com/andrew-potachits/test-swagger-ui-error.git)

The /WeatherForecast expands ok, but the expanding the /api/projects/transfer method hangs.

image

If the project references version v6.5.0, expanding api/projects/transfer fails, but if I change the reference to v6.2.3 and clean the browser cache (to reload the scripts), the method api/projects/transfer expands just fine.

While I prepared the project, the script didn’t hang until I added the ApiVersioning + document filters, so probably the issue is related to one of the mentioned functions.