Failed to load API definitions

Product: PowerShell Universal
Version: 2.7.4

Good afternoon. Not sure if anyone else has ran into this while trying to access the swagger docs.

https://localhost/swagger/index.html

image

022-04-06 15:54:20.999 -05:00 [ERR] An unhandled exception has occurred while executing the request.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'char' does not contain a definition for 'Text'
   at CallSite.Target(Closure , CallSite , Object )
   at Universal.Server.SwashbuckleSchemaFilter.PreSerializeFilter(OpenApiDocument document, HttpRequest request) in D:\a\universal\universal\src\Universal.Server\Middleware\SwashbuckleSchemaFilter.cs:line 76
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Universal.Server.Middleware.SwaggerAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in D:\a\universal\universal\src\Universal.Server\Middleware\SwaggerAuthMiddleware.cs:line 42
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in D:\a\universal\universal\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 109
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
2022-04-06 15:54:21.001 -05:00 [WRN] No exception handler was found, rethrowing original exception.
2022-04-06 15:54:21.002 -05:00 [ERR] Connection id "0HMGO1315CGAJ", Request id "0HMGO1315CGAJ:00000007": An unhandled exception was thrown by the application.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'char' does not contain a definition for 'Text'
   at CallSite.Target(Closure , CallSite , Object )
   at Universal.Server.SwashbuckleSchemaFilter.PreSerializeFilter(OpenApiDocument document, HttpRequest request) in D:\a\universal\universal\src\Universal.Server\Middleware\SwashbuckleSchemaFilter.cs:line 76
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Universal.Server.Middleware.SwaggerAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in D:\a\universal\universal\src\Universal.Server\Middleware\SwaggerAuthMiddleware.cs:line 42
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in D:\a\universal\universal\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 109
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Works fine on another PSU instance with that same version… Both running as a windows service.

It has to do with one of your custom endpoints. I don’t recall exactly what causes it but we’ve fixed it in 2.10.

Ahh figured it out. It had something to do with an endpoint that had the following attributes. Commenting out the line with the “->” fixed it.

 param(
   ->   [Parameter(Mandatory = $false, HelpMessage = "Account....")]
        [string] 
        $UserAccount
    )

Thanks for the quick reply as always. @adam

1 Like

@mikedhanson I have the same error. Are you saying its the entire Parameter block. I have this in my code many times with validation as well. I don’t want to disable the validation if I don’t have to. I have would have to change many endpoints as well. Maybe this doesn’t apply to the [ValidatePattern] block???

That worked! Deleting the [Parameter] block worked with effecting the Validation.

1 Like

Thanks for the follow up dude! @cpsdakota