Open Closed

Error Generating proxy Angular v2.9 #273


User avatar
0
buaziz created
  • ABP Framework version: v2.9
  • UI type: Angular
  • Identity Server Seperated (Angular)
  • Steps to reproduce the issue:
  1. Create new AppService
  2. Add GetList Method
  3. Angular client : Generate proxy - abp generate-proxy

Issue: I have a simple app service with one method but the generated proxy for the output DTO is incorrect.

AppService Method

   public virtual async Task<PagedResultDto<CampaignDto>> GetCampaignListAsync(GetCampaignsInput input)
        {

            var totalCount = await _campaignRepository.GetCountAsync(input.FilterText, input.Name);
            var items = await _campaignRepository.GetListAsync(input.FilterText, input.Name, input.Sorting, input.MaxResultCount, input.SkipCount, false);

            return new PagedResultDto<CampaignDto>
            {
                TotalCount = totalCount,
                Items = ObjectMapper.Map<List<Campaign>, List<CampaignDto>>(items)
            };
        }

Here is the problem>> Generated Proxy (incorrect)


import { ListResultDto } from '@abp/ng.core';

export class CampaignDto extends ListResultDto<ACME.Campaigns.CampaignDto> {
  totalCount: number;
  items: any[];

  constructor(initialValues: Partial<CampaignDto> = {}) {
    super(initialValues);
  }
}

Generated Service (correct)

import { RestService , PagedResultDto} from '@abp/ng.core';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import {GetCampaignsInput, CampaignDto} from '../models';

@Injectable({providedIn: 'root'})
export class CampaignService {
  apiName = 'Default';

  constructor(private restService: RestService) {}

 getCampaignListByInput(params = {} as GetCampaignsInput): Observable<PagedResultDto<CampaignDto>> {
   return this.restService.request({ url: '/api/app/campaign/campaignList', method: 'GET', params },{ apiName: this.apiName });
 }
}

DTO Class

namespace ACME.Campaigns
{
    public class CampaignDto : AuditedEntityDto<Guid>
    {
        public string Name { get; set; }     
    }
}

3 Answer(s)
  • User Avatar
    0
    buaziz created

    repro on the BookStore sample app

    book-dto.ts

    
    
    import { ListResultDto } from '@abp/ng.core';
    
    export class BookDto extends ListResultDto<Acme.BookStore.BookDto> {
      totalCount: number;
      items: any[];
    
      constructor(initialValues: Partial<BookDto> = {}) {
        super(initialValues);
      }
    }
    
    

    book-test.service.ts

    import { RestService , PagedResultDto} from '@abp/ng.core';
    import { Injectable } from '@angular/core';
    import { Observable } from 'rxjs';
    import {BookDto} from '../models';
    
    @Injectable({providedIn: 'root'})
    export class BookTestService {
      apiName = 'Default';
    
      constructor(private restService: RestService) {}
    
     getList(): Observable<PagedResultDto<BookDto>> {
       return this.restService.request({ url: '/api/app/bookTest', method: 'GET' },{ apiName: this.apiName });
     }
    }
    
    
  • User Avatar
    0
    alper created
    Support Team Director

    @buaziz sorry for my late response! did you manage to solve the issue?

  • User Avatar
    0
    buaziz created

    solved with v3.0.5

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11