sbornstein2
asked on
ASP.Net Web API Optional Boolean Param
I am trying to use an optional boolean parameter to a web endpoint and I am using swagger. I have tried {isActive?} then bool? or bool = false etc. and everytime no matter what when I select true in swagger it passes false. If I make it {isActive} then bool it seems to work by in Swagger it is defaulted to true and when I click execute it shows a validation red and won't pass unless I change it to false then back to true.
How can I best pass an optional boolean and is there something for swagger I need to do to get it to behave properly?
Thanks all
How can I best pass an optional boolean and is there something for swagger I need to do to get it to behave properly?
Thanks all
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Okay, what kind of API?
Cause this seems not to be an optional parameter, but a filter. So /Customers?active=1 or /Customers?active=0 (or using true/false instead of 1/0).
Cause this seems not to be an optional parameter, but a filter. So /Customers?active=1 or /Customers?active=0 (or using true/false instead of 1/0).
ASKER
I understand what you are saying but is it cleaner to have on a swagger api site duplicate endpoints for every one I want to have the option to only select active records?