Base solution for your next web application
Open Closed

How use Client Api generate by NSwagStudio doesn't work #11656


User avatar
0
martp00 created

So basically using NSwagStudio or Unchase openAPI to generate a c# client api work. But when using it, the return data are null. I see some thread telling to deactivate the wrapresult in PreInitialize() of Core WebCoreModule.cs

Like this:

Configuration.Modules.AbpAspNetCore().DefaultWrapResultAttribute.WrapOnError = false;
Configuration.Modules.AbpAspNetCore().DefaultWrapResultAttribute.WrapOnSuccess = false;

So doing this, make the client api working but, all the website is not working anymore.

Trying to change any data making display the general error box.

Using ASP.NET CORE MVC & jQuery v12.2.0

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

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @martp00

    For our MAUI application, we are using custom proxy services, you can check this example https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application.Client/MultiTenancy/ProxyTenantAppService.cs

    If you want to use C# proxies generated by NSwagStudio, you may create a base class for your services, process the return result and only return unwrapped result.

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

    Thank you for your answer, the url doesn't look to work,

    I try to decorate my function with this [ProducesResponseType(200, Type = typeof(ResponseWrapper<AuthenticateResultModel>))]

    Also, I make the custom ResponseWrapper class, it seems to work and now I have also the swagger definition who reflect the wrap result.

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

    Hi @martp00

    I'm glad that you have solved this. You can access the AspNet Zero's private GitHub repository by adding your GitHub username on https://aspnetzero.com/LicenseManagement page. Or, you can send an email to [email protected] about this.

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