flow2schema/README.md

61 lines
1.5 KiB
Markdown
Raw Normal View History

2017-11-16 17:34:27 +03:00
# flow2schema
2017-10-29 02:15:03 +03:00
2017-11-16 17:34:27 +03:00
[![Version npm](https://img.shields.io/npm/v/flow2schema.svg)](https://www.npmjs.com/package/flow2schema)
[![Linux Build](https://travis-ci.org/loyd/flow2schema.svg?branch=master)](https://travis-ci.org/loyd/flow2schema)
[![Windows Build](https://ci.appveyor.com/api/projects/status/github/loyd/flow2schema?branch=master&svg=true)](https://ci.appveyor.com/project/loyd/flow2schema)
[![Coverage Status](https://coveralls.io/repos/github/loyd/flow2schema/badge.svg?branch=master)](https://coveralls.io/r/loyd/flow2schema?branch=master)
2017-12-17 13:29:46 +03:00
## Example
```sh
$ cat example.js
```
```js
type A<T, K> = {
t: T,
k: K,
};
export type X = {
a: A<string, boolean>,
b: number,
};
```
```sh
$ flow2schema -t json-schema example.js
```
```json
{
"$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"]
}
}
}
```
2017-10-29 02:29:55 +03:00
## TODO
2017-11-16 17:34:27 +03:00
* Complete generics support.
2017-11-03 11:02:09 +03:00
* Errors and warnings.
2017-12-17 13:29:46 +03:00
* Complete commonjs support.
2017-11-03 11:02:09 +03:00
* Documentation.
2017-12-17 13:29:46 +03:00
* Stabilize API.
* Webpack plugin.
* Rollup plugin.