❔ How to convert query string to an Enum in a custom way
I have the following code: .
By default, If I send a GET request with a VehicleType = Foo, the framework will return a bad request. I want to change this behavior so that when it tries to convert the query string to VehicleType, it either succeed or returns VehicleType.Undefined
In other words, I am looking for something like a custom JsonConverter but that works on query strings rather than json body
any ideas ?
20 Replies
what happened
did you close and reopen this
yup, the other one was not so clear, since it was very long
IT doesn't help some one who wants to read as quickly as possible
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
I can't change the type to a string for sure
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
because I work in a company where there is some administrative overhead if you want to touch the API code :/
why you are changing string here ?
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
I know :/
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
yeah but here you changed the type of
VehicleType
to string
I mean here public string? VehicleType { get; set; } //Cannot change its type to string
it was public VehicleType? VehicleType {get; set;}
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
What's the messy alternative ?
Curious to know about it
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
what's this 😄
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
okay thanks, will check it !
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
I didn't know about Bing using an AI now 😅
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.