In Swagger After Executing a Request. The Server Response for Errors Doesn't Contain Accurate Description(Bad Request) of the Error Instead it Shows Only the Status code( Error: response status is 400).
Upon Inspection of Network Tab the Response Status Code Also Doesn't Contain Status Code Description
Using .NetCore API 3.1 And Swashbuckle Aspnetcore -6.4.0
Statup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "BAIM");
});
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
Action Method in Controller
[HttpGet]
public ActionResult<IEnumerable<WeatherForecast>> Get()
{
return BadRequest();
}
Need the Response With Error Description. Upon Removing '''app.UseHttpsRedirection();''' From startup.cs Response is in the Required Format But using http is not Practical. Reason Why this is Happening is Also Unknown. If there is way to Customize Error: That is Also Good
I have Tried :
- Reinstalling Packages
- Removed Exception Handling Middleware Swagger Documentation And Configuration, Authentication To Check If Its Working For Now .
- Tried Sending Only Response Code Only.
- Writing Response Instead of Returning Bad Request
Thank a Lot in Advance