Marwes / schemafy

Crate for generating rust types from a json schema
MIT License
242 stars 51 forks source link

null generates Value #70

Open lizelive opened 1 year ago

lizelive commented 1 year ago

for the schema

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Hashable Value",
    "id": "https://schema.qhpea.org/hashable-value.json",
    "oneOf": [
        {
            "title": "Null",
            "type": "null"
        },
        {
            "title": "Boolean",
            "type": "boolean"
        },
        {
            "title": "Integer",
            "type": "integer"
        },
        {
            "title": "String",
            "type": "string"
        },
        {
            "title": "Array",
            "type": "array",
            "items": {
                "$ref": "#"
            }
        },
        {
            "title": "Object",
            "type": "object",
            "additionalProperties": {
                "$ref": "#"
            }
        }
    ]
}

it generates

pub type HashableValueNull = Value;

pub enum HashableValue {
    Null(HashableValueNull),
    Boolean(HashableValueBoolean),
    Integer(HashableValueInteger),
    String(HashableValueString),
    Array(HashableValueArray),
    Object(HashableValueObject),
}

this is silly