Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Input DTO was not validated into parameter #7116


User avatar
0
kwongyuhong created

I created an application service with several function in it. The problem is when I run the swagger, some of the parameter's input is not converted into properties of parameters instead it is displayed as JSON (ex. CopyAddressBookTemp as in image). The rest of the functions' parameter input are fine. How to resolve this?

Application service code:

public class AddressBookGroupAppService : FlurrAppServiceBase, IAddressBookGroupAppService
{
    ...
    public async Task CopyAddressBookTemp(CopyAddressBookTempInput input){
        ...
    }
}

Input DTO code (CopyAddressBookGroupTempInput class):

public class CopyAddressBookTempInput
{
    public bool IsPrivate { get; set; }
}

4 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team

    This is because the parameter passing method of the CopyAddressBookTemp method is http body, so swagger is displayed as json, which is normal.

  • User Avatar
    0
    kwongyuhong created

    @maliming is there away to set it query? because I have similar input that is using boolean too that is displayed as query

  • User Avatar
    1
    maliming created
    Support Team

    http get will pass arguments in the query string, post will use the body.

    You can manually specify the http verb of the method.

    Related documents https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API#http-attributes https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#application-services-as-controllers

  • User Avatar
    0
    kwongyuhong created

    @maliming

    Got it, thank a lot!