abp icon indicating copy to clipboard operation
abp copied to clipboard

Generate proxy issue with c# nested class

Open naazz1992 opened this issue 3 years ago • 0 comments

Abp framework 4.4 Angular EF Core

When generating proxy for the following class i get a faulty definition inside generate-proxy.json which cause the typescript class to have a + sign in the name.

[Tranchant.Estimation.Quotes.QuoteFormProductListResponse+Product]

I didn't find any way in the documentation to solve that. I was able to solve it with swagger customizing CustomSchemaIds but since the proxy generation doesn't rely on that.

C# DTO

public class QuoteFormProductListResponse
    {
        public List<Product> Products { get; set; }
        public int TotalCount { get; set; }

        public class Product : EntityDto<Guid>
        {
            public string Name { get; set; }
        }
    }

generate-proxy.json

"Tranchant.Estimation.Quotes.QuoteFormProductListResponse": {
      "baseType": null,
      "isEnum": false,
      "enumNames": null,
      "enumValues": null,
      "genericArguments": null,
      "properties": [
        {
          "name": "Products",
          "jsonName": null,
          "type": "[Tranchant.Estimation.Quotes.QuoteFormProductListResponse+Product]",
          "typeSimple": "[Tranchant.Estimation.Quotes.QuoteFormProductListResponse+Product]",
          "isRequired": false
        },
        {
          "name": "TotalCount",
          "jsonName": null,
          "type": "System.Int32",
          "typeSimple": "number",
          "isRequired": false
        }
      ]
    },
    "Tranchant.Estimation.Quotes.QuoteFormProductListResponse+Product": {
      "baseType": "Volo.Abp.Application.Dtos.EntityDto<System.Guid>",
      "isEnum": false,
      "enumNames": null,
      "enumValues": null,
      "genericArguments": null,
      "properties": [
        {
          "name": "Name",
          "jsonName": null,
          "type": "System.String",
          "typeSimple": "string",
          "isRequired": false
        }
      ]
    }

Typescript model

export interface QuoteFormProductListResponse {
  products: QuoteFormProductListResponse+Product[];
  totalCount: number;
}

export interface QuoteFormProductListResponse+Product extends EntityDto<string> {
  name?: string;
}

naazz1992 avatar Jan 09 '22 21:01 naazz1992