biocad / openapi3

OpenAPI 3.0 data model
BSD 3-Clause "New" or "Revised" License
39 stars 54 forks source link

`fromAesonOptions` ignores `omitNothingFields` and `tagSingleConstructors` options #55

Open stevladimir opened 2 years ago

stevladimir commented 2 years ago
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 commented 2 years ago

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 commented 1 year ago

Friendly ping