Options and Swagger #1132
-
When I use
instead of
If I use the second JSON, my API works just fine. What I'm unclear about is where I need to deal with this. Is there something I need to do in my LanguageExt code or is this strictly a Swagger issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
IMO: Default JSON serialization of But this has some drawbacks and if you have a strict view on those things it is even better to serialize |
Beta Was this translation helpful? Give feedback.
IMO:
Default JSON serialization of
Option
and other types is a bit different to what you might expect. This is true for dictionary types, too.I built my own custom serializer (for System.Text.Json) to make LanguageExt types more "compatible", i.e. serialize
Option<string>
in the same way asstring?
.But this has some drawbacks and if you have a strict view on those things it is even better to serialize
Option
like an array because it is equivalent to an array that can have size 0 and size 1. So it depends who is consuming your API and how compatible you want/have to be.