Socket
Socket
Sign inDemoInstall

json-schema-to-flow-type

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-to-flow-type - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

lib/FlowSchema.js

@@ -110,3 +110,3 @@ 'use strict';

if (_lodash2.default.isArray(schema.type)) {
return f.union(_lodash2.default.map(schema.type, type => convertSchema(_extends({}, schema, {
return f.union(_lodash2.default.map([].concat(schema.type || []), type => convertSchema(_extends({}, schema, {
type

@@ -132,3 +132,3 @@ }))));

switch (_lodash2.default.toLower(schema.type)) {
switch (_lodash2.default.toLower(String(schema.type))) {
case 'string':

@@ -135,0 +135,0 @@ return f.flowType('string');

@@ -35,3 +35,3 @@ 'use strict';

const processObjectSchema = (flowSchema, processor) => {
const fields = _lodash2.default.reduce(flowSchema.$properties, (nextFields, fieldFlowSchema, field) => _extends({}, nextFields, {
const fields = _lodash2.default.reduce(flowSchema.$properties || {}, (nextFields, fieldFlowSchema, field) => _extends({}, nextFields, {
[`${ field }${ _lodash2.default.includes(flowSchema.$required, field) ? '' : '?' }`]: processor(fieldFlowSchema)

@@ -38,0 +38,0 @@ }), {});

{
"name": "json-schema-to-flow-type",
"version": "0.1.0",
"version": "0.1.1",
"ava": {

@@ -17,4 +17,3 @@ "files": [

"build": "rm -rf lib && babel src --ignore __**__ -d lib",
"flow-typed": "flow-typed install",
"postinstall": "npm run flow-typed",
"postinstall": "flow-typed update",
"prepublish": "npm test && npm run build"

@@ -37,3 +36,8 @@ },

],
"license": "WTFPL"
}
"license": "WTFPL",
"repository": {
"url": "git@github.com:morlay/json-schema-to-flow-type.git",
"type": "git"
},
"author": "Morlay <morlay@qq.com>"
}

@@ -1,13 +0,10 @@

# Convert JSON Schema to Flow Type Definitions;
# 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)
[![npm][json-schema-to-flow-type-badge]][json-schema-to-flow-type]
[![dependences][json-schema-to-flow-type-deps-badge]][json-schema-to-flow-type-deps]
[json-schema-to-flow-type]: https://www.npmjs.com/package/@morlay/json-schema-to-flow-type
[json-schema-to-flow-type-badge]: https://img.shields.io/npm/v/@morlay/json-schema-to-flow-type.svg
[json-schema-to-flow-type-deps]: https://david-dm.org/morlay/dep-packages?path=packages/json-schema-to-flow-type
[json-schema-to-flow-type-deps-badge]: https://david-dm.org/morlay/dep-packages.svg?path=packages/json-schema-to-flow-type
## APIs

@@ -14,0 +11,0 @@

@@ -5,3 +5,6 @@ // @flow

import type { Schema } from './schema.js.flow';
import type {
Schema,
SimpleTypes,
} from './schema.js.flow';

@@ -147,6 +150,11 @@ type FlowType = 'Object' | 'Array' | 'string' | 'number' | 'boolean' | 'null' | 'any' | 'void';

if (_.isArray(schema.type)) {
return f.union(_.map(schema.type, (type) => convertSchema({
...schema,
type,
})));
return f.union(
_.map(
[].concat(schema.type || []),
(type: SimpleTypes) => convertSchema({
...schema,
type,
}),
)
);
}

@@ -177,3 +185,3 @@

switch (_.toLower(schema.type)) {
switch (_.toLower(String(schema.type))) {
case 'string':

@@ -180,0 +188,0 @@ return f.flowType('string');

@@ -42,3 +42,3 @@ // @flow

const fields = _.reduce(
flowSchema.$properties,
flowSchema.$properties || {},
(nextFields: Object, fieldFlowSchema: FlowSchema, field: string) => ({

@@ -45,0 +45,0 @@ ...nextFields,

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