fullstackhero / blazor-wasm-boilerplate

Clean Architecture Boilerplate Template for .NET 6.0 Blazor WebAssembly built for FSH WebAPI with the goodness of MudBlazor Components.

Home Page:https://fullstackhero.net/blazor-webassembly-boilerplate/general/getting-started/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generating UpdateProductRequest

anasseb opened this issue · comments

Hello,
When I generate the UpdateProductRequest with the NSwag command, how can I specify the default value of a property ?
For exemple instead of = default! I want to set = 1.
I made the property in the API class UpdateProductRequest to = 1, but when launching the command it's not taking it.

Is it normal or there is another way to do it ?
Thanks.

The request objects are just dto's so they shouldn't contain any logic.

If you want to set default values, you have to populate the request object with those values before showing it in a "create" view.

If you use the EntityTable, there is actually a "GetDefaultsFunc" (Func<Task<TRequest>>) property on the EntityTableContext you can set which will be called before showing the "create" modal. There you have to return a request object which is initialized with the default values. It's an async func so if you want you can actually call an api endpoint on the server to provide a request object with the default values (if you want to let the domain objects on the server take care of that).

@fretje Thank you very much