# json-schema-to-flow-type

> [![Build Status](https://img.shields.io/travis/morlay/json-schema-to-flow-type.svg?style=flat-square)](https://travis-ci.org/morlay/json-schema-to-flow-type) [![NPM](https://img.shields.io/npm/v/json-schema-to-flow-type.svg?style=flat-square)](https://npm

Latest version **1.0.0** (published 2018-10-19) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install json-schema-to-flow-type
pnpm add json-schema-to-flow-type
yarn add json-schema-to-flow-type
bun add json-schema-to-flow-type
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-10-19 |
| First published | 2016-10-17 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Morlay |
| Maintainers | dannynelson, goodeggs, morlay_null, passfort-dev |

## Links

- npm: https://www.npmjs.com/package/json-schema-to-flow-type
- Repository: https://github.com/morlay/json-schema-to-flow-type
- Homepage: https://github.com/morlay/json-schema-to-flow-type#readme
- Issues: https://github.com/morlay/json-schema-to-flow-type/issues
- npm.io page: https://npm.io/package/json-schema-to-flow-type

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) 4.17.x
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.0.0
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.0.0-beta.44
- [eslint-plugin-flow](https://npm.io/package/eslint-plugin-flow.md) ^2.29.1

## Recent versions

- 1.0.0 (latest) — 2018-10-19
- 0.3.0 (prerelease) — 2018-04-12
- 0.4.0 — 2018-04-13
- 0.3.1 — 2018-04-12
- 0.2.7 — 2018-03-15
- 0.2.6 — 2017-04-10
- 0.2.5 — 2017-04-06
- 0.2.4 — 2017-01-09
- 0.2.3 — 2016-11-22
- 0.2.2 — 2016-11-21
- 0.2.1 — 2016-11-21
- 0.2.0 — 2016-11-18
- 0.1.3 — 2016-10-19
- 0.1.2 — 2016-10-19
- 0.1.1 — 2016-10-19
- … 3 more at https://npm.io/package/json-schema-to-flow-type/versions

## README

# Convert JSON Schema to Flow Type Definitions

[![Build Status](https://img.shields.io/travis/morlay/json-schema-to-flow-type.svg?style=flat-square)](https://travis-ci.org/morlay/json-schema-to-flow-type)
[![NPM](https://img.shields.io/npm/v/json-schema-to-flow-type.svg?style=flat-square)](https://npmjs.org/package/json-schema-to-flow-type)
[![Dependencies](https://img.shields.io/david/morlay/json-schema-to-flow-type.svg?style=flat-square)](https://david-dm.org/morlay/json-schema-to-flow-type)
[![License](https://img.shields.io/npm/l/json-schema-to-flow-type.svg?style=flat-square)](https://npmjs.org/package/json-schema-to-flow-type)



## APIs

```js
type Imports = {
  [key: string]: Schema
}
```

### `simplifySchema(schema, Schema, imports: ?Imports): Schema`

* `schema` should have `id` for type alias identifier
* outside `$ref` will be resolve the real schema instead of `$ref`;
* imports with `{ #: schema }` will have same rule as above;

### `convertSchema(schema: Schema): FlowSchema`

convert schema to a flow schema

### `toFlow(flowSchema): AstObject`

will export ast object `export ${upperCamelCase(flowSchema.id)} == ${toFlowType(flowType)}`

### `schemaToFlow(flowSchema): string`

convert definitions and schema root by `toFlow`

### `parseSchema(schema: Schema, imports: ?Imports): string`

pipe `simplifySchema | convertSchema | schemaToFlow`

## Changelog

### 0.4.0
* Support for string literal object type keys

### 0.3.0
* Support for [exact object types](https://flow.org/en/docs/types/objects/#toc-exact-object-types) when `additionalProperties: false` is present.

---
_Source: https://npm.io/package/json-schema-to-flow-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
