Ask a Question

Generating a schema for a generic list in c#

New Member

Generating a schema for a generic list in c#

Hello im using swagger in a .NET API project, and trying to generate a schema from a generic list in C#. I have a class with a property of applicants, applicants can have types of applicant, or buisness. When I make the property a type of List<object> swagger ui is presenting value as a string. ex <Applicants>String</Applicants>


im trying to achieve something along the lines of the below



below is my class

public class UpdateSfsLoanStatusRequest
[XmlArrayItem("Applicant", Type=typeof(Applicant))]
[XmlArrayItem("Business", Type=typeof(Business))]
public List<object> Applicants { get; set; }
public class Applicant
public class Business


below is the request body swagger is generating 


any help would be much appreciated.



Occasional Visitor

It looks like you want to generate a specific XML structure in Swagger for your .NET API project. Swagger may not infer the desired structure automatically for pc. To achieve the structure you've shown, you can use XML attributes to specify the structure explicitly. Heres how you can modify your class to achieve the desired XML structure:



Showing results for 
Search instead for 
Did you mean: