nijikokun / generate-schema

🧞 Convert JSON Objects to MySQL, JSON Schema, Mongoose, Google BigQuery, Swagger, and more.
MIT License
1.03k stars 135 forks source link

Array of array json schema support added #76

Closed kamathchethan closed 7 months ago

kamathchethan commented 1 year ago

Fix for Issue: https://github.com/nijikokun/generate-schema/issues/55 With current implementation we array of array is not handled added support for the same.

Input

{
    "filters": [
        [
            {
                "operator": "EQ",
                "value": "Ice Cold"
            }
        ]
    ]
}

Output before fix

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "filters": {
            "type": "array",
            "items": {
                "type": "array"
            }
        }
    },
    "required": [
        "filters"
    ]
}

Output after fix

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "filters": {
            "type": "array",
            "items": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "operator": {
                            "type": "string"
                        },
                        "value": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    },
    "required": [
        "filters"
    ]
}