Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Updated Examples Section #62

Merged
merged 20 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getDocsPath = [
const getStartedPath = [
'/learn/json-schema-examples',
'/learn/file-system',
'/learn/miscellaneous-examples',
'/learn/generic-examples',
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved
'/learn/getting-started-step-by-step'
]
const getReferencePath = [
Expand Down Expand Up @@ -198,7 +198,7 @@ export const DocsNav = () => {
>
<DocLink uri='/learn/getting-started-step-by-step' label='Creating your first schema' />
<SegmentSubtitle label='Examples' />
<DocLink uri='/learn/miscellaneous-examples' label='Miscellaneous examples' />
<DocLink uri='/learn/generic-examples' label='Generic examples' />
<DocLink uri='/learn/file-system' label='Modelling a file system' />
<DocLink uri='/learn/json-schema-examples' label='Other examples' />
</div>
Expand Down
4 changes: 4 additions & 0 deletions pages/learn/file-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ section: docs
title: Modeling a file system with JSON Schema
---

In this step-by-step guide you will learn how to design a JSON Schema that mirrors the structure of an `/etc/fstab` file.

This guide is divided into the following sections:

* [Introduction](#introduction)
* [Creating the `fstab` schema](#fstab-schema)
* [Starting the `entry` schema](#entry-schema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ section: docs
title: Miscellaneous Examples
---

In this page, you will find examples illustrating different uses cases to help you get the most out of your JSON Schemas, including:
In this page, you will find generic examples illustrating different uses cases to help you get the most out of your JSON Schemas. Each example comes with accompanying JSON data and explanation.
gregsdennis marked this conversation as resolved.
Show resolved Hide resolved

- [A typical minimum schema](#basic)
- [Describing geographical coordinates](#describing-geographical-coordinates)
- [Arrays of things](#arrays-of-things)
- [Enumerated values](#enumerated-values)
- [Regular expression pattern](#regular-expression-pattern)
Expand Down Expand Up @@ -66,49 +65,6 @@ This example provides a typical minimum you are likely to see in JSON Schema. It
In the data example, we provide values for the `firstName`, `lastName`, and `age` properties. The values match the defined schema, where `firstName` is a string, `lastName` is a string, and `age` is an integer greater than or equal to zero.


## Describing geographical coordinates

In this schema, we define an object representing geographical coordinates. This example also introduces the following keywords:

* [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword
* [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword
* [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword

```json
{
"$id": "https://example.com/geographical-location.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Longitude and Latitude Values",
"description": "A geographical coordinate.",
"required": [ "latitude", "longitude" ],
"type": "object",
"properties": {
"latitude": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"longitude": {
"type": "number",
"minimum": -180,
"maximum": 180
}
}
}
```

**Data**

```json
{
"latitude": 48.858093,
"longitude": 2.294694
}
```

The provided data contains the latitude and longitude values, both falling within the specified minimum and maximum ranges.


## Arrays of things

Arrays are fundamental structures in JSON -- here we demonstrate a couple of ways they can be described:
Expand Down