From 934b8561de1a78df93c449c99ae81780624dc1c6 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Mon, 16 Dec 2019 10:11:40 +0000 Subject: [PATCH] feat(schema): add support for keyword `deprecated` --- lib/formatInfo.js | 9 ++++++++- schemasupport.md | 6 +++--- test/fixtures/readme-1/simple.schema.json | 1 + test/markdownBuilder.test.js | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/formatInfo.js b/lib/formatInfo.js index 004316a2..5fc92277 100644 --- a/lib/formatInfo.js +++ b/lib/formatInfo.js @@ -91,11 +91,18 @@ function parsedescription(str) { }; } +function getstatus(schema) { + if (schema[keyword`deprecated`] === true) { + return 'deprecated'; + } + return schema[keyword`meta:status`] || undefined; +} + function formatmeta(schema) { return { abstract: isabstract(schema), extensible: isextensible(schema), - status: schema[keyword`meta:status`] || undefined, + status: getstatus(schema), identifiable: isidentifiable(schema), custom: iscustom(schema), additional: schema[keyword`additionalProperties`] !== false, diff --git a/schemasupport.md b/schemasupport.md index 4a9d2dd1..3c4a74b2 100644 --- a/schemasupport.md +++ b/schemasupport.md @@ -1,6 +1,6 @@ # JSON Schema Spec Coverage Report -This report lists the keywords of the JSON Schema spec that are covered in the tests. The overall coverage is 74% +This report lists the keywords of the JSON Schema spec that are covered in the tests. The overall coverage is 76% ## The JSON Schema Core Vocabulary @@ -135,12 +135,12 @@ Coverage for [A Vocabulary for the Contents of String-Encoded Data](https://json ## A Vocabulary for Basic Meta-Data Annotations -Coverage for [A Vocabulary for Basic Meta-Data Annotations](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9) is 57%. +Coverage for [A Vocabulary for Basic Meta-Data Annotations](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9) is 71%. | Keyword | Supported | | :------------ | --------- | | `default` | Yes | -| `deprecated` | No | +| `deprecated` | Yes | | `description` | Yes | | `examples` | Yes | | `readOnly` | No | diff --git a/test/fixtures/readme-1/simple.schema.json b/test/fixtures/readme-1/simple.schema.json index 01285fd3..9f09778a 100644 --- a/test/fixtures/readme-1/simple.schema.json +++ b/test/fixtures/readme-1/simple.schema.json @@ -8,6 +8,7 @@ "$schema": "http://json-schema.org/draft-06/schema#", "$id": "https://example.com/schemas/simple", "title": "Simple", + "deprecated": true, "description": "This is a *very* simple example of a JSON schema. There is only one property.", "type": "object", "properties": { diff --git a/test/markdownBuilder.test.js b/test/markdownBuilder.test.js index 4273c15f..8591b5f9 100644 --- a/test/markdownBuilder.test.js +++ b/test/markdownBuilder.test.js @@ -279,6 +279,7 @@ Reference this group by using it('Simple Schema looks OK', () => { assertMarkdown(results.simple) + .contains('Deprecated') .contains('"Simply Untitled"') .contains('# Simple Schema'); });