Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-to-flowtype

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-to-flowtype

Command line tool for generating flow types from swagger

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114
decreased by-52.3%
Maintainers
1
Weekly downloads
 
Created
Source

swagger-to-flowtype

swagger-to-flowtype is a tool for generating type definitions of Flow from swagger file.

Getting started

Install package

npm i -g swagger-to-flowtype

Generating flow type definitions

$swagger-to-flowtype <YOUR SWAGGER FILE OR URL>

This command generates a file named flowtype.js includes type definitions as default.

Options

Specify an output path

You can also specify an output path with -d option.

$swagger-to-flowtype <YOUR SWAGGER FILE PATH OR URL> -d <OUTPUT FILE PATH>

Supporting Maybe type

If you pass a --check-required option, swagger-to-flowtype will check required field on your swagger file, then output flow definitions with Maybe type.

"NewPet": {
  "type": "object",
  "required": [
    "name"
  ],
  "properties": {
    "name": {
      "type": "string"
    },
    "tag": {
      "type": "string"
    }
  }
}

will be

export type NewPet = {
  name: string,
  tag?: string
}

Example

swagger file like following

...

definitions:
  Order:
    type: "object"
    properties:
      id:
        type: "integer"
        format: "int64"
      petId:
        type: "integer"
        format: "int64"
      quantity:
        type: "integer"
        format: "int32"
      shipDate:
        type: "string"
        format: "date-time"
      status:
        type: "string"
        description: "Order Status"
        enum:
        - "placed"
        - "approved"
        - "delivered"
      complete:
        type: "boolean"
        default: false
    xml:
      name: "Order"
  Category:
    type: "object"
    properties:
      id:
        type: "integer"
        format: "int64"
      name:
        type: "string"
    xml:
      name: "Category"
...

Output will be like below

// @flow
export type Order = {
  id: number,
  petId: number,
  quantity: number,
  shipDate: string,
  status: string,
  complete: boolean
};
export type Category = { id: number, name: string };

Requirements

Node 4+ is required

Tests

npm test

Keywords

FAQs

Package last updated on 15 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc