You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there the possibility to have something like inherited types? #10
Is it possible to somehow define inherited types? For example if I have a car and a plane, they have some properties in common (classical inheritance).
Thanks for providing this example, it's exactly what I'm looking for.
Currently my knowledge about handling JSON in this way is very low, so I won't be able to contribute short term. I'll check out the source and see if I can do anything. :)
Activity
lovasoa commentedon Oct 2, 2025
Hi ! Not possible yet, but PR welcome !
sandrooco commentedon Oct 2, 2025
@lovasoa my question was rather if this is even technically implementable - is this possible with JSON schemas?
lovasoa commentedon Oct 2, 2025
You can do:
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "definitions": { "Vehicle": { "type": "object", "properties": { "id": { "type": "string" }, "manufacturer": { "type": "string" } }, "required": ["id", "manufacturer"] }, "Car": { "allOf": [ { "$ref": "#/definitions/Vehicle" }, { "type": "object", "properties": { "doors": { "type": "integer", "minimum": 2 }, "fuel": { "enum": ["petrol", "diesel", "electric", "hybrid"] } }, "required": ["doors", "fuel"] } ] }, "Plane": { "allOf": [ { "$ref": "#/definitions/Vehicle" }, { "type": "object", "properties": { "engines": { "type": "integer", "minimum": 1 }, "wingspan": { "type": "number" } }, "required": ["engines", "wingspan"] } ] } }, "oneOf": [ { "$ref": "#/definitions/Car" }, { "$ref": "#/definitions/Plane" } ] }lovasoa commentedon Oct 2, 2025
adding support for refs would be cool
sandrooco commentedon Oct 2, 2025
Thanks for providing this example, it's exactly what I'm looking for.
Currently my knowledge about handling JSON in this way is very low, so I won't be able to contribute short term. I'll check out the source and see if I can do anything. :)