patched flow2schema
 
Go to file
Paul Loyd 38c0a8b804 v0.3.1 2018-01-13 20:57:00 +03:00
bin Make CLI 2017-12-17 13:13:27 +03:00
declarations Make CLI 2017-12-17 13:13:27 +03:00
src oneOf -> anyOf for maybe types 2018-01-13 20:54:46 +03:00
tests oneOf -> anyOf for maybe types 2018-01-13 20:54:46 +03:00
.babelrc Use flow to check code 2017-11-18 12:38:34 +03:00
.flowconfig Stricter the flow config 2017-12-01 20:01:38 +03:00
.gitignore Compile sources with babel 2017-11-16 15:17:15 +03:00
.travis.yml Add coverage 2017-11-05 01:13:56 +03:00
README.md Add a small example 2017-12-17 13:39:17 +03:00
appveyor.yml Drop flow checks for appveyor 2017-11-18 13:48:16 +03:00
package.json v0.3.1 2018-01-13 20:57:00 +03:00

README.md

flow2schema

Version npm Linux Build Windows Build Coverage Status

Example

$ cat example.js
type A<T, K> = {
    t: T,
    k: K,
};

export type X = {
    a: A<string, boolean>,
    b: number,
};
$ flow2schema -t json-schema example.js
{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "definitions": {
        "example::A::string::boolean": {
            "type": "object",
            "properties": {
                "t": {"type": "string"},
                "k": {"type": "boolean"}
            },
            "required": ["t", "k"]
        },
        "example::X": {
            "type": "object",
            "properties": {
                "a": {"$ref": "#/definitions/example::A::string::boolean"},
                "b": {"type": "number"}
            },
            "required": ["a", "b"]
        }
    }
}

TODO

  • Complete generics support.
  • Errors and warnings.
  • Complete commonjs support.
  • Documentation.
  • Stabilize API.
  • Webpack plugin.
  • Rollup plugin.