CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
MIT License
2.08k stars 175 forks source link

OpenApi - crash if no validator found for request type #185

Closed wastaz closed 5 years ago

wastaz commented 5 years ago

If you try to use the OpenApi support but you dont have a validator for your request (yes, heresy, I know) the openapi endpoint will crash with a nullreference exception.

System.NullReferenceException: Object reference not set to an instance of an object.
  at Carter.OpenApi.CarterOpenApi.CreateOpenApiRequestBody(OpenApiDocument document, KeyValuePair`2 keyValuePair, OpenApiOperation operation, HttpContext context) in /Users/jonathan/Projects/Carter/src/OpenApi/CarterOpenApi.cs:316
  at Carter.OpenApi.CarterOpenApi.<>c__DisplayClass0_0.<BuildOpenApiResponse>b__0(HttpContext context) in /Users/jonathan/Projects/Carter/src/OpenApi/CarterOpenApi.cs:99
  at at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()

It seems like this is where it tries to fetch the validator and it gets null back and it doesnt expect that to happen.

jchannon commented 5 years ago

Thanks!

Will take a look tonight