Find out in this video how you can create JSON schema descriptions by yourself.
Ticket.json
{
    "$schema": "./ticket-schema-v1.json",
    "id": "ZUI-23424",
    "beschreibung": "Server fährt nicht hoch!",
    "art": "bug",
    "datum": "2020-03-20",
    "prio": 3,
    "tags": [ "Release", "Produktion" ],
    "kontakt": {
        "name": "Thomas",
        "email": "bayer@predic8.com"
    },
    "self": "http://api.predic8.de/tickets/5974B554-976C-43FD-B370-79AACC335328"

}

Ticket-schema-v1.json

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "required": ["id","art"],
    "properties": {
        "$schema": {},
        "id": {
           "$ref": "#/definitions/Id"
        },
        "beschreibung": {
            "type": "string",
            "minLength": 10,
            "maxLength": 100
        },
        "art": {
            "type": "string",
            "enum": ["bug","verbesserung"]
        },
        "datum": {
            "type": "string",
            "format": "date"
        },
        "prio": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "examples": [1,3,8,10]
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "kontakt": {
            "$ref": "#/definitions/Kontakt"
        },
        "self": {
            "type": "string",
            "format": "uri"
        }
    },
    "additionalProperties": false,
    "definitions": {
        "Id": {
            "type": "string",
            "pattern": "[A-Z]{3}-\\d+",
            "description": "Id mit dem Aufbau XXX-9999",
            "examples": ["GRT-3456","ZUI-23424"]
        },
        "Kontakt": {
            "type": "object",
            "required": ["name"],
            "properties": {
                "email": {
                    "type": "string",
                    "format": "email"
                }
            }
        }
    }
}

Reference:

https://www.predic8.de/json-schema-tutorial-erstellen.htm

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *