Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property of list type maps to wrong type #2769

Open
EmraanSiddiqui opened this issue Feb 27, 2024 · 2 comments
Open

Property of list type maps to wrong type #2769

EmraanSiddiqui opened this issue Feb 27, 2024 · 2 comments

Comments

@EmraanSiddiqui
Copy link

EmraanSiddiqui commented Feb 27, 2024

Hi Team, We have a response structure like this:

{
  "result": {
    "resultCode": "string",
    "resultDetailList": [
      {
        "detail": "string",
        "message": "string",
        "type": "string"
      }
    ],
    "source": "string"
  },
  "totalCount": 0,
  "virtualCustomers": [
    {
      "virtualCustomer": {
        "virtualCustomerType": [
          {
            "key": "string",
            "value": "string"
          }
        ],
        "virtualCustomerSubType": [
          {
            "key": "string",
            "value": "string"
          }
        ],
        "virtualCustomerCategory": [
          {
            "key": "string",
            "value": "string"
          }
        ],
        "virtualCustomerId": "string",
        "VirtualCustomers": [
          "string"
        ]
      }
    }
  ]
}

The class structure is like this:

[ExcludeFromCodeCoverage]
public sealed class CreateThirdPartyCustomerRelationshipResponse : ApiResponseBase
{
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public ThirdPartyCustomerInformationBase ThirdPartyCustomer;

    public List<CreateVirtualCustomerResponseBase> VirtualCustomers { get; set; }
}

[ExcludeFromCodeCoverage]
public sealed class CreateVirtualCustomerResponseBase
{
    public TPCVirtualCustomerResponse VirtualCustomer { get; set; }
}

public class TPCVirtualCustomerResponse : VirtualCustomerResponseBase
{
    public string VirtualCustomerId { get; set; }

    public List<CreateVirtualCustomerResponseBase> VirtualCustomers { get; set; }
}

[ExcludeFromCodeCoverage]
public sealed class CreateVirtualCustomerResponseBase
{
    public TPCVirtualCustomerResponse VirtualCustomer { get; set; }
}

[ExcludeFromCodeCoverage]
public abstract class VirtualCustomerResponseBase
{
    public List<KeyValue> VirtualCustomerType { get; set; }

    public List<KeyValue> VirtualCustomerSubType { get; set; }

    public List<KeyValue> VirtualCustomerCategory { get; set; }
}

the last virtual customers array in 201 created response example loading as string array instead of class object

image

How I can solve this issue, I searched a lot for the same but no matching solution found.

@Havunen
Copy link

Havunen commented Mar 5, 2024

Have you tested if DotSwashbuckle solves this issue? If it doesn't can you create a simple project where this issue is reproduced as a zip file or github repository please. I can take a look then.

@martincostello
Copy link
Collaborator

Could you create a minimal reproducible example project that demonstrates the issue in a GitHub repo please? Then it should be a lot easier for someone to look into this and see if we can fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants