Swagger page is not loading when I have POST and PUT method in the same API controller. If I remove or comment either one from the controller it is working fine.
Is there any way to use both in the same controller.
Below is my code snippets,
Controller:
[HttpGet]
public async Task<ActionResult<List<Activity>>> List()
{
return await _mediator.Send(new List.Query());
}
[HttpGet("{id}")]
public async Task<ActionResult<Activity>> Details(Guid id)
{
return await _mediator.Send(new Details.Query { Id = id });
}
[HttpPost]
public async Task<ActionResult<Unit>> Create(Create.Command command)
{
return await _mediator.Send(command);
}
[HttpPut("{id}")]
public async Task<ActionResult<Unit>> Edit(Guid id, Edit.Command command)
{
command.Id = id;
return await _mediator.Send(command);
}
[HttpDelete("{id}")]
public async Task<ActionResult<Unit>> Remove(Guid id)
{
return await _mediator.Send(new Remove.Command { Id = id });
}
Swagger configure in Startup
//Included swagger
services.AddSwaggerGen(options => options.SwaggerDoc(name: "v1", new OpenApiInfo { Title = "Reactivities", Version = "v1" }));
// Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(x => { x.SwaggerEndpoint("/swagger/v1/swagger.json", "Reactivities - V1"); });
Am I missing something? Please advice.