Base solution for your next web application
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; }
}
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    kwongyuhong created

    @maliming

    Got it, thank a lot!

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)