openapi3-code-generator: OpenAPI3 Haskell Client Code Generator

[ code-generator, library, mit, program ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.6, 0.1.0.7
Change log ChangeLog.md
Dependencies aeson, base (>=4.7 && <5), bytestring, containers, directory, filepath, hashmap, http-client, http-conduit, http-types, mtl, openapi3-code-generator, options, scientific, split, template-haskell, text, time, transformers, unordered-containers, vector, yaml [details]
License MIT
Copyright 2020 Remo Dörig & Joel Fisch
Author Remo Dörig & Joel Fisch
Maintainer Joel Fisch <joel.fisch96@gmail.com> & Remo Dörig <remo.doerig@gmail.com>
Category Code-Generator
Home page https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator#readme
Bug tracker https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator/issues
Source repo head: git clone https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator
Uploaded by remo_doerig at 2020-05-27T14:28:26Z
Distributions
Executables openapi3-code-generator-exe
Downloads 1133 total (28 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-05-27 [all 1 reports]

Readme for openapi3-code-generator-0.1.0.3

[back to package description]

openapi3-code-generator

CircleCI

How to use?

  1. install stack
  2. stack install openapi3-code-generator
  3. openapi3-code-generator my_specification.yml

An out directory is created with the generated code. Hint you can use --output-dir to specify another output directory. You can use openapi3-code-generator --help to list all CLI options.

Example package

In the folder example is a package that uses the generated code from specifications/petstore.yml. You can run stack test inside the example directory to run the code, it calls the server "https://petstore.swagger.io/v2" with some sample data.

https://github.com/Haskell-OpenAPI-Code-Generator/Stripe-Haskell-Library uses this code generator to generate a Stripe API client.

Documentation

The documentation for the code can be found at https://hackage.haskell.org/package/openapi3-code-generator This package was created as part of a bachelor thesis. This thesis can be found here TODO.

Large specifications

For large specifications some modules (CyclicTypes.hs for example) can get pretty big. It may be necessary to use --fast with stack build --fast to build the code.

Module structure of the generated code.

All symbols are globally unique and are reexported in the module OpenAPI (Module name can be changed with --module-name). To reduce compile time, the code is split up into multiple modules. Mainly for every operation and for every schema. Schemas with cyclic dependencies are are in the module OpenAPI.CyclicTypes.

Troubleshooting naming conflicts

Naming conflicts can happen, sometimes a little manual adjustment is needed. With the following options naming conflicts can be resolved.

  • property-type-suffix
  • response-type-suffix
  • response-body-type-suffix
  • request-body-type-suffix
  • use-numbered-variant-constructors
  • convert-to-camel-case