Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger.json not generated #7

Open
jarnaiz opened this issue Oct 14, 2021 · 0 comments
Open

swagger.json not generated #7

jarnaiz opened this issue Oct 14, 2021 · 0 comments

Comments

@jarnaiz
Copy link

jarnaiz commented Oct 14, 2021

Im using .net core v5 and the json file returns 404.

No errors founds...

my startup.cs looks like:

// Services

services.AddSwaggerGen(opts => {
    opts.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
    {
        Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
        Name = "Authorization",
        BearerFormat = "JWT",
        Scheme = "Bearer",
        In = ParameterLocation.Header,
        Type = SecuritySchemeType.Http,
    });
    opts.AddSecurityRequirement(new OpenApiSecurityRequirement {
       {
         new OpenApiSecurityScheme
         {
           Reference = new OpenApiReference
           {
             Type = ReferenceType.SecurityScheme,
             Id = "Bearer"
           }
          },
          new string[] { }
        }
      });
});
services.AddSwaggerGenWithConventionalRoutes(options =>
{
    options.SkipDefaults = true;
});
// Configure
app.UseSwagger();

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("v1/swagger.json", "Endurance V1");
});

 app.UseEndpoints(endpoints =>
{
      endpoints.MapControllers();

      endpoints.MapAreaControllerRoute(
         name: "ficha",
         areaName: "Ficha",
         pattern: "{controller}/{id}",
         defaults: new { controller = "Ficha", action = "Index" },
         constraints: new { id = @"\d+" }
      );

      endpoints.MapControllerRoute(
          name: "default",
          pattern: "{controller=Home}/{action=Index}/{id?}");

    ConventionalRoutingSwaggerGen.UseRoutes(endpoints);

});

Any suggestion? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant