未捕获的引用错误:SwaggerUIBundle 未在 window.onload 中定义

Dur*_*dar 6 hapi swagger-ui hapi-swagger

在我的本地主机中,我的 swagger UI 运行良好。localhost:3030/documentation 此 UI 也在服务器上运行,但从今天开始在服务器上不再运行https://digitalpathshalabd.com/documentation

错误

图片错误

小智 3

我遇到了同样的“SwaggerUIBundle 未定义”和空白页面。此外,问题仅出现在服务器上,而不是本地。它在过去也曾发挥过作用。然后,当我ctrl +f5 本地 swagger 页面时,它也出现在本地。

对我们来说,配置顺序似乎被交换了。对我来说,解决方法是在 swagger init 之后移动 app.UseRouting()

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{                                    
    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "Procedure Service V1");
        c.RoutePrefix = "";
    });
    app.UseRouting();
Run Code Online (Sandbox Code Playgroud)