I write my Web API controllers in a non-standard way where I get the parameters as dynamic objects.
This creates an issue with NSwag. Because there are no parameters in the method definition, NSwag cannot generate what is needed.
I wonder if there is any option to use NSwag in this situation. Maybe there are some attributes that I can add to the methods so that NSwag will be able to generate the API?
[HttpPost]
[ActionName("create-account")]
public IHttpActionResult CreateAccount()
{
var body = Request.Content.ReadAsStringAsync().Result;
dynamic json = Utils.GetJsonBody(body);
if (!Utils.GetJsonPropertyValueByPropertyName<String>(json, "email", out String email))
{
return Content(HttpStatusCode.BadRequest, "Please provide a valid email.".AsApiMessageResult());
}
if (!Utils.GetJsonPropertyValueByPropertyName<String>(json, "name", out String name))
{
return Content(HttpStatusCode.BadRequest, "Please provide an account name.".AsApiMessageResult());
}
if (!Utils.GetJsonPropertyValueByPropertyName<String>(json, "domain", out String domain))
{
return Content(HttpStatusCode.BadRequest, "Please provide a valid domain.".AsApiMessageResult());
}