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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Optional parameters are evil. At least from a clean code approach...

Bob Martin said once:
Functions should have a small number of arguments. No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice.
Especially indicate Boolean parameters, that a function does more than one thing. Thus instead of that parameter you should have two functions.

In an API they should be avoided at all costs. Cause it is not clear from the provider perspective, whether the consumer forgot to specify the parameter, thus that he's using the correct (default) value.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sbornstein2Author Commented:
So you think it is better to say have two endpoints for each one one for every endpoint an all endpoint and one for only active?   /Customer and /Customer/active for example?

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?
ste5anSenior DeveloperCommented:
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).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.