1.0.5 • Published 5 years ago

vue-props-schema v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

这是什么

将vue的prop-types转换为Json schema

如何使用

const props2Schema = require("./props2schema");


let input = `{
	a: {
		c: {
			type: [Number, String],
			required: true,
			default: 0
		},
		d: String,
		e: {
			type: Number,
			required: true
		}
	},
	b: {
		type: String,
		required: true
	},
	f: {
		type: String,
		required: true,
		default: '1'
	}
}`;


let schema =  props2Schema(input); 

/***
{
	"type": "object",
	"properties": {
		"a": {
			"type": "object",
			"properties": {
				"c": {
					"type": ["number", "string"],
					"default": 0
				},
				"d": {
					"type": "string"
				},
				"e": {
					"type": "number"
				}
			},
			"required": ["c", "e"]
		},
		"b": {
			"type": "string"
		},
		"f": {
			"type": "string",
			"default": "1"
		}
	},
	"required": ["b", "f"]
}
***/
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago