brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

Support enum types with numeric values #889

Open endgame opened 1 year ago

endgame commented 1 year ago

Example: Every value in apigateway's CacheClusterSize type contains only numbers and dots, so they all get mashed together into a single strange pattern:

https://github.com/boto/botocore/blob/ac9ce8eb9ab4296608c95c5d04461266925d90e2/botocore/data/apigateway/2015-07-09/service-2.json#L2337-L2350

Affected types include:

brendanhay commented 1 year ago

Given both of the examples have floating point values - is the desired behaviour to just replace "." "_" to make a valid constructor/identifier? Or is some kind of floating point equivalent of {To,From}Enum a desired here?

endgame commented 1 year ago

I think we should just do replace '.' '_' to begin with and look at doing something else if/when that proves insufficient. Are you thinking of PRing this for 2.0?

brendanhay commented 1 year ago

Yeah - considering if there’s any low hanging things that are breaking changes. I’ll take a look at this one today.

endgame commented 1 year ago

Okay, I've looked into this and it's annoying enough and affecting few enough people that I want to kick it back to post-2.0:

I don't really want to keep piling hacks atop hacks in this version of the generator. In the medium term, I want to build an AST representation of the data as it is represented in botocore, parsed out using waargonaut. (Unlike aeson, waargonaut remembers the order of keys in JSON objects, which is important for things like correctly emitting field names in order). Once we have that AST, I want to build a new version of the generator which takes the simplest necessary service description and write an adapter function between them. This will mean that people using IAM authentication with API Gateway can generate their own amazonka-style APIs to access them; Amazon's own Selling Partner API (SP-API) is a prominent example.