Is there a way in the UI Explorer to fill some of the data entry boxes with default values? I was hoping this would work but it didn’t. This would speed up testing.
public class CustomerHistory : IReturn<CustomerHistory>
{
public Guid CustID { get; set; } = new("2770FA69-EF7D-48B4-ACE8-3D9021EA015B");
public int Season { get; set; } = 2023;
}
DTOs are inert data containers, any implementation or logic within them are not included in the generated Add ServiceStack Reference DTOs which is what’s used to invoke the APIs, as such they shouldn’t contain or rely on any implementation within them.
To customize how Auto Form UIs are generated you can use the Declarative UI Attributes, e.g the [Input] attribute is used to customize the HTML Input control used:
public class CustomerHistory : IReturn<CustomerHistory>
{
[Input(Value = "2770FA69-EF7D-48B4-ACE8-3D9021EA015B")]
public Guid CustID { get; set; }
[Input(Value = "2023")]
public int Season { get; set; }
}
Unfortunately this fixes the value of the input control, which prevents them being edited. So ok for testing, but not useful for usage as a default value.
actually, not even ok for being tested! When I set the input values and click the send in Api Explorer, the parameters don’t get added to the query string.
That would be because it doesn’t trigger the input event that causes the reactive value to update. You can run something like this in Web Inspector to populate the Input fields and trigger the value updates: