Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PassFort/json-schema-to-flow-type
https://github.com/PassFort/json-schema-to-flow-type
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/PassFort/json-schema-to-flow-type
- Owner: PassFort
- Created: 2016-10-17T01:49:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T13:16:03.000Z (over 1 year ago)
- Last Synced: 2024-05-20T08:32:43.659Z (8 months ago)
- Language: JavaScript
- Size: 571 KB
- Stars: 69
- Watchers: 27
- Forks: 17
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-flow - json-schema-to-flow-type - Convert JSON Schema to flow type definitions. (Tools)
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.