Search code examples
aspnetboilerplate

Exclude Real models from swagger model list


I have some issue that I want to solve. I'm using AppService exactly as described in documentation.

[AbpAuthorize(PermissionNames.Pages_Companies)]
public class CompanyAppService : CrudAppService<Company, CompanyDto>
{
    public CompanyAppService(IRepository<Company, int> repository) : base(repository)
    {
    }
}

My issue is that Swagger exposes the real model "Company" and the other models in the model list that is unwanted behavior. I have to hide the real models. Have a look at screen, all these models from domains layer, and all of them contains appropriate DTO. As I can see swagger doesn't exposes the real Models of Abp itself. Please help to hide my models.

real models on screed


Solution

  • I found the issue. I have exposed the real model inside DTO instead of expose their DTOs in navigation property. This way swagger had to expose my models because they were in use. I've changed my DTOs to use appropriate DTO instead of model inside DTOs. (Sorry for the tautology). Now swagger hides my real models from the model list because they're no longer in use. Problem solved. Hope it helps some one else.