Skip to content

Is there the possibility to have something like inherited types? #10

Closed

Description

@sandrooco

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 building this, it's great!

Activity

  1. lovasoa commented on Oct 2, 2025

    @lovasoa
    Owner

    Hi ! Not possible yet, but PR welcome !

  2. sandrooco commented on Oct 2, 2025

    @sandrooco
    Author

    @lovasoa my question was rather if this is even technically implementable - is this possible with JSON schemas?

  3. lovasoa commented on Oct 2, 2025

    @lovasoa
    Owner

    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" }
      ]
    }
  4. lovasoa commented on Oct 2, 2025

    @lovasoa
    Owner

    adding support for refs would be cool

  5. sandrooco commented on Oct 2, 2025

    @sandrooco
    Author

    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. :)

  6. linked a pull request that will close this issueAdd full $ref support to the visual editor #47on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions