-
Notifications
You must be signed in to change notification settings - Fork 10
Description
We keep running into compatibility issues, as various (test) environments have Locations and Tariffs with invalid information. This could range from completely wrong entries (country codes with more than 2 digits), easily ignorable issues (invalid enum value in optional field) to fixable issues (lat/lng with too many decimals)
Not only will this cause PUT/PATCH requests to fail, but also blocks paginated GET calls, as a single wrong field causes the entire call to be marked as invalid.
To improve compatibility, I'd suggest the following:
- All deserialisers use Partials -> this allows filtering out bad entries from a list
- All optional enums have a
@JsonEnumDefaultValue UNKNOWN
entry combined withDeserializationFeature#READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
- Configurable validation that allows fixing values and ignoring UNKNOWN values instead of error
The execution chain for clients on GET would be
- Deserialize Partial
- Validate
- optionally fixes issues
- optionally ignores UNKNOWN and sets it to null
- per entry, in case of list, and allows to filter invalid entries
- convert to non-partial (can be code generated mapper)
The execution chain for server on PUT/PATCH/POST would be
- transportServer handler
- deserializes partial
- service
- validates with optional overrides and fixes
- converts to non-partial
All these changes should be possible entirely within this lib, without affecting existing repo interfaces. Validation could be configured by either providing a Validator instance (instead of current static calls) or providing configuration in coroutine context