Rafael Cruz

Rafael Cruz

  • NA
  • 23
  • 0

Swagger not working when is deployed

May 17 2021 7:32 PM
I need some help, there is a .net core 3.1 project that includes swagger, swagger UI works in local but when is deployed.
 
ConfigureServices method
  1. // Register the Swagger generator, defining one or more Swagger documents  
  2. services.AddSwaggerGen(c =>  
  3. {  
  4. c.SwaggerDoc("v1"new OpenApiInfo  
  5. {  
  6. Title = "my app V1",  
  7. Version = "v1"  
  8. });  
  9. c.ExampleFilters();  
  10. c.OperationFilter();  
  11. // Set the comments path for the Swagger JSON and UI.  
  12. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";  
  13. var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);  
  14. c.IncludeXmlComments(xmlPath);  
  15. });  
  16. services.ConfigureSwaggerGen(options =>  
  17. {  
  18. options.CustomSchemaIds(x => x.FullName);  
  19. });  
  20. services.AddSwaggerExamplesFromAssemblies();  
Configure Method
  1. app.UseSwaggerUI(c =>  
  2. {  
  3. c.RoutePrefix = "swagger";  
  4. c.SwaggerEndpoint("./v1/swagger.json""my app V1");  
  5. c.DefaultModelsExpandDepth(-1);  
  6. });  

Answers (2)