You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I am trying to do is have one endpoint name/route with multiple parameters.
I have got the endpoints working but when viewing swagger file, I get the error
'Fetch error undefined ./v1/swagger.json'
Below is complete code that causes the issue.
If i remove one of the end points and just leave one (still with [PostFor], it works and swagger file/doc shows, as soon as I add the second, swagger file stops working.
VERSION:
5.0
STEPS TO REPRODUCE:
public class PostForAttribute: ActionMethodSelectorAttribute
{
public Type Type { get; }
public PostForAttribute(Type type)
{
Type = type;
}
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action)
{
routeContext.HttpContext.Request.EnableBuffering();
var body = new StreamReader(routeContext.HttpContext.Request.Body).ReadToEndAsync().Result;
try
{
JsonConvert.DeserializeObject(body, Type, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error });
return true;
}
catch (Exception)
{
return false;
}
finally
{
routeContext.HttpContext.Request.Body.Position = 0;
}
}
}
public class TestController : ControllerBase
{
private readonly IMediator _mediator;
public TestController(IMediator mediator)
{
_mediator = mediator;
}
[HttpPost("/send")]
[PostFor(typeof(Class2))]
public async Task<IActionResult> Class2Method(Class2 cmd)
{
var user = await _mediator.Send(cmd);
return Ok(user);
}
[HttpPost("/send")]
[PostFor(typeof(Class1))]
public async Task<IActionResult> Class1Method(Class1 cmd)
{
var user = await _mediator.Send(cmd);
return Ok(user);
}
public class Class1
{
public string ClassOne { get; set; }
}
public class Class2
{
public string ClassTwo { get; set; }
}
}
EXPECTED RESULT:
Multiple end points with same name and different parameters
ACTUAL RESULT:
Fetch error undefined ./v1/swagger.json
The text was updated successfully, but these errors were encountered:
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Conflicting method/path combination "GET WeatherForecast/mypath/{id}" for actions - ActSel.Controllers.WeatherForecastController.Get1 (ActSel),ActSel.Controllers.WeatherForecastController.Get2 (ActSel). Actions require a unique method/path combination for Swagger/OpenAPI 3.0. Use ConflictingActionsResolver as a workaround at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
What I am trying to do is have one endpoint name/route with multiple parameters.
I have got the endpoints working but when viewing swagger file, I get the error
'Fetch error undefined ./v1/swagger.json'
Below is complete code that causes the issue.
If i remove one of the end points and just leave one (still with [PostFor], it works and swagger file/doc shows, as soon as I add the second, swagger file stops working.
VERSION:
5.0
STEPS TO REPRODUCE:
EXPECTED RESULT:
Multiple end points with same name and different parameters
ACTUAL RESULT:
Fetch error undefined ./v1/swagger.json
The text was updated successfully, but these errors were encountered: