flow2schema/README.md

1.4 KiB

flow2schema

Version npm Linux Build Windows Build Coverage Status

Currently avro is the only supported target.

Example

Input ($ cat example.js):

export interface Foo {
    foo: string,
    // $avro long
    bar: number,
    opt: ?number,
    baz: 'one' | 'two',
    mix: 'one' | 'two' | number,
}

Output ($ ./bin/flow2schema example.js):

[
  {
    "type": "record",
    "fields": [
      {"name": "foo", "type": "string"},
      {"name": "bar", "type": "double"},
      {"name": "opt", "type": ["null", "double"]},
      {"name": "baz", "type": {"type": "enum", "symbols": ["one", "two"]}},
      {
          "name": "mix",
          "type": ["double", {"type": "enum", "symbols": ["one", "two"]}]
      }
    ],
    "name": "Foo",
    "namespace": "example"
  }
]

TODO

  • Complete generics support.
  • Errors and warnings.
  • Support commonjs modules.
  • Documentation.