Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: using generics-sop to derive some ToJSON instances #59

Closed
wants to merge 1 commit into from

Conversation

phadej
Copy link
Collaborator

@phadej phadej commented Mar 6, 2016

Related to #56 as using this we could write sopSwaggerGenericToEncoding as by making own generics derivation, we don't need to postprocess existing values (we cannot postprocess `Encoding!)

Here I also used generics-sop, as it's just much more straightforward (for me).

@phadej phadej force-pushed the aeson-generics-sop branch 6 times, most recently from 91eea7f to fa69bf1 Compare March 7, 2016 00:31
@@ -1015,10 +1027,8 @@ instance ToJSON (CollectionFormat t) where
toJSON CollectionMulti = "multi"

instance ToJSON (ParamSchema t) where
toJSON = omitEmptiesExcept f . genericToJSONWithSub "items" (jsonPrefix "paramSchema")
where
f "items" (Array _) = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, how do you account for this with generics-sop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it falls out naturally as fields from sub-object aren't omitted. OTOH i'm looking for some kind of symmetric variant to do FromJSON, e.g. only omit fields which are specified in defaults if the values match.

@fizruk fizruk mentioned this pull request Mar 7, 2016
@phadej
Copy link
Collaborator Author

phadej commented Mar 8, 2016

Merged into #56

@phadej phadej closed this Mar 8, 2016
@phadej phadej deleted the aeson-generics-sop branch March 8, 2016 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants