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

Added migration page overview #1061

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
859a6f1
Added migration page overview
kwennB Oct 24, 2024
93bcaba
Update pages/specification/migration/_index.md
kwennB Oct 25, 2024
d4c8b24
Update pages/specification/migration/_index.md
kwennB Oct 25, 2024
8eb9721
Updated migration overview
kwennB Oct 28, 2024
75ee2a1
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
a967f66
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
b22b2ff
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
c5d352e
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
136ee2e
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
fa6391b
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
83536f1
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
dd364ba
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
dd1d4e7
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
33b69ab
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
9c583ce
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
5a4b8b3
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
24488f9
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
4e5a08d
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
d17e308
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
c5b1f87
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
95276a0
Update pages/specification/migration/_index.md
kwennB Oct 29, 2024
288e5d9
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
7199292
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
8cc36f0
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
45aecbc
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
65ba898
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
9891c6e
Update pages/specification/migration/_index.md
kwennB Oct 30, 2024
5bdfc65
added updates to migration overview
kwennB Oct 30, 2024
3ef35de
Adding migration folders and cards
benjagm Nov 2, 2024
a68d4f3
updated overview
kwennB Nov 7, 2024
65325b8
renamed page and added metadata
benjagm Nov 8, 2024
419ea36
updated links to the rights migration docs
benjagm Nov 8, 2024
43f9816
Added Alterschema details and individual draft pages
kwennB Nov 8, 2024
bb62eaa
Added migration data to single page-Draft 3-4.
kwennB Nov 12, 2024
757f1f9
Updated the Draft 3-4
kwennB Nov 14, 2024
5eae100
Updated Draft 3-4
kwennB Nov 15, 2024
93da171
Update pages/specification/migration/_index.md
kwennB Nov 20, 2024
994f731
Update pages/draft-04/migration-notes.md
kwennB Nov 20, 2024
ffcf639
Update pages/draft-04/migration-notes.md
kwennB Nov 20, 2024
b439468
Update pages/draft-04/migration-notes.md
kwennB Nov 20, 2024
85b9ceb
Update pages/draft-04/migration-notes.md
kwennB Nov 20, 2024
81ebeea
Updated Draft 3-4 & Overview
kwennB Nov 24, 2024
d718e51
added draft 2-3
kwennB Nov 24, 2024
3a5a632
Update pages/draft-04/migration-notes.md
kwennB Dec 2, 2024
33e536b
Update pages/specification/migration/_index.md
kwennB Dec 2, 2024
266963b
Update pages/specification/migration/_index.md
kwennB Dec 2, 2024
e75e0da
Update pages/specification/migration/_index.md
kwennB Dec 2, 2024
78d912a
Update pages/specification/migration/_index.md
kwennB Dec 2, 2024
5a46c9d
Update pages/draft-03/migration-notes.md
kwennB Dec 2, 2024
91c3b63
Update pages/draft-03/migration-notes.md
kwennB Dec 2, 2024
ddec102
Update pages/draft-03/migration-notes.md
kwennB Dec 2, 2024
f0fd4c2
Updated draft 2-3
kwennB Dec 2, 2024
f2aa409
Added Draft 6-7
kwennB Feb 6, 2025
6e7aa3e
CI/CD fix
kwennB Feb 6, 2025
7badaea
Added migration guide for draft 2019-09 to 2020-12
kwennB Mar 14, 2025
625b9f8
Added migration notes page
benjagm Mar 16, 2025
6649ac8
Update migration-notes.md
benjagm Mar 16, 2025
a215d13
Fix problem with slug
benjagm Mar 16, 2025
2d34ff1
Update DocsHelp.tsx
benjagm Mar 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions components/DocsHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@ import React, { FormEvent, useRef, useState } from 'react';
import extractPathWithoutFragment from '~/lib/extractPathWithoutFragment';

interface DocsHelpProps {
markdownFile?: string;
fileRenderType?: '_indexmd' | 'indexmd' | 'tsx' | '_md' | string;
showEditOption?: boolean;
}

export function DocsHelp({ markdownFile }: DocsHelpProps) {
export function DocsHelp({
fileRenderType,
showEditOption = true,
}: DocsHelpProps) {
const router = useRouter();
const path = encodeURIComponent(router.pathname);
const [isFormOpen, setIsFormOpen] = useState(false);
const [feedbackStatus, setFeedbackStatus] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState('');
const feedbackFormRef = useRef<HTMLFormElement>(null);

let gitredirect = '';
if (
typeof fileRenderType === 'string' &&
fileRenderType.startsWith('https://')
) {
gitredirect = fileRenderType;
} else if (fileRenderType === 'tsx') {
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.page.tsx'}`;
} else if (fileRenderType === '_indexmd') {
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/_index.md'}`;
} else if (fileRenderType === 'indexmd') {
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.md'}`;
} else {
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '.md'}`;
}
async function createFeedbackHandler(event: FormEvent) {
event.preventDefault();
const formData = new FormData(feedbackFormRef.current!);
Expand Down Expand Up @@ -296,28 +312,30 @@ export function DocsHelp({ markdownFile }: DocsHelpProps) {
type of contribution!
</p>
</div>
<div className='my-4 text-[14px]'>
<a
target='_blank'
rel='noreferrer'
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
href={`https://github.com/json-schema-org/website/blob/main/pages${markdownFile ? (markdownFile === '_indexPage' ? extractPathWithoutFragment(router.asPath) + '/_index.md' : extractPathWithoutFragment(router.asPath) + '.md') : `/${path}/index.page.tsx`}`}
data-test='edit-on-github-link'
>
<svg
className='inline-block select-none align-text-bottom mr-1'
aria-hidden='true'
role='img'
viewBox='0 0 16 16'
width='16'
height='16'
fill='currentColor'
{showEditOption && (
<div className='my-4 text-[14px]'>
<a
target='_blank'
rel='noreferrer'
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
href={gitredirect} // Ensure gitredirect is defined
data-test='edit-on-github-link'
>
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
</svg>
Edit this page on Github
</a>
</div>
<svg
className='inline-block select-none align-text-bottom mr-1'
aria-hidden='true'
role='img'
viewBox='0 0 16 16'
width='16'
height='16'
fill='currentColor'
>
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
</svg>
Edit this page on Github
</a>
</div>
)}
<div className='my-2 text-[14px]'>
<a
target='_blank'
Expand Down
2 changes: 1 addition & 1 deletion data/tooling-data.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"C#",
"Go",
"C++",
"JavaScript",
"JavaScript",
"Julia"
]
]
Expand Down
39 changes: 39 additions & 0 deletions pages/draft-02/[slug].page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import Head from 'next/head';
import StyledMarkdown from '~/components/StyledMarkdown';
import { getLayout } from '~/components/Sidebar';
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths';
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
import { Headline1 } from '~/components/Headlines';
import { SectionContext } from '~/context';
import { DocsHelp } from '~/components/DocsHelp';

export async function getStaticPaths() {
return getStaticMarkdownPaths('pages/draft-02');
}
export async function getStaticProps(args: any) {
return getStaticMarkdownProps(args, 'pages/draft-02');
}

export default function StaticMarkdownPage({
frontmatter,
content,
}: {
frontmatter: any;
content: any;
}) {
const fileRenderType = '_md';
const newTitle = 'JSON Schema - ' + frontmatter.title;

return (
<SectionContext.Provider value={frontmatter.section || null}>
<Head>
<title>{newTitle}</title>
</Head>
<Headline1>{frontmatter.title}</Headline1>
<StyledMarkdown markdown={content} />
<DocsHelp fileRenderType={fileRenderType} />
</SectionContext.Provider>
);
}
StaticMarkdownPage.getLayout = getLayout;
4 changes: 4 additions & 0 deletions pages/draft-02/migration-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Draft 01 to Draft 02
section: docs
---
39 changes: 39 additions & 0 deletions pages/draft-03/[slug].page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import Head from 'next/head';
import StyledMarkdown from '~/components/StyledMarkdown';
import { getLayout } from '~/components/Sidebar';
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths';
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
import { Headline1 } from '~/components/Headlines';
import { SectionContext } from '~/context';
import { DocsHelp } from '~/components/DocsHelp';

export async function getStaticPaths() {
return getStaticMarkdownPaths('pages/draft-03');
}
export async function getStaticProps(args: any) {
return getStaticMarkdownProps(args, 'pages/draft-03');
}

export default function StaticMarkdownPage({
frontmatter,
content,
}: {
frontmatter: any;
content: any;
}) {
const fileRenderType = '_md';
const newTitle = 'JSON Schema - ' + frontmatter.title;

return (
<SectionContext.Provider value={frontmatter.section || null}>
<Head>
<title>{newTitle}</title>
</Head>
<Headline1>{frontmatter.title}</Headline1>
<StyledMarkdown markdown={content} />
<DocsHelp fileRenderType={fileRenderType} />
</SectionContext.Provider>
);
}
StaticMarkdownPage.getLayout = getLayout;
48 changes: 48 additions & 0 deletions pages/draft-03/migration-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Draft 02 to Draft 03
section: docs
---

### Introduction

The migration from Draft 2 to Draft 3 of JSON Schema introduced significant updates in schema definition and validation behaviors. Draft 3 refined existing keywords, added new ones, and adjusted validation rules to improve schema precision and consistency. This guide will assist you in updating your JSON Schemas to meet Draft 3 requirements, detailing keyword replacements, vocabulary changes, and modifications in validation behaviors.

### Keyword changelog

| Keyword(Draft 2) | Keyword(Draft 3) | Specification | Keyword type | Behavior Details |
| ----------------- | ------------------- | ------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$schema` | `$schema` | `core` | Identifier | The `$schema` keyword specifies the URI of the JSON Schema that defines the schema of the current document. Validators use this URI to resolve links and determine the JSON Schema version, enabling appropriate validation features. Including the `$schema` keyword is recommended to ensure compatibility with future JSON Schema changes. |
| not present | `$ref` | `core` | Applicator | `$ref` key references an external schema URI for validation. |
| not present | `id` | `core` | Identifier | This keyword defines the schema's current URI (a "self" link). The URI can be relative or absolute and is resolved against the parent schema's URI. If there is no parent schema, it is resolved against the URI used to retrieve the schema. |
| `optional` | `required` | `core` | Assertion | In **draft-02**, object properties defined within the `properties` keyword were required by default, and the `optional` keyword was used to explicitly make a property optional. In **draft-03**, this behavior changed: properties defined under `properties` are now optional by default. As a result, the `optional` keyword became redundant and was replaced by the `required` keyword to reflect the new default behavior, where properties are optional unless explicitly marked as required. |
| `minimumCanEqual` | `exclusiveMinimum` | `core` | Assertion | Specifies that instance values must be strictly greater than the minimum when `exclusiveMinimum` is `true`. |
| `maximumCanEqual` | `exclusiveMaximum` | `core` | Assertion | This ensures that instance values fall below the maximum when `exclusiveMaximum` is `true`. |
| `format` | `format` | `core` | Annotation | This update refined format handling by adding and removing specific types, offering clearer guidance for expected data formats. |
| not present | `patternProperties` | `core` | Applicator | Enforces schema validation on properties with names matching specified regex patterns. Each property matching a pattern must conform to the schema defined for that pattern in `patternProperties`. |
| `requires` | `dependencies` | `core` | Assertion | Defines property dependencies - if an instance includes a property named in this attribute, that property must meet additional validation requirements defined by its dependency value. |
| not present | `additionalItems` | `core` | Applicator | Defines rules for extra items in an array - can be set to false to disallow extra items beyond specified tuples, or to a schema that additional items must follow. |
| `alternate` | removed | `core` | | - |

### Tutorial

#### Step 1: Review Core Changes

Start by understanding the key differences between Draft 2 and Draft 3, especially regarding core changes in $schema, $ref, and validation keywords.

- `$schema`: In Draft 3, this remains the same but is now more standardized to handle the schema dialect and the version of the specification being used.
- `$ref`: Draft 3 introduces the `$ref` keyword, which allows referencing external schemas for validation. This will enable more modular and reusable schema definitions.

#### Step 2: Update Validation Keywords

Draft 3 introduces new validation keywords that improve flexibility in schema definitions. Notable changes include:

- `optional` to `required`: Draft 3 removes the `optional` keyword and introduces `required`, which specifies the required properties for an object.
- `minimumCanEqual` to `exclusiveMinimum`: For numerical validation, `exclusiveMinimum` enforces that the value must be strictly greater than the given minimum value.
- `maximumCanEqual` to `exclusiveMaximum`: Similarly, `exclusiveMaximum` ensures the value is strictly less than the maximum allowed value.
- `patternProperties`: Draft 3 introduces `patternProperties`, which allows you to define schema rules for properties whose names match a regular expression.

#### Step 3: Refactor $ref Usage

Draft 3 introduces `$ref`, which allows you to reference external schemas using **URIs**. This improves schema modularity and enables better reuse of schema definitions.

Validate and test your updated schemas manually, or with your preferred [tool.](https://json-schema.org/tools)
39 changes: 39 additions & 0 deletions pages/draft-04/[slug].page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import Head from 'next/head';
import StyledMarkdown from '~/components/StyledMarkdown';
import { getLayout } from '~/components/Sidebar';
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths';
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps';
import { Headline1 } from '~/components/Headlines';
import { SectionContext } from '~/context';
import { DocsHelp } from '~/components/DocsHelp';

export async function getStaticPaths() {
return getStaticMarkdownPaths('pages/draft-04');
}
export async function getStaticProps(args: any) {
return getStaticMarkdownProps(args, 'pages/draft-04');
}

export default function StaticMarkdownPage({
frontmatter,
content,
}: {
frontmatter: any;
content: any;
}) {
const fileRenderType = '_md';
const newTitle = 'JSON Schema - ' + frontmatter.title;

return (
<SectionContext.Provider value={frontmatter.section || null}>
<Head>
<title>{newTitle}</title>
</Head>
<Headline1>{frontmatter.title}</Headline1>
<StyledMarkdown markdown={content} />
<DocsHelp fileRenderType={fileRenderType} />
</SectionContext.Provider>
);
}
StaticMarkdownPage.getLayout = getLayout;
Loading
Loading