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
10 Replies
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
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
that's just the swagger documentation, that not how the user will be using the API
I know the [Range] data annotation has changed the value but i don't know how to counter that
ahh oke.
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
Ahhh. Now i understand. Swagger is doing this. But when someone uses my API. The "discountAmount" and "minAmount" wont be filled in?
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
correct, they'd have to provide values what calling your endpoint
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
The [DefaultValue()] does exactly what i want! Thanks for the help! Really appreciate it!