diff --git a/examples/docs/README.md b/examples/docs/README.md index 13ab963c1b2698ad3204fc60c699d1d0586eb1af..ecc614e906bc7cd0d894da2b70daf23a3ef5b48a 100644 --- a/examples/docs/README.md +++ b/examples/docs/README.md @@ -9,6 +9,7 @@ * [Abstract](./abstract.schema.md) – `https://example.com/schemas/abstract` * [Definitions](./definitions.schema.md) – `https://example.com/schemas/definitions` * [Example](./example.schema.md) – `https://example.com/schemas/example` +* [Extensible](./extensible.schema.md) – `https://example.com/schemas/extensible` * [Simple](./simple.schema.md) – `https://example.com/schemas/simple` ## /subdir/ diff --git a/examples/docs/example.schema.md b/examples/docs/example.schema.md index f7dde70eaf0bd7fa769597db45c12845710e8d87..a9d0955ad275a7d72963d08040bc4b5942207c91 100644 --- a/examples/docs/example.schema.md +++ b/examples/docs/example.schema.md @@ -13,5 +13,5 @@ This is an example schema with examples. Too many examples? There can never be t | Abstract | Extensible | Custom Properties | Defined In | |----------|------------|-------------------|------------| -| | true | true | [example.schema.json](example.schema.json) | +| false | false | true | [example.schema.json](example.schema.json) | --- \ No newline at end of file diff --git a/examples/docs/extensible.schema.md b/examples/docs/extensible.schema.md new file mode 100644 index 0000000000000000000000000000000000000000..35d1e74be3494a7a18e6723f23a6dd6f877e616a --- /dev/null +++ b/examples/docs/extensible.schema.md @@ -0,0 +1,17 @@ + +--- +template: reference +foo: bar +--- + +# Extensible +``` +https://example.com/schemas/extensible +``` + +This is an extensible schema. It has `definitions`, that can be used in other schemas + +| Abstract | Extensible | Custom Properties | Defined In | +|----------|------------|-------------------|------------| +| true | true | true | [extensible.schema.json](extensible.schema.json) | +--- \ No newline at end of file diff --git a/examples/docs/simple.schema.md b/examples/docs/simple.schema.md index e361ec7b2a2a2005aa2a3a95c0d9ca8b724b1a06..71311cff8a6ca0e35b4364fc9a79cbcce2982a6a 100644 --- a/examples/docs/simple.schema.md +++ b/examples/docs/simple.schema.md @@ -13,5 +13,5 @@ This is a *very* simple example of a JSON schema. There is only one property. | Abstract | Extensible | Custom Properties | Defined In | |----------|------------|-------------------|------------| -| | true | true | [simple.schema.json](simple.schema.json) | +| false | false | true | [simple.schema.json](simple.schema.json) | --- \ No newline at end of file diff --git a/examples/generated-schemas/extensible.schema.json b/examples/generated-schemas/extensible.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..7982be0802c5c47490aa40a11f0443f3a6f45366 --- /dev/null +++ b/examples/generated-schemas/extensible.schema.json @@ -0,0 +1,32 @@ +{ + "meta:license": [ + "Copyright 2017 Adobe Systems Incorporated. All rights reserved.", + "This file is licensed to you under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License. You may obtain a copy", + "of the License at http://www.apache.org/licenses/LICENSE-2.0" + ], + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "https://example.com/schemas/extensible", + "title": "Extensible", + "description": "This is an extensible schema. It has `definitions`, that can be used in other schemas", + "type": "object", + "meta:extensible": true, + "definitions": { + "first": { + "properties": { + "foo": { + "type": "string", + "description": "A unique identifier given to every addressable thing." + } + } + }, + "second": { + "properties": { + "bar": { + "type": "string", + "description": "A unique identifier given to every addressable thing." + } + } + } + } +} \ No newline at end of file diff --git a/examples/schemas/extensible.schema.json b/examples/schemas/extensible.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..7982be0802c5c47490aa40a11f0443f3a6f45366 --- /dev/null +++ b/examples/schemas/extensible.schema.json @@ -0,0 +1,32 @@ +{ + "meta:license": [ + "Copyright 2017 Adobe Systems Incorporated. All rights reserved.", + "This file is licensed to you under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License. You may obtain a copy", + "of the License at http://www.apache.org/licenses/LICENSE-2.0" + ], + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "https://example.com/schemas/extensible", + "title": "Extensible", + "description": "This is an extensible schema. It has `definitions`, that can be used in other schemas", + "type": "object", + "meta:extensible": true, + "definitions": { + "first": { + "properties": { + "foo": { + "type": "string", + "description": "A unique identifier given to every addressable thing." + } + } + }, + "second": { + "properties": { + "bar": { + "type": "string", + "description": "A unique identifier given to every addressable thing." + } + } + } + } +} \ No newline at end of file diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index e96a4bc602108160c6f1a84e733fd5583c528400..9d70defbf39d6d48aefbb63e80c25a25ea478c64 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -30,11 +30,11 @@ function assoc(obj, key, value) { } function schemaProps(schema, schemaPath, filename) { - console.log(_.keys(schema.properties)); + console.log(_.keys(schema)); return { // if there are definitions, but no properties - abstract: schema.definitions && _.keys(schema.properties).length === 0, - extensible: true, + abstract: schema.definitions !== undefined && _.keys(schema.properties).length === 0, + extensible: schema.definitions !== undefined || schema['meta:extensible'] === true, custom: true, original: filename.substr(schemaPath.length).substr(1), };