take the models from your swagger api and create class definitions for the facebook flow typechecker
usage:
just invoke swaggerflowtypes -o <output_dir> <the_url_to_your_api-docs_json>
$ > npm install -g swaggerflowtypes
$ > swaggerflowtypes -o types http://`boot2docker ip`/api-docs
wrote to types/User.js
wrote to types/Device.js
Currently because of this issue this outputs class definitions instead of type aliases
in order to import these types in your code, you have to require the file for the type as follows.
var User = require('./types/User');
Then you can refer to the type normally eg:
foo(user: User): void
$refs
this tool will reference and import where necessary types from $ref attributes, assuming that the required model will remain where the tool puts it relative the referencing model.
...
models: {
Subscription: {
id: "Subscription",
description: "",
properties: {
id: {
type: "number",
},
user: {
$ref: "User"
}
}
}
...
yields
/* @flow */
var User = require('./User');
class Subscription {id: number; user: User;}
module.exports = Subscription;
jshint
you might want to set in your .jshintrc in the root of your project:
"unused" : false, // true: Require all defined variables be used