slovely / TypeScriptDefinitionsGenerator

Generate TypeScript .d.ts files for your server classes, plus optionally create client-side interfaces for WebAPI / SignalR server implementations
MIT License
10 stars 1 forks source link

Options to generate all derived types #20

Open slovely opened 5 years ago

slovely commented 5 years ago

Sometimes you might have an API call that returns a base class, and the service decides which concrete type should actually be returned. Only the base class will be generated into classes.d.ts.

Wonderfully unrealistic example

public abstract Person { 
  public string Name {get;set;}
}
public class Staff {
  public string EmployeeNumber {get;set;}
}
public class Customer {
  public string CustomerNumber {get;set;}
}

public PersonBase GetPerson(int id) {
// might return a staff or customer object
}

We should have an option in the props file to specify a list of classes that should have all derived types generated automatically. So in this case, add "Person" to that list and Person/Staff/Customer would all be generated.

Current workaround: - reference the derived types in a Dummy API call.