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
- // Register the Swagger generator, defining one or more Swagger documents
- services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo
- {
- Title = "my app V1",
- Version = "v1"
- });
- c.ExampleFilters();
- c.OperationFilter();
- // Set the comments path for the Swagger JSON and UI.
- var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
- var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
- c.IncludeXmlComments(xmlPath);
- });
- services.ConfigureSwaggerGen(options =>
- {
- options.CustomSchemaIds(x => x.FullName);
- });
- services.AddSwaggerExamplesFromAssemblies();
Configure Method
- app.UseSwaggerUI(c =>
- {
- c.RoutePrefix = "swagger";
- c.SwaggerEndpoint("./v1/swagger.json", "my app V1");
- c.DefaultModelsExpandDepth(-1);
- });
Salman BegPosted May 18, 2021, 11:20 AM
Varun SetiaPosted May 18, 2021, 9:27 AM
What is the exact error, "cannot find swagger.json" or something else ?