簡體   English   中英

Swagger 與 .net core 3.1 和 Lambda

[英]Swagger with .net core 3.1 and Lambda

我正在為我們的 API 使用 .net core 3.1 和 swashbuckle swagger。 在本地這可以正常工作,當我運行我的項目時,它會很好地加載以下內容:https://localhost:44352/swagger/index.html 以及我所有的 api 端點。

當我部署到我的服務器時,相同的代碼在導航到 /swagger/index.html 時顯示沒有錯誤的空白屏幕。 不知道在哪里查看。 下面是我的代碼:

public void ConfigureServices(IServiceCollection services)
 {
    services.AddCors();
    services.AddMvc(options => options.EnableEndpointRouting = false);
    services.AddControllers()
        .AddNewtonsoftJson();
    services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new OpenApiInfo
        {
            Title = "API",
            Version = "V1",
            Description = ""
        });
    }); 
 }
 
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
 {
    app.UseMvc();
    app.UseSwagger();

    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "API");
    });
 }

請輸入任何內容。 謝謝

public readonly IWebHostEnvironment _env;
    public readonly AppDbContext _context;

    public HeroController(IWebHostEnvironment env, AppDbContext context)
    {
        _env = env;
        _context = context;
    }
index - public ActionResult Index()
    {
        List<Hero> heroList = _context.hero.ToList();
        return View(heroList);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM