From 0ad270210b54ca7113c8ed92eb73f83b68189ce8 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sun, 17 Dec 2017 13:29:46 +0300 Subject: [PATCH] Add a small example --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 290ea00..3b350ac 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,56 @@ [![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) +## Example + +```sh +$ cat example.js +``` +```js +type A = { + t: T, + k: K, +}; + +export type X = { + a: A, + 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"] + } + } +} +``` + ## TODO * Complete generics support. * Errors and warnings. -* Support "declare". -* Support commonjs modules. +* Complete commonjs support. * Documentation. +* Stabilize API. +* Webpack plugin. +* Rollup plugin.