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

fromAesonOptions ignores omitNothingFields and tagSingleConstructors options #55

Open
stevladimir opened this issue Aug 8, 2022 · 2 comments

Comments

@stevladimir
Copy link
Contributor

fromAesonOptions :: Options -> SchemaOptions
-- ...
-- Note that these fields have no effect on SchemaOptions:

--    omitNothingFields
--    tagSingleConstructors

Are there any deep reasons behind that? Or is it just lack of hands to add support?

And thank you for awesome library!

@stevladimir
Copy link
Contributor Author

One of the real examples where it may become a practical problem.

Assume we have an API type

data T = A Int | Bar Char deriving (Generic, FromJSON, ToJSON)
-- > encode A 1
-- {"tag":"A", "contents":1}

At some point we remove Bar constructor and default aeson encoding changes to 1 (IMO this isa flaw in aeson, but that's another story). To preserve encoding backward compatibility we can add tagSingleConstructors = True, but that does not "fix" derived ToSchema instance and we have to bake it manually.

@stevladimir
Copy link
Contributor Author

Friendly ping

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

No branches or pull requests

1 participant