Reputation: 5366
It works fine with the code below is I only have one parameter but how do I do TWO input parameters? If I just use [HttpGet] then none of the parameters are send though it works fine outside of Swagger. Help ?
//[HttpGet]
[Consumes("application/json")]
[HttpGet("{caseId}")]
public ActionResult Get(string caseId, string fileName)
{
return null;
}
Upvotes: 3
Views: 3263
Reputation: 5505
I was just experimenting with this.
I found the following code works with Swagger:
[HttpGet("{entityId}/{monthsOfHistory}")]
public async Task<ActionResult<DateTime>> GetAsync([FromRoute] int entityId, [FromRoute] int monthsOfHistory)
Upvotes: 1
Reputation: 887
Try using the FromUri or querystring attributes in your method signature
[Consumes("application/json")]
[HttpGet("{caseId}")]
public ActionResult Get(string caseId, [FromUri] string fileName)
{
return null;
}
or
[Consumes("application/json")]
[HttpGet("{caseId}")]
public ActionResult Get(string caseId, [QueryString] string fileName)
{
return null;
}
This should now document in swagger showing that the caseId is part of the route and that the fileName should be specified.
Upvotes: 3