Spine icon indicating copy to clipboard operation
Spine copied to clipboard

Globally specify operation serializer options

Open markst opened this issue 8 years ago • 4 comments

We'd like to globally specify OmitNullValues as a default option when serializing, or perhaps even be able to specify endpoint specific options...

markst avatar Aug 12 '16 11:08 markst

What is your use case for this? Perhaps there is a way we can solve it without adding any more configuration options.

wvteijlingen avatar Aug 21 '16 18:08 wvteijlingen

Current use case is as I mentioned, here's my Spine branch changes:

if isNewResource {
    URL = router.URLForResourceType(resource.resourceType)
    method = "POST"
    options = [.IncludeToOne, .IncludeToMany, .OmitNullValues]
} else {
    URL = router.URLForQuery(Query(resource: resource))
    method = "PATCH"
    options = [.IncludeID, .OmitNullValues]
}

markst avatar Aug 23 '16 14:08 markst

Why do you want to omit null values? If it's because of overwriting attributes that weren't fetched, I recommend trying the dirty-checking branch.

wvteijlingen avatar Aug 26 '16 14:08 wvteijlingen

thanks @wvteijlingen yeah dirty checking also achieves what I wish for. However this still requires me to create an instance of SerializeOperation to be able to assign options.

I'd like to be able to globally specify all SerializeOperations always dirty check.

markst avatar Nov 28 '16 06:11 markst