C
C#12mo ago
Paulvv

How do i set the int to 0 and set the string to empty

I'm working on a API project. And i have a CouponDto that has 3 properties (See Image). When i run the API project the properties are already filled in inside the POST methode (See other image). I would the POST methode to start with the following properties. "couponCode": "", "discountAmount": 0, "minAmount": 0
No description
No description
10 Replies
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Paulvv
PaulvvOP12mo ago
I understand that. But i would like the default values to be different. If someone uses this API. The properties would be valid without the person changing them I want to counter that
Anu6is
Anu6is12mo ago
that's just the swagger documentation, that not how the user will be using the API
Paulvv
PaulvvOP12mo ago
I know the [Range] data annotation has changed the value but i don't know how to counter that ahh oke.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Paulvv
PaulvvOP12mo ago
Ahhh. Now i understand. Swagger is doing this. But when someone uses my API. The "discountAmount" and "minAmount" wont be filled in?
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Anu6is
Anu6is12mo ago
correct, they'd have to provide values what calling your endpoint
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Paulvv
PaulvvOP12mo ago
The [DefaultValue()] does exactly what i want! Thanks for the help! Really appreciate it!
No description
No description
Want results from more Discord servers?
Add your server