From 4969ad043d2e1907066b5b06053abcb81cabbdad Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Thu, 31 Aug 2023 22:14:32 +0530 Subject: [PATCH 01/16] chore: remove redundant example Signed-off-by: Akanksha Kushwaha --- pages/learn/miscellaneous-examples.md | 44 --------------------------- 1 file changed, 44 deletions(-) diff --git a/pages/learn/miscellaneous-examples.md b/pages/learn/miscellaneous-examples.md index 28e07bb2f..63d3ce5e3 100644 --- a/pages/learn/miscellaneous-examples.md +++ b/pages/learn/miscellaneous-examples.md @@ -6,7 +6,6 @@ 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: - [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) @@ -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: From b103968fd891441afe54a3a255e74bf9e99d0701 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 14:47:41 +0530 Subject: [PATCH 02/16] update: add examples of use cases Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 683 +++++++++++++++++++++++++++- 1 file changed, 682 insertions(+), 1 deletion(-) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index 5e37a05fc..dc69ceeb4 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -4,6 +4,9 @@ title: JSON Schema examples --- ## Address + +A schema representing an address, with optional properties for different address components like `post-office-box`, `street-address`, `locality`, `region`, `postal-code`, and `country-name`. + ```json { "$id": "https://example.com/address.schema.json", @@ -41,7 +44,126 @@ title: JSON Schema examples } ``` +**Data** + +```json +{ + "post-office-box": "123", + "street-address": "456 Main St", + "locality": "Cityville", + "region": "State", + "postal-code": "12345", + "country-name": "Country" +} +``` + + +## Blog post + +A schema representing a blog post, including properties like `title`, `content`, `published-date`, `author-details`, and `tags`. + +```json +{ + "$id": "https://example.com/blog-post.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a blog post", + "type": "object", + "required": ["title", "content", "author"], + "properties": { + "title": { + "type": "string" + }, + "content": { + "type": "string" + }, + "publishedDate": { + "type": "string", + "format": "date-time" + }, + "author": { + "$ref": "https://example.com/user-profile.schema.json" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } +} +``` + +**Data** + +```json +{ + "title": "New Blog Post", + "content": "This is the content of the blog post...", + "publishedDate": "2023-08-25T15:00:00Z", + "author": { + "username": "authoruser", + "email": "author@example.com" + }, + "tags": ["Technology", "Programming"] +} +``` + + +## Book + +A schema representing a book, including various properties like `title`, `author`, `publication-date`, `genre`, `ISBN`, and `rating`. + +```json +{ + "$id": "https://example.com/book.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a book", + "type": "object", + "required": ["title", "author"], + "properties": { + "title": { + "type": "string" + }, + "author": { + "type": "string" + }, + "publicationDate": { + "type": "string", + "format": "date" + }, + "genre": { + "type": "string" + }, + "isbn": { + "type": "string" + }, + "rating": { + "type": "number", + "minimum": 0, + "maximum": 5 + } + } +} +``` + +**Data** + +```json +{ + "title": "Sample Book", + "author": "Jane Smith", + "publicationDate": "2023-07-15", + "genre": "Fiction", + "isbn": "978-1234567890", + "rating": 4.5 +} +``` + + ## Calendar + +A schema representing an event in a calendar, including properties like `start-date`, `end-date`, `summary`, `location`, and `recurrence` details. + ```json { "$id": "https://example.com/calendar.schema.json", @@ -92,7 +214,23 @@ title: JSON Schema examples } ``` +**Data** + +```json +{ + "dtstart": "2023-08-25T10:00:00Z", + "dtend": "2023-08-25T12:00:00Z", + "summary": "Conference Presentation", + "location": "Conference Center", + "rrule": "FREQ=DAILY;COUNT=5" +} +``` + + ## Card + +A schema representing a person, company, organization, or place, with properties such as `name`, `contact-information`, and `organizational-details`. + ```json { "$id": "https://example.com/card.schema.json", @@ -195,7 +333,83 @@ title: JSON Schema examples } ``` +**Data** + +```json +{ + "fn": "John Doe", + "givenName": "John", + "familyName": "Doe", + "email": { + "type": "work", + "value": "john.doe@example.com" + }, + "tel": { + "type": "home", + "value": "123-456-7890" + }, + "adr": { + "locality": "Cityville", + "region": "State", + "country-name": "Country" + } +} +``` + + +## Event registration + +A schema representing an event registration, including properties like `event-name`, `participant-details`, `registration-date`, `ticket-type`, and `ticket-price`. + +```json +{ + "$id": "https://example.com/event-registration.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of an event registration", + "type": "object", + "required": ["eventName", "participant", "registrationDate"], + "properties": { + "eventName": { + "type": "string" + }, + "participant": { + "$ref": "https://example.com/user-profile.schema.json" + }, + "registrationDate": { + "type": "string", + "format": "date-time" + }, + "ticketType": { + "type": "string" + }, + "ticketPrice": { + "type": "number", + "minimum": 0 + } + } +} +``` + +**Data** + +```json +{ + "eventName": "Tech Conference", + "participant": { + "username": "participantuser", + "email": "participant@example.com" + }, + "registrationDate": "2023-08-20T10:00:00Z", + "ticketType": "Standard", + "ticketPrice": 100 +} +``` + + ## Geographical location + +A schema representing geographical coordinates with `latitude` and `longitude` values within specified ranges. + ```json { "$id": "https://example.com/geographical-location.schema.json", @@ -217,4 +431,471 @@ title: JSON Schema examples } } } -``` \ No newline at end of file +``` + +**Data** + +```json +{ + "latitude": 48.858093, + "longitude": 2.294694 +} +``` + + +## Health record + +A schema representing a health record, including `patient-information`, `allergies`, `medical-conditions`, `medications`, and `emergency-contact`. + +```json +{ + "$id": "https://example.com/health-record.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a health record", + "type": "object", + "required": ["patientName", "dateOfBirth", "bloodType"], + "properties": { + "patientName": { + "type": "string" + }, + "dateOfBirth": { + "type": "string", + "format": "date" + }, + "bloodType": { + "type": "string" + }, + "allergies": { + "type": "array", + "items": { + "type": "string" + } + }, + "conditions": { + "type": "array", + "items": { + "type": "string" + } + }, + "medications": { + "type": "array", + "items": { + "type": "string" + } + }, + "emergencyContact": { + "$ref": "https://example.com/user-profile.schema.json" + } + } +} +``` + +**Data** + +```json +{ + "patientName": "Jane Doe", + "dateOfBirth": "1985-02-15", + "bloodType": "A+", + "allergies": ["Pollen", "Penicillin"], + "conditions": ["Hypertension", "Diabetes"], + "medications": ["Lisinopril", "Metformin"], + "emergencyContact": { + "username": "emergencyuser", + "email": "emergency@example.com" + } +} +``` + + +## Invoice + +A schema representing an invoice, including `invoice details`, `billing address`, `line items`, and `total amount`. + +```json +{ + "$id": "https://example.com/invoice.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of an invoice", + "type": "object", + "required": ["invoiceNumber", "billingAddress", "items", "totalAmount"], + "properties": { + "invoiceNumber": { + "type": "string" + }, + "billingAddress": { + "$ref": "https://example.com/address.schema.json" + }, + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "quantity": { + "type": "integer", + "minimum": 1 + }, + "unitPrice": { + "type": "number", + "minimum": 0 + } + } + } + }, + "totalAmount": { + "type": "number", + "minimum": 0 + } + } +} +``` + +**Data** + +```json +{ + "invoiceNumber": "INV123", + "billingAddress": { + "street-address": "789 Billing St", + "locality": "Cityville", + "region": "State", + "postal-code": "54321", + "country-name": "Country" + }, + "items": [ + { "description": "Product A", "quantity": 2, "unitPrice": 50 }, + { "description": "Product B", "quantity": 1, "unitPrice": 30 } + ], + "totalAmount": 130 +} +``` + + +## Job posting + +A schema representing a job posting, including properties like `job title`, `company name`, `location`, `job description`, `employment type`, `salary`, and `application deadline`. + +```json +{ + "$id": "https://example.com/job-posting.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a job posting", + "type": "object", + "required": ["title", "company", "location", "description"], + "properties": { + "title": { + "type": "string" + }, + "company": { + "type": "string" + }, + "location": { + "type": "string" + }, + "description": { + "type": "string" + }, + "employmentType": { + "type": "string" + }, + "salary": { + "type": "number", + "minimum": 0 + }, + "applicationDeadline": { + "type": "string", + "format": "date" + } + } +} +``` + +**Data** + +```json +{ + "title": "Software Engineer", + "company": "Tech Solutions Inc.", + "location": "Cityville", + "description": "Join our team as a software engineer...", + "employmentType": "Full-time", + "salary": 80000, + "applicationDeadline": "2023-09-15" +} +``` + + +## Movie + +A schema representing a movie, including properties such as `title`, `director`, `release date`, `genre`, `duration`, and `cast members`. + +```json +{ + "$id": "https://example.com/movie.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a movie", + "type": "object", + "required": ["title", "director", "releaseDate"], + "properties": { + "title": { + "type": "string" + }, + "director": { + "type": "string" + }, + "releaseDate": { + "type": "string", + "format": "date" + }, + "genre": { + "type": "string" + }, + "duration": { + "type": "string" + }, + "cast": { + "type": "array", + "items": { + "type": "string" + } + } + } +} +``` + +**Data** + +```json +{ + "title": "Sample Movie", + "director": "John Director", + "releaseDate": "2023-07-01", + "genre": "Action", + "duration": "2h 15m", + "cast": ["Actor A", "Actress B", "Actor C"] +} +``` + + +## Order + +A schema representing an order, including properties like `order ID`, `items`, `total price`, `customer details`, and `shipping address`. + +```json +{ + "$id": "https://example.com/order.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of an order", + "type": "object", + "required": ["orderId", "items", "totalPrice"], + "properties": { + "orderId": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "productId": { + "type": "string" + }, + "quantity": { + "type": "integer", + "minimum": 1 + } + } + } + }, + "totalPrice": { + "type": "number", + "minimum": 0 + }, + "customer": { + "$ref": "https://example.com/user-profile.schema.json" + }, + "shippingAddress": { + "$ref": "https://example.com/address.schema.json" + } + } +} +``` + +**Data** + +```json +{ + "orderId": "ORD123", + "items": [ + { "productId": "PROD1", "quantity": 2 }, + { "productId": "PROD2", "quantity": 1 } + ], + "totalPrice": 150, + "customer": { + "username": "customeruser", + "email": "customer@example.com" + }, + "shippingAddress": { + "street-address": "123 Shipping St", + "locality": "Cityville", + "region": "State", + "postal-code": "54321", + "country-name": "Country" + } +} +``` + + +## Product + +A schema representing a product, including properties such as `name`, `price`, `description`, `category`, and `inventory count`. + +```json +{ + "$id": "https://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a product", + "type": "object", + "required": ["name", "price"], + "properties": { + "name": { + "type": "string" + }, + "price": { + "type": "number", + "minimum": 0 + }, + "description": { + "type": "string" + }, + "category": { + "type": "string" + }, + "inventory": { + "type": "integer", + "minimum": 0 + } + } +} +``` + +**Data** + +```json +{ + "name": "Product A", + "price": 50, + "description": "A high-quality product", + "category": "Electronics", + "inventory": 100 +} +``` + + +## Recipe + +A schema representing a recipe, including properties like `name`, `ingredients`, `cooking instructions`, `preparation time`, `cooking time`, and `servings`. + +```json +{ + "$id": "https://example.com/recipe.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a recipe", + "type": "object", + "required": ["name", "ingredients", "instructions"], + "properties": { + "name": { + "type": "string" + }, + "ingredients": { + "type": "array", + "items": { + "type": "string" + } + }, + "instructions": { + "type": "string" + }, + "prepTime": { + "type": "string" + }, + "cookTime": { + "type": "string" + }, + "servings": { + "type": "integer", + "minimum": 1 + } + } +} +``` + +**Data** + +```json +{ + "name": "Chocolate Chip Cookies", + "ingredients": ["Flour", "Sugar", "Chocolate Chips", "Butter"], + "instructions": "1. Preheat the oven...", + "prepTime": "15 minutes", + "cookTime": "12 minutes", + "servings": 24 +} +``` + + +## User profile + +A schema representing a user profile, including properties like `username`, `email`, `full name`, `age`, `location`, and `interests`. + +```json +{ + "$id": "https://example.com/user-profile.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "A representation of a user profile", + "type": "object", + "required": ["username", "email"], + "properties": { + "username": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "fullName": { + "type": "string" + }, + "age": { + "type": "integer", + "minimum": 0 + }, + "location": { + "type": "string" + }, + "interests": { + "type": "array", + "items": { + "type": "string" + } + } + } +} +``` + +**Data** + +```json +{ + "username": "user123", + "email": "user@example.com", + "fullName": "John Doe", + "age": 30, + "location": "Cityville", + "interests": ["Travel", "Technology"] +} +``` + From f149409f00c5aee9188dfbbe57bb16ab8387da8d Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 14:48:46 +0530 Subject: [PATCH 03/16] update: add summary and index for examples Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index dc69ceeb4..18700f64b 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -3,6 +3,25 @@ section: docs title: JSON Schema examples --- +In this page, you will find examples illustrating different use cases to help you get the most out of your JSON Schemas. These examples cover a wide range of scenarios, and each example comes with accompanying JSON data and explanation, showcasing how JSON Schemas can be applied to various domains. + +- [Address](#address) +- [Blog post](#blog-post) +- [Book](#book) +- [Calendar](#calendar) +- [Card](#card) +- [Event registration](#event-registration) +- [Geographical location](#geographical-location) +- [Health record](#health-record) +- [Invoice](#invoice) +- [Job posting](#job-posting) +- [Movie](#movie) +- [Order](#order) +- [Product](#product) +- [Recipe](#recipe) +- [User profile](#user-profile) + + ## Address A schema representing an address, with optional properties for different address components like `post-office-box`, `street-address`, `locality`, `region`, `postal-code`, and `country-name`. From 44bf982a98edcbe0518618f30246727f325fbb42 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 14:52:44 +0530 Subject: [PATCH 04/16] update: add summary for the example Signed-off-by: Akanksha Kushwaha --- pages/learn/file-system.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pages/learn/file-system.md b/pages/learn/file-system.md index acd2f3bea..9a8d70522 100644 --- a/pages/learn/file-system.md +++ b/pages/learn/file-system.md @@ -3,6 +3,14 @@ section: docs title: Modeling a file system with JSON Schema --- +This guide unfolds a step-by-step walkthrough to design a JSON Schema that mirrors the structure of an `/etc/fstab` file. This file maps out the connections of various storage parts in a computer. The journey starts by crafting a foundational arrangement for the `fstab` file. We apply various keywords like `$id`, `type`, and `patternProperties` to create rules for the entries. + +In the next phase, we introduce the idea of an `entry` schema. This schema functions as a plan for how each part of the file should look. We employ keywords like `description`, `oneOf`, and `$ref` to construct this plan, making it flexible for different kinds of entries. + +The guide goes further to detail rules customized for specific parts of each entry. For example, it clarifies how to precisely classify storage, defines acceptable options, and decides if something is merely readable. Our exploration widens to intricate plans for varied storage types, including regular disks, network storage, and temporary storage. + +To conclude, all these facets are interwoven to create a comprehensive design for the entire `fstab` file. The guide employs simple language and practical examples to make grasping the concepts behind JSON Schema and its role in explaining the setup of `fstab` files effortless. + * [Introduction](#introduction) * [Creating the `fstab` schema](#fstab-schema) * [Starting the `entry` schema](#entry-schema) From fda5b98294207d3e8157cf16f57d2343f56cf7e5 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 14:55:58 +0530 Subject: [PATCH 05/16] minor: update formatting Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index 18700f64b..40eeeeb11 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -24,7 +24,7 @@ In this page, you will find examples illustrating different use cases to help yo ## Address -A schema representing an address, with optional properties for different address components like `post-office-box`, `street-address`, `locality`, `region`, `postal-code`, and `country-name`. +A schema representing an address, with optional properties for different address components like `post office box`, `street address`, `locality`, `region`, `postal code`, and `country name`. ```json { @@ -79,7 +79,7 @@ A schema representing an address, with optional properties for different address ## Blog post -A schema representing a blog post, including properties like `title`, `content`, `published-date`, `author-details`, and `tags`. +A schema representing a blog post, including properties like `title`, `content`, `published date`, `author details`, and `tags`. ```json { @@ -130,7 +130,7 @@ A schema representing a blog post, including properties like `title`, `content`, ## Book -A schema representing a book, including various properties like `title`, `author`, `publication-date`, `genre`, `ISBN`, and `rating`. +A schema representing a book, including various properties like `title`, `author`, `publication date`, `genre`, `ISBN`, and `rating`. ```json { @@ -181,7 +181,7 @@ A schema representing a book, including various properties like `title`, `author ## Calendar -A schema representing an event in a calendar, including properties like `start-date`, `end-date`, `summary`, `location`, and `recurrence` details. +A schema representing an event in a calendar, including properties like `start date`, `end date`, `summary`, `location`, and `recurrence` details. ```json { @@ -248,7 +248,7 @@ A schema representing an event in a calendar, including properties like `start-d ## Card -A schema representing a person, company, organization, or place, with properties such as `name`, `contact-information`, and `organizational-details`. +A schema representing a person, company, organization, or place, with properties such as `name`, `contact information`, and `organizational details`. ```json { @@ -378,7 +378,7 @@ A schema representing a person, company, organization, or place, with properties ## Event registration -A schema representing an event registration, including properties like `event-name`, `participant-details`, `registration-date`, `ticket-type`, and `ticket-price`. +A schema representing an event registration, including properties like `event name`, `participant details`, `registration date`, `ticket type`, and `ticket price`. ```json { @@ -464,7 +464,7 @@ A schema representing geographical coordinates with `latitude` and `longitude` v ## Health record -A schema representing a health record, including `patient-information`, `allergies`, `medical-conditions`, `medications`, and `emergency-contact`. +A schema representing a health record, including `patient information`, `allergies`, `medical conditions`, `medications`, and `emergency contact`. ```json { From 6d442b363e417b816b294c6b3c396bb0a1228230 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 15:03:26 +0530 Subject: [PATCH 06/16] update: rename misc examples to generic examples Signed-off-by: Akanksha Kushwaha --- components/Layout.tsx | 2 +- pages/learn/{miscellaneous-examples.md => generic-examples.md} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename pages/learn/{miscellaneous-examples.md => generic-examples.md} (99%) diff --git a/components/Layout.tsx b/components/Layout.tsx index 5e4df7b65..14d125452 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -201,7 +201,7 @@ const DocsNav = () => {
- +
diff --git a/pages/learn/miscellaneous-examples.md b/pages/learn/generic-examples.md similarity index 99% rename from pages/learn/miscellaneous-examples.md rename to pages/learn/generic-examples.md index 63d3ce5e3..57ee08cdf 100644 --- a/pages/learn/miscellaneous-examples.md +++ b/pages/learn/generic-examples.md @@ -1,6 +1,6 @@ --- section: docs -title: Miscellaneous Examples +title: Generic Examples --- In this page, you will find examples illustrating different uses cases to help you get the most out of your JSON Schemas, including: From 449cc1ab7d9d5985f481f17034ce2d8a81eb3b76 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 15:14:16 +0530 Subject: [PATCH 07/16] Revert "update: rename misc examples to generic examples" Signed-off-by: Akanksha Kushwaha --- components/Layout.tsx | 2 +- pages/learn/{generic-examples.md => miscellaneous-examples.md} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename pages/learn/{generic-examples.md => miscellaneous-examples.md} (99%) diff --git a/components/Layout.tsx b/components/Layout.tsx index 14d125452..5e4df7b65 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -201,7 +201,7 @@ const DocsNav = () => {
- +
diff --git a/pages/learn/generic-examples.md b/pages/learn/miscellaneous-examples.md similarity index 99% rename from pages/learn/generic-examples.md rename to pages/learn/miscellaneous-examples.md index 57ee08cdf..63d3ce5e3 100644 --- a/pages/learn/generic-examples.md +++ b/pages/learn/miscellaneous-examples.md @@ -1,6 +1,6 @@ --- section: docs -title: Generic Examples +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: From 4eb16cf7b1a105759723ddba1db6fc294b5bf484 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Fri, 1 Sep 2023 15:18:32 +0530 Subject: [PATCH 08/16] update: rename misc examples to generic examples Signed-off-by: Akanksha Kushwaha --- components/Layout.tsx | 2 +- pages/learn/{miscellaneous-examples.md => generic-examples.md} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename pages/learn/{miscellaneous-examples.md => generic-examples.md} (100%) diff --git a/components/Layout.tsx b/components/Layout.tsx index cd0bcea44..e610391d1 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -256,7 +256,7 @@ export const DocsNav = () => { > - + diff --git a/pages/learn/miscellaneous-examples.md b/pages/learn/generic-examples.md similarity index 100% rename from pages/learn/miscellaneous-examples.md rename to pages/learn/generic-examples.md From 3a8a0d92dda49531bacf511eecb15e33d4b415fb Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha <72210364+aku1310@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:47:09 +0530 Subject: [PATCH 09/16] minor: update summary of 'Generic Examples' section Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com> --- pages/learn/generic-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/learn/generic-examples.md b/pages/learn/generic-examples.md index 63d3ce5e3..32b0d2e31 100644 --- a/pages/learn/generic-examples.md +++ b/pages/learn/generic-examples.md @@ -3,7 +3,7 @@ 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. - [A typical minimum schema](#basic) - [Arrays of things](#arrays-of-things) From d972d878aca9f7aa45c36f5f6832abda0663e20f Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha <72210364+aku1310@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:47:50 +0530 Subject: [PATCH 10/16] minor: update summary of file system section Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com> --- pages/learn/file-system.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/learn/file-system.md b/pages/learn/file-system.md index 9a8d70522..a6ab67bc3 100644 --- a/pages/learn/file-system.md +++ b/pages/learn/file-system.md @@ -3,7 +3,9 @@ section: docs title: Modeling a file system with JSON Schema --- -This guide unfolds a step-by-step walkthrough to design a JSON Schema that mirrors the structure of an `/etc/fstab` file. This file maps out the connections of various storage parts in a computer. The journey starts by crafting a foundational arrangement for the `fstab` file. We apply various keywords like `$id`, `type`, and `patternProperties` to create rules for the entries. +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: In the next phase, we introduce the idea of an `entry` schema. This schema functions as a plan for how each part of the file should look. We employ keywords like `description`, `oneOf`, and `$ref` to construct this plan, making it flexible for different kinds of entries. From a926ad2169aea06285c87d6929a6dd6208d8c539 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Mon, 4 Sep 2023 19:50:05 +0530 Subject: [PATCH 11/16] minor: update summary of file system section Signed-off-by: Akanksha Kushwaha --- pages/learn/file-system.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pages/learn/file-system.md b/pages/learn/file-system.md index a6ab67bc3..79ec422f5 100644 --- a/pages/learn/file-system.md +++ b/pages/learn/file-system.md @@ -7,12 +7,6 @@ In this step-by-step guide you will learn how to design a JSON Schema that mirro This guide is divided into the following sections: -In the next phase, we introduce the idea of an `entry` schema. This schema functions as a plan for how each part of the file should look. We employ keywords like `description`, `oneOf`, and `$ref` to construct this plan, making it flexible for different kinds of entries. - -The guide goes further to detail rules customized for specific parts of each entry. For example, it clarifies how to precisely classify storage, defines acceptable options, and decides if something is merely readable. Our exploration widens to intricate plans for varied storage types, including regular disks, network storage, and temporary storage. - -To conclude, all these facets are interwoven to create a comprehensive design for the entire `fstab` file. The guide employs simple language and practical examples to make grasping the concepts behind JSON Schema and its role in explaining the setup of `fstab` files effortless. - * [Introduction](#introduction) * [Creating the `fstab` schema](#fstab-schema) * [Starting the `entry` schema](#entry-schema) From ee8cf4be1e4be964314756766e71d4fe5c4a70bc Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Sun, 24 Sep 2023 00:09:19 +0530 Subject: [PATCH 12/16] update: rename misc examples to generic examples Signed-off-by: Akanksha Kushwaha --- components/Sidebar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 0955e19e7..fac9a8bb6 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -39,7 +39,7 @@ const getDocsPath = [ const getStartedPath = [ '/learn/json-schema-examples', '/learn/file-system', - '/learn/miscellaneous-examples', + '/learn/generic-examples', '/learn/getting-started-step-by-step' ] const getReferencePath = [ @@ -177,7 +177,7 @@ export const DocsNav = () => { > - + From fdaecee56a10a8b56d042bf2e788a69cd69d2623 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Thu, 28 Sep 2023 21:06:30 +0530 Subject: [PATCH 13/16] docs: update examples Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 563 ++++++---------------------- 1 file changed, 111 insertions(+), 452 deletions(-) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index 40eeeeb11..54f465a6a 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -3,28 +3,23 @@ section: docs title: JSON Schema examples --- -In this page, you will find examples illustrating different use cases to help you get the most out of your JSON Schemas. These examples cover a wide range of scenarios, and each example comes with accompanying JSON data and explanation, showcasing how JSON Schemas can be applied to various domains. +In this page, you will find examples illustrating different use cases to help you get the most out of your JSON Schemas. These examples cover a wide range of scenarios, and each example comes with accompanying JSON data and explanation, showcasing how JSON Schemas can be applied to various domains. You can modify these examples to suit your specific needs, as this is just one of the many ways you can utilize JSON Schemas. - [Address](#address) - [Blog post](#blog-post) -- [Book](#book) - [Calendar](#calendar) -- [Card](#card) -- [Event registration](#event-registration) +- [Device Type](#device-type) +- [Ecommerce System](#ecommerce-system) - [Geographical location](#geographical-location) - [Health record](#health-record) -- [Invoice](#invoice) - [Job posting](#job-posting) - [Movie](#movie) -- [Order](#order) -- [Product](#product) -- [Recipe](#recipe) - [User profile](#user-profile) ## Address -A schema representing an address, with optional properties for different address components like `post office box`, `street address`, `locality`, `region`, `postal code`, and `country name`. +A schema representing an address, with optional properties for different address components which enforces that `locality`, `region`, and `countryName` are required, and if `postOfficeBox` or `extendedAddress` is provided, `streetAddress` must also be provided. ```json { @@ -33,13 +28,13 @@ A schema representing an address, with optional properties for different address "description": "An address similar to http://microformats.org/wiki/h-card", "type": "object", "properties": { - "post-office-box": { + "postOfficeBox": { "type": "string" }, - "extended-address": { + "extendedAddress": { "type": "string" }, - "street-address": { + "streetAddress": { "type": "string" }, "locality": { @@ -48,17 +43,17 @@ A schema representing an address, with optional properties for different address "region": { "type": "string" }, - "postal-code": { + "postalCode": { "type": "string" }, - "country-name": { + "countryName": { "type": "string" } }, - "required": [ "locality", "region", "country-name" ], + "required": [ "locality", "region", "countryName" ], "dependentRequired": { - "post-office-box": [ "street-address" ], - "extended-address": [ "street-address" ] + "postOfficeBox": [ "streetAddress" ], + "extendedAddress": [ "streetAddress" ] } } ``` @@ -67,19 +62,19 @@ A schema representing an address, with optional properties for different address ```json { - "post-office-box": "123", - "street-address": "456 Main St", + "postOfficeBox": "123", + "streetAddress": "456 Main St", "locality": "Cityville", "region": "State", - "postal-code": "12345", - "country-name": "Country" + "postalCode": "12345", + "countryName": "Country" } ``` ## Blog post -A schema representing a blog post, including properties like `title`, `content`, `published date`, `author details`, and `tags`. +A schema representing a blog post, including properties like `title`, `content`, `publishedDate`, `author`, and `tags`. ```json { @@ -128,60 +123,9 @@ A schema representing a blog post, including properties like `title`, `content`, ``` -## Book - -A schema representing a book, including various properties like `title`, `author`, `publication date`, `genre`, `ISBN`, and `rating`. - -```json -{ - "$id": "https://example.com/book.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of a book", - "type": "object", - "required": ["title", "author"], - "properties": { - "title": { - "type": "string" - }, - "author": { - "type": "string" - }, - "publicationDate": { - "type": "string", - "format": "date" - }, - "genre": { - "type": "string" - }, - "isbn": { - "type": "string" - }, - "rating": { - "type": "number", - "minimum": 0, - "maximum": 5 - } - } -} -``` - -**Data** - -```json -{ - "title": "Sample Book", - "author": "Jane Smith", - "publicationDate": "2023-07-15", - "genre": "Fiction", - "isbn": "978-1234567890", - "rating": 4.5 -} -``` - - ## Calendar -A schema representing an event in a calendar, including properties like `start date`, `end date`, `summary`, `location`, and `recurrence` details. +A schema representing an event in a calendar, including properties like `startDate`, `endDate`, `summary`, `location`, and `recurrenceDate` details. The `geo` property is a reference (`$ref`) to another schema defined at a different location which represents a geographical location with latitude and longitude values. ```json { @@ -191,11 +135,11 @@ A schema representing an event in a calendar, including properties like `start d "type": "object", "required": [ "dtstart", "summary" ], "properties": { - "dtstart": { + "startDate": { "type": "string", "description": "Event starting time" }, - "dtend": { + "endDate": { "type": "string", "description": "Event ending time" }, @@ -212,11 +156,11 @@ A schema representing an event in a calendar, including properties like `start d "type": "string", "description": "Event duration" }, - "rdate": { + "recurrenceDate": { "type": "string", "description": "Recurrence date" }, - "rrule": { + "recurrenceDule": { "type": "string", "description": "Recurrence rule" }, @@ -237,118 +181,70 @@ A schema representing an event in a calendar, including properties like `start d ```json { - "dtstart": "2023-08-25T10:00:00Z", - "dtend": "2023-08-25T12:00:00Z", + "startDate": "2023-08-25T10:00:00Z", + "endDate": "2023-08-25T12:00:00Z", "summary": "Conference Presentation", "location": "Conference Center", - "rrule": "FREQ=DAILY;COUNT=5" + "recurrenceDule": "FREQ=DAILY;COUNT=5" } ``` -## Card +## Device type -A schema representing a person, company, organization, or place, with properties such as `name`, `contact information`, and `organizational details`. +This schema represents electronic devices with a `deviceType` property that determines the device's category, such as `Smartphone` or `Laptop`.It employs the `$dynamicRef` keyword to dynamically reference schemas based on the `deviceType` property. This flexible schema structure allows data to conform to the appropriate device schema based on the `deviceType` specified, making it easy to describe different electronic devices with their unique characteristics ```json { - "$id": "https://example.com/card.schema.json", + "$id": "https://example.com/device.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of a person, company, organization, or place", "type": "object", - "required": [ "familyName", "givenName" ], "properties": { - "fn": { - "description": "Formatted Name", + "deviceType": { "type": "string" - }, - "familyName": { - "type": "string" - }, - "givenName": { - "type": "string" - }, - "additionalName": { - "type": "array", - "items": { - "type": "string" - } - }, - "honorificPrefix": { - "type": "array", - "items": { - "type": "string" - } - }, - "honorificSuffix": { - "type": "array", - "items": { - "type": "string" - } - }, - "nickname": { - "type": "string" - }, - "url": { - "type": "string" - }, - "email": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "tel": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "adr": { "$ref": "https://example.com/address.schema.json" }, - "geo": { "$ref": "https://example.com/geographical-location.schema.json" }, - "tz": { - "type": "string" - }, - "photo": { - "type": "string" - }, - "logo": { + } + }, + "required": ["deviceType"], + "$dynamicRef": "#/$defs/DeviceTypes" +} + +{ + "$id": "https://example.com/smartphone.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "brand": { "type": "string" }, - "sound": { + "model": { "type": "string" }, - "bday": { + "screenSize": { + "type": "number" + } + }, + "required": ["brand", "model", "screenSize"] +} + +{ + "$id": "https://example.com/laptop.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "brand": { "type": "string" }, - "title": { + "model": { "type": "string" }, - "role": { + "processor": { "type": "string" }, - "org": { - "type": "object", - "properties": { - "organizationName": { - "type": "string" - }, - "organizationUnit": { - "type": "string" - } - } + "ramSize": { + "type": "number" } - } + }, + "required": ["brand", "model", "processor", "ramSize"] } ``` @@ -356,54 +252,41 @@ A schema representing a person, company, organization, or place, with properties ```json { - "fn": "John Doe", - "givenName": "John", - "familyName": "Doe", - "email": { - "type": "work", - "value": "john.doe@example.com" - }, - "tel": { - "type": "home", - "value": "123-456-7890" - }, - "adr": { - "locality": "Cityville", - "region": "State", - "country-name": "Country" - } + "deviceType": "Smartphone", + "brand": "Samsung", + "model": "Galaxy S21", + "screenSize": 6.2 } ``` -## Event registration +## Ecommerce system -A schema representing an event registration, including properties like `event name`, `participant details`, `registration date`, `ticket type`, and `ticket price`. +A schema representing an ecommerce system, where `$anchor` is used within the definitions of `product` and `order` schemas to define anchor points: `ProductSchema` and `OrderSchema`, respectively. ```json { - "$id": "https://example.com/event-registration.schema.json", + "$id": "https://example.com/ecommerce.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of an event registration", - "type": "object", - "required": ["eventName", "participant", "registrationDate"], - "properties": { - "eventName": { - "type": "string" - }, - "participant": { - "$ref": "https://example.com/user-profile.schema.json" - }, - "registrationDate": { - "type": "string", - "format": "date-time" - }, - "ticketType": { - "type": "string" + "$defs": { + "product": { + "$anchor": "ProductSchema", + "type": "object", + "properties": { + "name": { "type": "string" }, + "price": { "type": "number", "minimum": 0 } + } }, - "ticketPrice": { - "type": "number", - "minimum": 0 + "order": { + "$anchor": "OrderSchema", + "type": "object", + "properties": { + "orderId": { "type": "string" }, + "items": { + "type": "array", + "items": { "$ref": "#/$defs/ProductSchema" } + } + } } } } @@ -413,14 +296,19 @@ A schema representing an event registration, including properties like `event na ```json { - "eventName": "Tech Conference", - "participant": { - "username": "participantuser", - "email": "participant@example.com" - }, - "registrationDate": "2023-08-20T10:00:00Z", - "ticketType": "Standard", - "ticketPrice": 100 + "order": { + "orderId": "ORD123", + "items": [ + { + "name": "Product A", + "price": 50 + }, + { + "name": "Product B", + "price": 30 + } + ] + } } ``` @@ -464,13 +352,13 @@ A schema representing geographical coordinates with `latitude` and `longitude` v ## Health record -A schema representing a health record, including `patient information`, `allergies`, `medical conditions`, `medications`, and `emergency contact`. +A schema representing a health record, including `patientName`, `dateOfBirth`, `bloodType`, `allergies`, `conditions`, `medications`, and `emergencyContact`. ```json { "$id": "https://example.com/health-record.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of a health record", + "description": "Schema for representing a health record", "type": "object", "required": ["patientName", "dateOfBirth", "bloodType"], "properties": { @@ -527,75 +415,9 @@ A schema representing a health record, including `patient information`, `allergi ``` -## Invoice - -A schema representing an invoice, including `invoice details`, `billing address`, `line items`, and `total amount`. - -```json -{ - "$id": "https://example.com/invoice.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of an invoice", - "type": "object", - "required": ["invoiceNumber", "billingAddress", "items", "totalAmount"], - "properties": { - "invoiceNumber": { - "type": "string" - }, - "billingAddress": { - "$ref": "https://example.com/address.schema.json" - }, - "items": { - "type": "array", - "items": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "quantity": { - "type": "integer", - "minimum": 1 - }, - "unitPrice": { - "type": "number", - "minimum": 0 - } - } - } - }, - "totalAmount": { - "type": "number", - "minimum": 0 - } - } -} -``` - -**Data** - -```json -{ - "invoiceNumber": "INV123", - "billingAddress": { - "street-address": "789 Billing St", - "locality": "Cityville", - "region": "State", - "postal-code": "54321", - "country-name": "Country" - }, - "items": [ - { "description": "Product A", "quantity": 2, "unitPrice": 50 }, - { "description": "Product B", "quantity": 1, "unitPrice": 30 } - ], - "totalAmount": 130 -} -``` - - ## Job posting -A schema representing a job posting, including properties like `job title`, `company name`, `location`, `job description`, `employment type`, `salary`, and `application deadline`. +A schema representing a job posting, including properties like `title`, `company`, `location`, `description`, `employmentType`, `salary`, and `applicationDeadline`. It also uses the `$anchor` keyword for defining an anchor. ```json { @@ -628,7 +450,8 @@ A schema representing a job posting, including properties like `job title`, `com "type": "string", "format": "date" } - } + }, + "$anchor": "JobPosting" } ``` @@ -670,7 +493,8 @@ A schema representing a movie, including properties such as `title`, `director`, "format": "date" }, "genre": { - "type": "string" + "type": "string", + "enum": ["Action", "Comedy", "Drama", "Science Fiction"] }, "duration": { "type": "string" @@ -679,9 +503,11 @@ A schema representing a movie, including properties such as `title`, `director`, "type": "array", "items": { "type": "string" - } + }, + "additionalItems": false } - } + }, + "$anchor": "MovieSchema" } ``` @@ -699,176 +525,9 @@ A schema representing a movie, including properties such as `title`, `director`, ``` -## Order - -A schema representing an order, including properties like `order ID`, `items`, `total price`, `customer details`, and `shipping address`. - -```json -{ - "$id": "https://example.com/order.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of an order", - "type": "object", - "required": ["orderId", "items", "totalPrice"], - "properties": { - "orderId": { - "type": "string" - }, - "items": { - "type": "array", - "items": { - "type": "object", - "properties": { - "productId": { - "type": "string" - }, - "quantity": { - "type": "integer", - "minimum": 1 - } - } - } - }, - "totalPrice": { - "type": "number", - "minimum": 0 - }, - "customer": { - "$ref": "https://example.com/user-profile.schema.json" - }, - "shippingAddress": { - "$ref": "https://example.com/address.schema.json" - } - } -} -``` - -**Data** - -```json -{ - "orderId": "ORD123", - "items": [ - { "productId": "PROD1", "quantity": 2 }, - { "productId": "PROD2", "quantity": 1 } - ], - "totalPrice": 150, - "customer": { - "username": "customeruser", - "email": "customer@example.com" - }, - "shippingAddress": { - "street-address": "123 Shipping St", - "locality": "Cityville", - "region": "State", - "postal-code": "54321", - "country-name": "Country" - } -} -``` - - -## Product - -A schema representing a product, including properties such as `name`, `price`, `description`, `category`, and `inventory count`. - -```json -{ - "$id": "https://example.com/product.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of a product", - "type": "object", - "required": ["name", "price"], - "properties": { - "name": { - "type": "string" - }, - "price": { - "type": "number", - "minimum": 0 - }, - "description": { - "type": "string" - }, - "category": { - "type": "string" - }, - "inventory": { - "type": "integer", - "minimum": 0 - } - } -} -``` - -**Data** - -```json -{ - "name": "Product A", - "price": 50, - "description": "A high-quality product", - "category": "Electronics", - "inventory": 100 -} -``` - - -## Recipe - -A schema representing a recipe, including properties like `name`, `ingredients`, `cooking instructions`, `preparation time`, `cooking time`, and `servings`. - -```json -{ - "$id": "https://example.com/recipe.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "A representation of a recipe", - "type": "object", - "required": ["name", "ingredients", "instructions"], - "properties": { - "name": { - "type": "string" - }, - "ingredients": { - "type": "array", - "items": { - "type": "string" - } - }, - "instructions": { - "type": "string" - }, - "prepTime": { - "type": "string" - }, - "cookTime": { - "type": "string" - }, - "servings": { - "type": "integer", - "minimum": 1 - } - } -} -``` - -**Data** - -```json -{ - "name": "Chocolate Chip Cookies", - "ingredients": ["Flour", "Sugar", "Chocolate Chips", "Butter"], - "instructions": "1. Preheat the oven...", - "prepTime": "15 minutes", - "cookTime": "12 minutes", - "servings": 24 -} -``` - - ## User profile -A schema representing a user profile, including properties like `username`, `email`, `full name`, `age`, `location`, and `interests`. +A schema representing a user profile, including properties like `username`, `email`, `fullName`, `age`, `location`, and `interests`. ```json { From 78b254ee7d7e47a902d9a9b61668db3f69217b68 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Sun, 29 Oct 2023 23:26:36 +0530 Subject: [PATCH 14/16] update: rename generic examples to misc examples Signed-off-by: Akanksha Kushwaha --- components/Sidebar.tsx | 2 +- pages/learn/{generic-examples.md => miscellaneous-examples.md} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename pages/learn/{generic-examples.md => miscellaneous-examples.md} (98%) diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index d13e5ea64..d8f215eb6 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -59,7 +59,7 @@ const getDocsPath = [ const getStartedPath = [ '/learn/json-schema-examples', '/learn/file-system', - '/learn/generic-examples', + '/learn/miscellaneous-examples', '/learn/getting-started-step-by-step' ] const getReferencePath = [ diff --git a/pages/learn/generic-examples.md b/pages/learn/miscellaneous-examples.md similarity index 98% rename from pages/learn/generic-examples.md rename to pages/learn/miscellaneous-examples.md index bfc94e75d..abf2b8060 100644 --- a/pages/learn/generic-examples.md +++ b/pages/learn/miscellaneous-examples.md @@ -3,7 +3,7 @@ section: docs title: Miscellaneous Examples --- -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. +In this page, you will find miscellaneous 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. - [A typical minimum schema](#basic) - [Arrays of things](#arrays-of-things) From a5172a3734e17bae97d6ab3c035f414d11f1ad0b Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Sun, 29 Oct 2023 23:27:23 +0530 Subject: [PATCH 15/16] docs: update examples Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index 54f465a6a..39f40bc9e 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -192,7 +192,7 @@ A schema representing an event in a calendar, including properties like `startDa ## Device type -This schema represents electronic devices with a `deviceType` property that determines the device's category, such as `Smartphone` or `Laptop`.It employs the `$dynamicRef` keyword to dynamically reference schemas based on the `deviceType` property. This flexible schema structure allows data to conform to the appropriate device schema based on the `deviceType` specified, making it easy to describe different electronic devices with their unique characteristics +This schema represents electronic devices with a `deviceType` property that determines the device's category, such as `smartphone` or `laptop`. It employs the `oneOf` keyword to dynamically reference schemas based on the `deviceType` property. This flexible schema structure allows data to conform to the appropriate device schema based on the deviceType specified, making it easy to describe different electronic devices with their unique characteristics. When `deviceType` is set to `smartphone`, the schema enforces properties specific to smartphones, and when `deviceType` is set to `laptop`, it enforces properties specific to laptops. ```json { @@ -205,7 +205,20 @@ This schema represents electronic devices with a `deviceType` property that dete } }, "required": ["deviceType"], - "$dynamicRef": "#/$defs/DeviceTypes" + "oneOf": [ + { + "properties": { + "deviceType": { "const": "smartphone" } + }, + "$ref": "https://example.com/smartphone.schema.json" + }, + { + "properties": { + "deviceType": { "const": "laptop" } + }, + "$ref": "https://example.com/laptop.schema.json" + } + ] } { @@ -284,7 +297,7 @@ A schema representing an ecommerce system, where `$anchor` is used within the de "orderId": { "type": "string" }, "items": { "type": "array", - "items": { "$ref": "#/$defs/ProductSchema" } + "items": { "$ref": "#ProductSchema" } } } } @@ -450,8 +463,7 @@ A schema representing a job posting, including properties like `title`, `company "type": "string", "format": "date" } - }, - "$anchor": "JobPosting" + } } ``` @@ -506,8 +518,7 @@ A schema representing a movie, including properties such as `title`, `director`, }, "additionalItems": false } - }, - "$anchor": "MovieSchema" + } } ``` From 816a1021aefb33a0ab4874f3537b648283fae338 Mon Sep 17 00:00:00 2001 From: Akanksha Kushwaha Date: Mon, 30 Oct 2023 12:46:13 +0530 Subject: [PATCH 16/16] docs: fix capitalisation in example data Signed-off-by: Akanksha Kushwaha --- pages/learn/json-schema-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/learn/json-schema-examples.md b/pages/learn/json-schema-examples.md index 39f40bc9e..d86b9656b 100644 --- a/pages/learn/json-schema-examples.md +++ b/pages/learn/json-schema-examples.md @@ -265,7 +265,7 @@ This schema represents electronic devices with a `deviceType` property that dete ```json { - "deviceType": "Smartphone", + "deviceType": "smartphone", "brand": "Samsung", "model": "Galaxy S21", "screenSize": 6.2