Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit d69fb9d

Browse files
authored
Merge pull request #85 from vossad01/master
Convert other html pages to Markdown
2 parents 34e6621 + fdbad86 commit d69fb9d

10 files changed

+631
-710
lines changed

_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ collections:
2929
docs:
3030
output: true
3131
permalink: "/:title:output_ext"
32+
33+
gems:
34+
- jekyll-relative-links

documentation.html

Lines changed: 0 additions & 70 deletions
This file was deleted.

documentation.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: page
3+
---
4+
5+
Specification
6+
-------------
7+
8+
The latest Internet-Drafts at the IETF are the draft-wright-json-schema\*-01 documents, which correspond to the draft-06 meta-schemas. These were published on 2017-04-15. (Due to a change in authorship the I-D numbering was reset with the previous draft). The specification is split into three parts, Core, Validation, and Hyper-Schema:
9+
10+
|--------------------------------------------------------------|-------------------------------------------------|
11+
| [JSON Schema Core](latest/json-schema-core.html) | defines the basic foundation of JSON Schema |
12+
| [JSON Schema Validation](latest/json-schema-validation.html) | defines the validation keywords of JSON Schema |
13+
| [JSON Hyper-Schema](latest/json-schema-hypermedia.html) | defines the hyper-media keywords of JSON Schema |
14+
15+
They are also available on the IETF main site: [core (draft-wright-json-schema-01)](http://tools.ietf.org/html/draft-wright-json-schema-01), [validation (draft-wright-json-schema-validation-01)](http://tools.ietf.org/html/draft-wright-json-schema-validation-01) and [hyper-schema (draft-wright-json-schema-hyperschema-01)](http://tools.ietf.org/html/draft-wright-json-schema-hyperschema-01).
16+
17+
For previous versions of the specification, please see the [Specification Links](https://github.com/json-schema-org/json-schema-spec/wiki/Specification-Links) page on our github wiki.
18+
19+
Meta-schemas
20+
------------
21+
22+
The meta-schemas are the schemas which define the JSON Schema and Hyper-Schema formats.
23+
24+
The latest meta-schema is draft-06.
25+
26+
|--------------------------------------------------------------|------------------------------------------------------------|
27+
| [Core/Validation Meta-Schema](http://json-schema.org/schema) | Used for schemas written for pure validation. |
28+
| [Hyper Meta-Schema](http://json-schema.org/hyper-schema) | Used for schemas written for validation and hyper-linking. |
29+
30+
Standard schemas
31+
----------------
32+
33+
These sample schemas describe simple data structures which can be expressed as JSON:
34+
35+
|-----------------------------------------------------|---------------------------------------------------------------------------------|
36+
| [Geographic Coordinate](http://json-schema.org/geo) | a location as longitude and latitude |
37+
| [Card](http://json-schema.org/card) | a microformat-style representation of a person, company, organization, or place |
38+
| [Calendar](http://json-schema.org/calendar) | a microformat-style representation of an event |
39+
| [Address](http://json-schema.org/address) | a microformat-style representation of a street address |
40+
41+

example1.html renamed to example1.md

Lines changed: 69 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,65 @@
22
layout: page
33
---
44

5-
<h2>Example data</h2>
6-
<div class="block">
7-
<p>Let's pretend we're interacting with a JSON based product catalog. This catalog has a product which has an <em>id</em>, a <em>name</em>, a <em>price</em>, and an optional set of <em>tags</em>.</p>
5+
Example data
6+
------------
87

9-
<h3>Example JSON data for a product API</h3>
10-
<p>An example product in this API is:</p>
8+
Let's pretend we're interacting with a JSON based product catalog. This catalog has a product which has an *id*, a *name*, a *price*, and an optional set of *tags*.
119

12-
<pre><code class="language-json">
10+
### Example JSON data for a product API
11+
12+
An example product in this API is:
13+
14+
```json
1315
{
1416
"id": 1,
1517
"name": "A green door",
1618
"price": 12.50,
1719
"tags": ["home", "green"]
1820
}
19-
</code></pre>
21+
```
2022

21-
<p>While generally straightforward, that example leaves some open questions. For example, one may ask:</p>
23+
While generally straightforward, that example leaves some open questions. For example, one may ask:
2224

23-
<ul>
24-
<li>What is id?</li>
25-
<li>Is name required?</li>
26-
<li>Can price be 0?</li>
27-
<li>Are all tags strings?</li>
28-
</ul>
25+
- What is id?
26+
- Is name required?
27+
- Can price be 0?
28+
- Are all tags strings?
2929

30-
<p>When you're talking about a data format, you want to have metadata about what fields mean, and what valid inputs for those fields are. JSON schema is a specification for standardizing how to answer those questions for JSON data.</p>
31-
</div>
30+
When you're talking about a data format, you want to have metadata about what fields mean, and what valid inputs for those fields are. JSON schema is a specification for standardizing how to answer those questions for JSON data.
3231

33-
<h2>Starting the schema</h2>
34-
<div class="block">
35-
<p>To start a schema definition, let's begin with a basic JSON schema:</p>
32+
Starting the schema
33+
-------------------
3634

37-
<pre><code class="language-json">
35+
To start a schema definition, let's begin with a basic JSON schema:
36+
37+
```json
3838
{
3939
"$schema": "http://json-schema.org/draft-04/schema#",
4040
"title": "Product",
4141
"description": "A product from Acme's catalog",
4242
"type": "object"
4343
}
44-
</code></pre>
44+
```
45+
46+
The above schema has four properties called *keywords*. The *title* and *description* keywords are descriptive only, in that they do not add constraints to the data being validated. The intent of the schema is stated with these two keywords (that is, this schema describes a product).
4547

46-
<p>The above schema has four properties called <em>keywords</em>.
48+
The *type* keyword defines the first constraint on our JSON data: it has to be a JSON Object.
4749

48-
The <em>title</em> and <em>description</em> keywords are descriptive only, in that they do not add
49-
constraints to the data being validated. The intent of the schema is stated with these two keywords
50-
(that is, this schema describes a product).</p>
50+
Finally, the *$schema* keyword states that this schema is written according to the draft v4 specification.
5151

52-
<p>The <em>type</em> keyword defines the first constraint on our JSON data: it has to be a JSON
53-
Object.</p>
52+
Defining the properties
53+
-----------------------
5454

55-
<p>Finally, the <em>$schema</em> keyword states that this schema is written according to the draft
56-
v4 specification.</p>
57-
</div>
55+
Next let's answer our previous questions about this API, starting with id.
5856

59-
<h2>Defining the properties</h2>
60-
<div class="block">
61-
<p>Next let's answer our previous questions about this API, starting with id.</p>
57+
### What is id?
6258

63-
<h3>What is id?</h3>
64-
<p><em>id</em> is a numeric value that uniquely identifies a product. Since this is the canonical identifier for a product, it doesn't make sense to have a product without one, so it is required.</p>
59+
*id* is a numeric value that uniquely identifies a product. Since this is the canonical identifier for a product, it doesn't make sense to have a product without one, so it is required.
6560

66-
<p>In JSON Schema terms, we can update our schema to:</p>
67-
<pre><code class="language-json">
61+
In JSON Schema terms, we can update our schema to:
62+
63+
```json
6864
{
6965
"$schema": "http://json-schema.org/draft-04/schema#",
7066
"title": "Product",
@@ -78,13 +74,13 @@ <h3>What is id?</h3>
7874
},
7975
"required": ["id"]
8076
}
81-
</code></pre>
77+
```
78+
79+
### Is name required?
8280

83-
<h3>Is name required?</h3>
84-
<p><em>name</em> is a string value that describes a product. Since there isn't
85-
much to a product without a name, it also is required. Adding this gives us the schema:</p>
81+
*name* is a string value that describes a product. Since there isn't much to a product without a name, it also is required. Adding this gives us the schema:
8682

87-
<pre><code class="language-json">
83+
```json
8884
{
8985
"$schema": "http://json-schema.org/draft-04/schema#",
9086
"title": "Product",
@@ -102,12 +98,13 @@ <h3>Is name required?</h3>
10298
},
10399
"required": ["id", "name"]
104100
}
105-
</code></pre>
101+
```
102+
103+
### Can price be 0?
106104

107-
<h3>Can price be 0?</h3>
108-
<p>According to Acme's docs, there are no free products. In JSON schema a number can have a minimum. By default this minimum is inclusive, so we need to specify <em>exclusiveMinimum</em>. Therefore we can update our schema with <em>price</em>:</p>
105+
According to Acme's docs, there are no free products. In JSON schema a number can have a minimum. By default this minimum is inclusive, so we need to specify *exclusiveMinimum*. Therefore we can update our schema with *price*:
109106

110-
<pre><code class="language-json">
107+
```json
111108
{
112109
"$schema": "http://json-schema.org/draft-04/schema#",
113110
"title": "Product",
@@ -130,25 +127,20 @@ <h3>Can price be 0?</h3>
130127
},
131128
"required": ["id", "name", "price"]
132129
}
133-
</code></pre>
130+
```
134131

135-
<h3>Are all tags strings?</h3>
136-
<p>Finally, we come to the <em>tags</em> property. Unlike the previous
137-
properties, tags have many values, and is represented as a JSON array. According
138-
to Acme's docs, all tags must be strings, but you aren't required to specify
139-
tags. We simply leave <em>tags</em> out of the list of required properties.</p>
132+
### Are all tags strings?
140133

141-
<p>However, Acme's docs add two constraints:</p>
134+
Finally, we come to the *tags* property. Unlike the previous properties, tags have many values, and is represented as a JSON array. According to Acme's docs, all tags must be strings, but you aren't required to specify tags. We simply leave *tags* out of the list of required properties.
142135

143-
<ul>
144-
<li>there must be at least one tag,</li>
145-
<li>all tags must be unique.</li>
146-
</ul>
136+
However, Acme's docs add two constraints:
147137

148-
<p>The first constraint can be added with <em>minItems</em>, and the second one by
149-
specifying <em>uniqueItems</em> as being true:</p>
138+
- there must be at least one tag,
139+
- all tags must be unique.
150140

151-
<pre><code class="language-json">
141+
The first constraint can be added with *minItems*, and the second one by specifying *uniqueItems* as being true:
142+
143+
```json
152144
{
153145
"$schema": "http://json-schema.org/draft-04/schema#",
154146
"title": "Product",
@@ -179,17 +171,20 @@ <h3>Are all tags strings?</h3>
179171
},
180172
"required": ["id", "name", "price"]
181173
}
182-
</code></pre>
183-
</div>
174+
```
175+
176+
Summary
177+
-------
178+
179+
The above example is by no means definitive of all the types of data JSON schema can define. For more definitive information see the [full standard draft](#definitions).
184180

185-
<h2>Summary</h2>
186-
<div class="block">
187-
<p>The above example is by no means definitive of all the types of data JSON schema can define. For more definitive information see the <a href="#definitions">full standard draft</a>.</p>
188-
<p>As a final example, here's a spec for an array of products, with the products having 2 new properties. The first is a <em>dimensions</em> property for the size of the product, and the second is a <em>warehouseLocation</em> field for where the warehouse that stores them is geographically located.</p>
189-
<p>And also, since JSON Schema defines a reference schema for a geographic location, instead of coming up with our own, we'll reference the <a href="http://json-schema.org/geo">canonical one</a>.</p>
181+
As a final example, here's a spec for an array of products, with the products having 2 new properties. The first is a *dimensions* property for the size of the product, and the second is a *warehouseLocation* field for where the warehouse that stores them is geographically located.
190182

191-
<h3>Set of products:</h3>
192-
<pre><code class="language-json">
183+
And also, since JSON Schema defines a reference schema for a geographic location, instead of coming up with our own, we'll reference the [canonical one](http://json-schema.org/geo).
184+
185+
### Set of products:
186+
187+
```json
193188
[
194189
{
195190
"id": 2,
@@ -221,10 +216,11 @@ <h3>Set of products:</h3>
221216
}
222217
}
223218
]
224-
</code></pre>
219+
```
220+
221+
### Set of products schema:
225222

226-
<h3>Set of products schema:</h3>
227-
<pre><code class="language-json">
223+
```json
228224
{
229225
"$schema": "http://json-schema.org/draft-04/schema#",
230226
"title": "Product set",
@@ -270,6 +266,5 @@ <h3>Set of products schema:</h3>
270266
"required": ["id", "name", "price"]
271267
}
272268
}
273-
</code></pre>
274-
</div>
269+
```
275270

0 commit comments

Comments
 (0)