From 42d91f9bfac6d81cce4fdfe24b9147c018b03700 Mon Sep 17 00:00:00 2001 From: tomcollins Date: Thu, 30 Mar 2023 19:00:23 +0100 Subject: [PATCH] Add support for root level deprectaed within schema. --- gh-pages/_includes/examples-table.md | 21 +-- gh-pages/assets/css/style.scss | 8 ++ gh-pages/examples/draft-06/animal.md | 2 + gh-pages/examples/draft-07/user.md | 2 + gh-pages/examples/draft-2019-09/array.md | 2 + gh-pages/examples/draft-2019-09/deprecated.md | 132 ++++++++++++++++++ gh-pages/examples/enums.md | 2 + gh-pages/examples/examples-index.md | 1 + gh-pages/examples/name.md | 2 + gh-pages/examples/oneof.md | 2 + gh-pages/examples/person.md | 2 + gh-pages/yml/draft-2019-09/deprecated.yml | 20 +++ templates/schema.hbs | 14 +- 13 files changed, 194 insertions(+), 16 deletions(-) create mode 100644 gh-pages/examples/draft-2019-09/deprecated.md create mode 100644 gh-pages/yml/draft-2019-09/deprecated.yml diff --git a/gh-pages/_includes/examples-table.md b/gh-pages/_includes/examples-table.md index 84deb5b..9e7f5d5 100644 --- a/gh-pages/_includes/examples-table.md +++ b/gh-pages/_includes/examples-table.md @@ -1,10 +1,11 @@ -| HTML documentation | JSON Schema | -| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -| [Index of documents](/json-schema-static-docs/examples/examples-index.html) | n/a | -| [Person](/json-schema-static-docs/examples/person.html) | [person.yml](/json-schema-static-docs/yml/person.yml) | -| [Name](/json-schema-static-docs/examples/name.html) | [name.yml](/json-schema-static-docs/yml/name.yml) | -| [Enum Value Documentation](/json-schema-static-docs/examples/enums.html) | [enums.yml](/json-schema-static-docs/yml/enums.yml) | -| [One-of](/json-schema-static-docs/examples/oneof.html) | [oneof.yml](/json-schema-static-docs/yml/oneof.yml) | -| [Draft 2019-09 - Array](/json-schema-static-docs/examples/draft-2019-09/array.html) | [draft-2019-09/array.yml](/json-schema-static-docs/yml/draft-2019-09/array.yml) | -| [Draft 07 - User](/json-schema-static-docs/examples/draft-07/user.html) | [draft-07/user.yml](/json-schema-static-docs/yml/draft-07/user.yml) | -| [Draft 06 - Animal](/json-schema-static-docs/examples/draft-06/animal.html) | [draft-06/animal.yml](/json-schema-static-docs/yml/draft-06/animal.yml) | +| HTML documentation | JSON Schema | +| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| [Index of documents](/json-schema-static-docs/examples/examples-index.html) | n/a | +| [Person](/json-schema-static-docs/examples/person.html) | [person.yml](/json-schema-static-docs/yml/person.yml) | +| [Name](/json-schema-static-docs/examples/name.html) | [name.yml](/json-schema-static-docs/yml/name.yml) | +| [Enum Value Documentation](/json-schema-static-docs/examples/enums.html) | [enums.yml](/json-schema-static-docs/yml/enums.yml) | +| [One-of](/json-schema-static-docs/examples/oneof.html) | [oneof.yml](/json-schema-static-docs/yml/oneof.yml) | +| [Draft 2019-09 - Array](/json-schema-static-docs/examples/draft-2019-09/array.html) | [draft-2019-09/array.yml](/json-schema-static-docs/yml/draft-2019-09/array.yml) | +| [Draft 2019-09 - Deprecated](/json-schema-static-docs/examples/draft-2019-09/deprecated.html) | [draft-2019-09/deprecated.yml](/json-schema-static-docs/yml/draft-2019-09/deprecated.yml) | +| [Draft 07 - User](/json-schema-static-docs/examples/draft-07/user.html) | [draft-07/user.yml](/json-schema-static-docs/yml/draft-07/user.yml) | +| [Draft 06 - Animal](/json-schema-static-docs/examples/draft-06/animal.html) | [draft-06/animal.yml](/json-schema-static-docs/yml/draft-06/animal.yml) | diff --git a/gh-pages/assets/css/style.scss b/gh-pages/assets/css/style.scss index da656f5..e27f8de 100644 --- a/gh-pages/assets/css/style.scss +++ b/gh-pages/assets/css/style.scss @@ -38,3 +38,11 @@ h1 { clear: both; margin-top: 50px !important; } + + +div.jssd-deprecated { + background: #d94c4c; + color: white; + width: 100%; + padding: 10px; +} diff --git a/gh-pages/examples/draft-06/animal.md b/gh-pages/examples/draft-06/animal.md index 12af84d..027d51a 100644 --- a/gh-pages/examples/draft-06/animal.md +++ b/gh-pages/examples/draft-06/animal.md @@ -3,6 +3,8 @@ title: Draft 06 - User Example description: A schema demonstrating some draft 06 features --- + + # Draft 06 - User Example

A schema demonstrating some draft 06 features

diff --git a/gh-pages/examples/draft-07/user.md b/gh-pages/examples/draft-07/user.md index cd8db46..937e7ee 100644 --- a/gh-pages/examples/draft-07/user.md +++ b/gh-pages/examples/draft-07/user.md @@ -3,6 +3,8 @@ title: Draft 07 - User Example description: A schema demonstrating some draft 07 features --- + + # Draft 07 - User Example

A schema demonstrating some draft 07 features

diff --git a/gh-pages/examples/draft-2019-09/array.md b/gh-pages/examples/draft-2019-09/array.md index e8a2853..502a194 100644 --- a/gh-pages/examples/draft-2019-09/array.md +++ b/gh-pages/examples/draft-2019-09/array.md @@ -3,6 +3,8 @@ title: Draft 2019-09 - Array Example description: A schema describing fruits and vegetables --- + + # Draft 2019-09 - Array Example

A schema describing fruits and vegetables

diff --git a/gh-pages/examples/draft-2019-09/deprecated.md b/gh-pages/examples/draft-2019-09/deprecated.md new file mode 100644 index 0000000..54068ac --- /dev/null +++ b/gh-pages/examples/draft-2019-09/deprecated.md @@ -0,0 +1,132 @@ +--- +title: Draft 2019-09 - Deprecated Example +description: A schema demonstrating use of deprecated + +--- +
⚠️ This schema has been marked as deprecated.
+ +# Draft 2019-09 - Deprecated Example + +

A schema demonstrating use of deprecated

+ + + + + + +
$idhttps://example.com/deprecated.schema.json
$schemahttps://json-schema.org/draft/2019-09/schema
+ +## Properties + +
NameType
firstNameString
lastNameString
+ + +## Example +``` +{ + "firstName": "Neil", + "lastName": "Williams" +} +``` + +
+ + + +## firstName + + + + + + + + + + + + + + + + + + + +
TitleFirst Name
DescriptionA persons first name
TypeString
RequiredNo
+ + + + + + +## lastName + + + + + + + + + + + + + + + + + + + + + + + +
Deprecatedtrue
TitleLast Name
DescriptionA persons last name
TypeString
RequiredNo
+ + + + + + + + + + +
+ +## Schema +``` +{ + "$id": "https://example.com/deprecated.schema.json", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "title": "Draft 2019-09 - Deprecated Example", + "description": "A schema demonstrating use of deprecated", + "examples": [ + { + "firstName": "Neil", + "lastName": "Williams" + } + ], + "deprecated": true, + "type": "object", + "properties": { + "firstName": { + "deprecated": false, + "type": "string", + "title": "First Name", + "description": "A persons first name" + }, + "lastName": { + "deprecated": true, + "type": "string", + "title": "Last Name", + "description": "A persons last name" + } + } +} +``` + + diff --git a/gh-pages/examples/enums.md b/gh-pages/examples/enums.md index 6bdef10..7e7ae31 100644 --- a/gh-pages/examples/enums.md +++ b/gh-pages/examples/enums.md @@ -3,6 +3,8 @@ title: Enum Documentation description: JSON schema example demonstrating documentation of enum values using the custom meta:enum keyword. This must be enabled using the enableMetaEnum config option. --- + + # Enum Documentation

JSON schema example demonstrating documentation of enum values using the custom meta:enum keyword. This must be enabled using the enableMetaEnum config option.

diff --git a/gh-pages/examples/examples-index.md b/gh-pages/examples/examples-index.md index 5c61c7e..bad554f 100644 --- a/gh-pages/examples/examples-index.md +++ b/gh-pages/examples/examples-index.md @@ -13,3 +13,4 @@ ## Draft-2019-09 - [draft-2019-09/array](draft-2019-09/array.md) +- [draft-2019-09/deprecated](draft-2019-09/deprecated.md) diff --git a/gh-pages/examples/name.md b/gh-pages/examples/name.md index dc8b433..c39cab3 100644 --- a/gh-pages/examples/name.md +++ b/gh-pages/examples/name.md @@ -3,6 +3,8 @@ title: Name description: JSON schema example for a name entity --- + + # Name

JSON schema example for a name entity

diff --git a/gh-pages/examples/oneof.md b/gh-pages/examples/oneof.md index f929a61..042e86a 100644 --- a/gh-pages/examples/oneof.md +++ b/gh-pages/examples/oneof.md @@ -3,6 +3,8 @@ title: One-of description: Example schema to demonstrate the use of the oneOf keyword --- + + # One-of

Example schema to demonstrate the use of the oneOf keyword

diff --git a/gh-pages/examples/person.md b/gh-pages/examples/person.md index 3840e89..1463651 100644 --- a/gh-pages/examples/person.md +++ b/gh-pages/examples/person.md @@ -3,6 +3,8 @@ title: Person description: JSON schema example for a person entity --- + + # Person

JSON schema example for a person entity

diff --git a/gh-pages/yml/draft-2019-09/deprecated.yml b/gh-pages/yml/draft-2019-09/deprecated.yml new file mode 100644 index 0000000..574b267 --- /dev/null +++ b/gh-pages/yml/draft-2019-09/deprecated.yml @@ -0,0 +1,20 @@ +"$id": https://example.com/deprecated.schema.json +"$schema": https://json-schema.org/draft/2019-09/schema +title: Draft 2019-09 - Deprecated Example +description: A schema demonstrating use of deprecated +examples: + - firstName: Neil + lastName: Williams +deprecated: true +type: object +properties: + firstName: + deprecated: false + type: string + title: First Name + description: A persons first name + lastName: + deprecated: true + type: string + title: Last Name + description: A persons last name diff --git a/templates/schema.hbs b/templates/schema.hbs index 8d1c449..feccdc5 100644 --- a/templates/schema.hbs +++ b/templates/schema.hbs @@ -1,3 +1,5 @@ +{{#if schema.deprecated}}
⚠️ This schema has been marked as deprecated.
{{/if}} + {{#if schema.title}}# {{ schema.title }}{{else if schema.description}}# {{ schema.description }}{{else}}# {{/if}} {{#if schema.title}}{{#if schema.description}}

{{ schema.description }}

{{/if}}{{/if}} @@ -121,6 +123,12 @@ {{ this.$id }} {{/if}} + {{#if this.deprecated}} + + Deprecated + {{this.deprecated}} + + {{/if}} {{#if this.title}} Title @@ -146,12 +154,6 @@ {{this.default}} {{/if}} - {{#if this.deprecated}} - - Deprecated - {{this.deprecated}} - - {{/if}} {{#if this.readOnly}} Read Only