mattiasw2 / swagger-elm

Generate Elm types and decoders based on a Swagger file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swagger Elm

Swagger elm generates types and decoders from Swagger document.

Try it out in the browser!

Note: This project is currently under active and initial development. Thus everything is not finished and there's no guarantee that anything will work as promised. However I'm happy for any testing and feedback I can get.

Installation

  1. npm install ahultgren/swagger-elm -g
  2. Optionally install elm format

Usage (unix)

Using elm-format:

cat swagger.json | swagger-to-elm | elm-format --stdin

Unformatted (no guarantee it will work):

cat swagger.json | swagger-to-elm

Contribution

Help and feedback would be gladly appreciated, but please just drop me a line (an issue) before you start, to prevent wasted effort.

Features

  • Basic decoding of all types (Integer, Float, String, Boolean, Object, Array, Null)
  • $refs
  • Enum for strings
    • Other types (if meaningful)
  • Default values for Integer, Float, String, Boolean
    • Complex types (if meaningful)
  • Sanitization of identifiers
  • Unit tests
  • Dicts (additionalProperties)
  • Recursive types and decoders
  • Encoders
  • Polymorphism (allOf and discriminator)
  • Formats? (datetime, uuid, etc)
  • Deduplication of types and fields

License

ISC

About

Generate Elm types and decoders based on a Swagger file


Languages

Language:Elm 99.6%Language:JavaScript 0.4%