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

Generating UpdateProductRequest #164

Closed
anasseb opened this issue Mar 20, 2022 · 2 comments
Closed

Generating UpdateProductRequest #164

anasseb opened this issue Mar 20, 2022 · 2 comments

Comments

@anasseb
Copy link

anasseb commented Mar 20, 2022

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.

@fretje
Copy link
Contributor

fretje commented Mar 20, 2022

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).

@anasseb
Copy link
Author

anasseb commented Mar 20, 2022

@fretje Thank you very much

@anasseb anasseb closed this as completed Mar 20, 2022
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

2 participants