Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amis2schema

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amis2schema

根据 [amis](https://github.com/baidu/amis) 表单部分的 json,产出表格数据对应的 json schema。

  • 1.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

amis2schema

根据 amis 表单部分的 json,产出表格数据对应的 json schema。

例如:

{
    "title": "",
    "type": "form",
    "controls": [
        {
            "name": "a",
            "required": true,
            "validations": {},
            "type": "combo",
            "controls": [
                {
                    "name": "item",
                    "required": true,
                    "validations": {},
                    "type": "array",
                    "multiLine": true,
                    "items": {
                        "name": "",
                        "required": false,
                        "label": "",
                        "validations": {},
                        "type": "combo",
                        "controls": [
                            {
                                "name": "key",
                                "required": true,
                                "label": "",
                                "validations": {
                                    "minLength": 1,
                                    "maxLength": 76
                                },
                                "type": "text"
                            }
                        ],
                        "multiLine": true
                    }
                },
                {
                    "name": "content_method",
                    "required": false,
                    "validations": {},
                    "type": "select",
                    "options": [
                        "full",
                        "inc",
                        "dec"
                    ]
                }
            ],
            "multiLine": true
        }
    ]
}

得到

{
    "title": "",
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "a": {
            "type": "object",
            "properties": {
                "item": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "key": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "key"
                        ]
                    }
                },
                "content_method": {
                    "type": "string"
                }
            },
            "required": [
                "item"
            ]
        }
    },
    "required": [
        "a"
    ]
}

使用方式

const {amis2JsonSchema} = require('../dist/index');

const amis = {
    type: 'form' // 必须是一个 form
    // ...
};

const res = amis2JsonSchema(amis);

FAQs

Package last updated on 08 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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