remoteoss / json-schema-form

https://json-schema-form.vercel.app
MIT License
70 stars 7 forks source link

select inputType and number type #50

Open gaou-piou opened 8 months ago

gaou-piou commented 8 months ago

i have this json schema

{
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "AccountType": {
            "title": "Select account type",
            "description": "",
            "x-jsf-presentation": {
                "inputType": "select"
            },
            "oneOf": [
                {
                    "title": "Normal User",
                    "const": 0
                },
                {
                    "title": "Business",
                    "const": 1
                },
                {
                    "title": "Services Provider",
                    "const": 2
                }
            ],
            "type": "number"
        }
    },
    "required": [],
    "x-jsf-order": [
        "AccountType"
    ]
}

and on validation cannot accepts that value must be number and not string as the output field is (it has schema type : string)

{
    "type": "select",
    "name": "AccountType",
    "label": "Select account type",
    "options": [
        {
            "label": "Normal User",
            "value": 0
        },
        {
            "label": "Business",
            "value": 1
        },
        {
            "label": "Services Provider",
            "value": 2
        }
    ],
    "required": false,
    "inputType": "select",
    "jsonType": "number",
    "computedAttributes": {},
    "description": "",
    "errorMessage": {},
    "schema": {
        "_deps": [],
        "_conditions": [],
        "_options": {
            "abortEarly": true,
            "recursive": true
        },
        "_exclusive": {},
        "_whitelist": {
            "list": {},
            "refs": {}
        },
        "_blacklist": {
            "list": {},
            "refs": {}
        },
        "tests": [],
        "transforms": [
            null,
            null
        ],
        "type": "string",
        "_type": "string",
        "_nullable": true
    },
    "scopedJsonSchema": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
            "AccountType": {
                "title": "Select account type",
                "description": "",
                "x-jsf-presentation": {
                    "inputType": "select"
                },
                "oneOf": [
                    {
                        "title": "Normal User",
                        "const": 0
                    },
                    {
                        "title": "Business",
                        "const": 1
                    },
                    {
                        "title": "Services Provider",
                        "const": 2
                    }
                ],
                "type": "number"
            }
        },
        "required": [],
        "x-jsf-order": [
            "AccountType"
        ]
    },
    "isVisible": true
}
brennj commented 8 months ago

A happy coincidence! We are running into this issue internally. https://github.com/remoteoss/json-schema-form/pull/49 should solve this.