<commit_before># swagger-to-flowtype

`swagger-to-flowtype` is a tool for generating type definitions of [Flow](https://flow.org/) from swagger file.

## Getting started

#### Install package

1. `npm i -g swagger-to-flowtype`

#### Generating flow type definitions

2. `$swagger-to-flowtype <YOUR SWAGGER FILE>`

This command generates a file named **flowtype.js** includes type definitions as default.  
You can also specify output path with `-d option`.

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

## Example

swagger file like following 

```yaml
...

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"<commit_msg>Noted supporting Maybe type to README.md.<commit_after># swagger-to-flowtype

`swagger-to-flowtype` is a tool for generating type definitions of [Flow](https://flow.org/) from swagger file.

## Getting started

#### Install package

`npm i -g swagger-to-flowtype`

#### Generating flow type definitions

`$swagger-to-flowtype <YOUR SWAGGER FILE>`

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> -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.

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

will be

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


## Example

swagger file like following 

```yaml
...

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"
{'fraction_non_alphanumeric': 0.1309623430962343, 'fraction_numerical': 0.005857740585774059, 'mean_word_length': 2.7069767441860466, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2290528', 'n_tokens_mistral': 799, 'n_tokens_neox': 767, 'n_words': 248}