Draft a data model

Steps to create your new data model in json schema

Supposedly you know how many fields you want your data model to have and what data types they would be.

1.- Copy this text

click on the plus
// Instructions for creating your schema
// 1.- respect the HEADER
// 2.- there are 8 types of examples field1XXX to field9XXX
// HEADER ***Do not change any of these till next warning***
$schema =   http://json-schema.org/schema
$schemaVersion = 0.0.1
$id = https://smart-data-models.github.io/XXXSubjectXXX/XXXDataModelXXX/schema.json
title = Smart Data models -XXXdataModelXXX schema"
modelTags = ""
description = description of a generic entity. You have to change this.
type = object
required[] = id, type
allOf[0]
  $ref=https://smart-data-models.github.io/data-models/common-schema.json#/definitions/GSMA-Commons
allOf[1]
  $ref=https://smart-data-models.github.io/data-models/common-schema.json#/definitions/Location-Commons
// HEADER  ***this is the end of the header ***
// you can start configuring this 
allOf[2]
  properties

// Create a numeric attribute
    field1XXX
      type = number
      minimum number = 0
      maximum number = 1
      description = Property. Model:'https://schema.org/Number'. Example of definition of a numerical attribute

// Create a simple string attribute
    field2XXX
      type = string
      description = Property. Model:'https://schema.org/Text'. Example of definition of a numerical attribute

// Create a date time attribute
    field3XXX 
      type = string
      format = date-time
      description = Property. Model:'https://schema.org/Text'. Example of definition of a date-time attribute 

// Create a relationship
    relationship1XX
      anyOf[0]
        type = string
        minLength number = 1
        maxLength number = 256
        pattern = ^[\w\-\.\{\}\$\+\*\[\]`|~^@!,:\\]+$
        description = Property. Identifier format of any NGSI entity
      anyOf[1]
         type = string
         format = uri
         description = Property. Identifier format of any NGSI entity
       description = Relationship. Reference to the other entity 

//Create an enumeration of strings
    field4XXX
      type = string
      enum[] s = val1, val2, val3
      description = Property. Model:'https://schema.org/Text. Example of definition of a enumeration of strings

//Create an enumeration of numbers
    field5XXX
      type = string
      enum[] number = 1, 2, 3
      description = Property. Model:'https://schema.org/Text. Example of definition of a enumeration of numbers

//Create an enumeration of an object
    field6XXX
      type = object
      description = Property. Model:'https://schema.org/Text. Example of definition of a enumeration of objects
      properties
        subproperty1XXX
          type = string
        subproperty2XXX
          type = number

//Create an array of strings
    field7XXX
      type = array
      description = Property. Model:'https://schema.org/Text. Example of definition of a arrayof strings
      items
        type = string
        minitems number = 3

//Create an array of numbers
    field8XXX
      type = array
      description = Property. Model:'https://schema.org/Text. Example of definition of a array of numbers
      items
        type = number
        minitems number = 1

// Create a simple boolean attribute 
    field9XXX 
      type = boolean
      description = Property. Model:'https://schema.org/Boolean'. Example of definition of a boolean attribute
 required[] string = id, type
 derivedFrom = ""
 license = ""

2.- Open in a new window this web.
3.- Paste the text in the left form and in the right you’ll have the json schema version.
4.- Modify according to your needs (copy and rename attributes). XXX string helps you to see what should be changed.
5.- You’ll have the code for your json schema on the right text box.
6.- You can validate in this link (paste in the left text box) and you will see the result below. On the right you should paste the example in keyvalues format. (leave emtpy) Better if you use chrome browser.

Comments are closed.