VideosIntroducing the JSON Schema Design Mode

Overview

Duration: 06:40

This video provides an introduction to Oxygen's JSON Schema Design mode, demonstrating some of this mode's useful features and possibilities.

Transcript

00:00:07The purpose of this video is to provide a brief  overview of Oxygen's Design mode for JSON schema  
00:00:13documents. The Design mode offers a diagram view  of a Schema document by rendering all the Schema  
00:00:16components and it provides various actions  and options for designing and editing Schema  
00:00:16components directly within the diagram. For this demonstration, let's suppose that I  
00:00:18have a JSON-based product catalog  and I want to have a product ID,  
00:00:22name, price, and some optional tags.
00:00:30The first thing I'll do is create a JSON  
00:00:33Schema from scratch ... notice that there's a JSON  Schema template in the file creation wizard ...  
00:00:47and the new created file is opened  directly in the Design mode  
00:00:53So, I'll start designing my schema and  the first property that I want to define  
00:00:57is the "productId". and I want to set the  
00:01:02identifier type to be an integer. The description of the property is presented  
00:01:07on the bottom of the property. To change it,  I can double-click on it, or I can right-click  
00:01:12and use the "Edit Annotations" action. All of the annotations of a JSON Schema  
00:01:19component can be edited in this dialog box.  I'll change the value of "description".  
00:01:27I want my "productId" property to be set as  required so I'll right-click on the schema root  
00:01:33and use the Edit Properties action and I'll set  
00:01:36"productId" as the value of the  schema's "required" property.  
00:01:43Next, I'll define the "productName" property ...  
00:01:55and I want to set its type to "string", but  it's not displayed so I need to add it.  
00:02:02For this, I could right-click and use the "Edit  Properties" action ... or I can go to options  
00:02:13and I'll find the "type" property  and uncheck the option called  
00:02:17"Only if specified" so that it's displayed in  the diagram even if it does not have a value. 
00:02:25Now it's displayed so I'll  set the value to "string". 
00:02:31Now I'll use the "Edit Annotations" action  to set the value of its description. 
00:02:42and I want to also set it  as a required property.  
00:02:53Next I'll define the "price" property  
00:03:01and I want to set its type to "number"  ... but I'll intentionally mispell it.  
00:03:09Notice that the validation engine automatically  reports such issues ... I can hover over the  
00:03:16error to see a tooltip with more details, and  the error is also reported in the verticle  
00:03:21range ruler on the right side and also in the  results pane at the bottom of the editor. 
00:03:27so, I'll fix the typo.
00:03:32then I'll use the exclusiveMinimum  
00:03:34property to specify that the value of  price must be something other than zero. 
00:03:41I also want it to be a required  property, so I'll add it. 
00:03:58Next, I'll add the "tags" property.  
00:04:03I want to have multiple tags for each  product, so I'll set the type to array. 
00:04:10Then I'll add an items definition and I want  the type for each tag to be a string.  
00:04:26and I'll set the uniqueItems value to  true and the minItems value to 1.  
00:04:34So, the JSON Schema is created. You can  switch to text mode to see how the source  
00:04:40JSON Schema looks like, and  the modes are synchronized,  
00:04:46so any modification in one mode  is presented in the other. 
00:04:53You can also visualize and edit  complex JSON Schemas in Design mode. 
00:04:59I have a pretty complex schema here and  I'll expand some of the definitions. 
00:05:06Note that if the schema contains references  to definitions from another file,  
00:05:10you can click the "go to definition"  icon to open the corresponding file. 
00:05:16As a side note or tip, you  can use the keyboard instead  
00:05:19of the mouse to navigate through the diagram.
00:05:25I can even print or save a diagram as an image.
00:05:35This is what the exported image  looks like in a photo app.  
00:05:42The schema diagrams can also be included  in generated schema documentation.  
00:05:48I'll use the "Generate Schema  Documentation" button from the toolbar ...  
00:05:53and in this dialog box, I'll expand the  "Included component details" section,  
00:05:59and I want to make sure the  "diagram" option is selected,  
00:06:04I'll also enable this option to "Split the output  into multiple files", and I'll click generate. 
00:06:14Now you can see that there is also a diagram  for each component in the documentation.  
00:06:21This helps to more easily visualize  and understand the schema. 
00:06:28That concludes the demonstration  of the JSON Schema design mode.  
00:06:32As always, thank you for watching.

Use Oxygen Feedback to ask us anything about this video.