Skip to content

mycrobe/swaggerflowtypes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Turn a swagger API's models into types for the flow typechecker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%