gandalf
gandalf

Reputation: 470

Swagger-WebAPi with two params fromuri and frombody

I have an API with two params, the first is from URI the second from the Body, the generated doc with swagger take all params from URI, it doesn't put the body params in the body. Is it a limit for swagger or should I add some configuration?

public IHttpActionResult Put([FromUri] string id, [FromBody] string name, [FromBody] bool activate = false)
{
    return Ok();
}

Thanks.

Upvotes: 1

Views: 1509

Answers (1)

Anapsidae
Anapsidae

Reputation: 194

You cannot have more than one [FromBody] used in your method signature. If you have multiple values, you should just encapsulate into an object to your liking :)

https://learn.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api

Upvotes: 2

Related Questions