swagger-api / swagger-api/swagger-codegen
[HASKELL] Generated types do not produce/consume JSON according to spec
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In a Swagger spec file, when specifying eg. "payment_data" as a field name in an object, the resulting Haskell type produces (and consumes) JSON with a field name of "PaymentData". So eg. "channel_value_left" becomes "ChannelValueLeft". This breaks compatibility with the client library.
Swagger-codegen version
master @ a3610f1c12e5d7912cf2e9f16dff2152ef40291b
Swagger declaration file content or url
https://gist.github.com/runeksvendsen/305a3018fe48723998851419c2e4393d
Command line used for generation
$ java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l haskell -i swagger.yaml
$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Steps to reproduce
wget https://gist.githubusercontent.com/runeksvendsen/305a3018fe98851419c2e4393d/raw/5d022bdef0355128c54d2235ea986aa84efa3e3e/swagger.yaml
java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l haskell -i swagger.yaml
cat lib/BitcoinPaymentChannelRESTProtocol/Types.hs
Suggest a Fix
Perhaps add a config option like the modelPropertyNaming option that typescript-node has, which allows choosing word separation semantics ('camelCase', 'PascalCase', 'snake_case' etc.).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Java generation command with the linked swagger.yaml, then inspect lib/BitcoinPaymentChannelRESTProtocol/Types.hs. Compare the generated JSON field names with the Swagger names, especially payment_data and channel_value_left; done means the generated Haskell types produce and consume the specified names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100