@adobe/jsonschema2md 6.1.4 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.js → .eslintrc.cjs} +3 -17
- package/{.releaserc.js → .releaserc.cjs} +0 -0
- package/CHANGELOG.md +41 -0
- package/README.md +1 -1
- package/cli.js +1 -1
- package/lib/formatInfo.js +17 -19
- package/lib/formattingTools.js +6 -8
- package/lib/index.js +176 -81
- package/lib/keywords.js +2 -4
- package/lib/locales/nl-NL.json +182 -0
- package/lib/locales/update.js +2 -2
- package/lib/markdownBuilder.js +62 -44
- package/lib/readmeBuilder.js +15 -15
- package/lib/schemaProxy.js +32 -26
- package/lib/symbols.js +14 -2
- package/lib/traverseSchema.js +5 -5
- package/lib/writeMarkdown.js +87 -41
- package/lib/writeSchema.js +46 -21
- package/package.json +41 -30
- package/types/api.d.ts +72 -0
- package/types/formatInfo.d.ts +19 -0
- package/types/formattingTools.d.ts +2 -0
- package/types/index.d.ts +75 -0
- package/types/keywords.d.ts +2 -0
- package/types/markdownBuilder.d.ts +8 -0
- package/types/readmeBuilder.d.ts +5 -0
- package/types/schemaProxy.d.ts +1 -0
- package/types/symbols.d.ts +11 -0
- package/types/traverseSchema.d.ts +6 -0
- package/types/writeMarkdown.d.ts +56 -0
- package/types/writeSchema.d.ts +19 -0
- package/.circleci/config.yml +0 -83
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- package/.github/workflows/semantic-release.yaml +0 -55
- package/.github/workflows/semver-check.yaml +0 -16
- package/.renovaterc.json +0 -3
- package/.tidelift.yml +0 -32
- package/crowdin.yml +0 -4
- package/examples/abstract.md +0 -3
- package/examples/docs/README.md +0 -121
- package/examples/docs/abstract-definitions-first-properties-foo.md +0 -15
- package/examples/docs/abstract-definitions-first-properties-nonfoo.md +0 -23
- package/examples/docs/abstract-definitions-first.md +0 -66
- package/examples/docs/abstract-definitions-second-properties-bar.md +0 -15
- package/examples/docs/abstract-definitions-second.md +0 -39
- package/examples/docs/abstract-definitions.md +0 -15
- package/examples/docs/abstract.md +0 -104
- package/examples/docs/arrays-properties-boollist-items.md +0 -15
- package/examples/docs/arrays-properties-boollist.md +0 -19
- package/examples/docs/arrays-properties-coordinatelist-items-items.md +0 -21
- package/examples/docs/arrays-properties-coordinatelist-items.md +0 -21
- package/examples/docs/arrays-properties-coordinatelist.md +0 -19
- package/examples/docs/arrays-properties-intlist-items.md +0 -15
- package/examples/docs/arrays-properties-intlist.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-0-properties-foo.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-0.md +0 -45
- package/examples/docs/arrays-properties-jointypelist-items-oneof-1-properties-bar.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-1.md +0 -45
- package/examples/docs/arrays-properties-jointypelist-items.md +0 -21
- package/examples/docs/arrays-properties-jointypelist.md +0 -15
- package/examples/docs/arrays-properties-list-items.md +0 -15
- package/examples/docs/arrays-properties-list.md +0 -15
- package/examples/docs/arrays-properties-listlist-items.md +0 -15
- package/examples/docs/arrays-properties-listlist.md +0 -15
- package/examples/docs/arrays-properties-numlist-items.md +0 -19
- package/examples/docs/arrays-properties-numlist.md +0 -19
- package/examples/docs/arrays-properties-objectlist-items-properties-a.md +0 -15
- package/examples/docs/arrays-properties-objectlist-items-properties-b.md +0 -15
- package/examples/docs/arrays-properties-objectlist-items.md +0 -58
- package/examples/docs/arrays-properties-objectlist.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist-items-items.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist-items.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist.md +0 -15
- package/examples/docs/arrays-properties-tuple-items-negative-integer.md +0 -19
- package/examples/docs/arrays-properties-tuple-items-positive-integer.md +0 -19
- package/examples/docs/arrays-properties-tuple-zero.md +0 -23
- package/examples/docs/arrays-properties-tuple.md +0 -21
- package/examples/docs/arrays.md +0 -240
- package/examples/docs/complex-additionalproperties.md +0 -15
- package/examples/docs/complex-patternproperties-int.md +0 -15
- package/examples/docs/complex-patternproperties-str.md +0 -15
- package/examples/docs/complex-patternproperties.md +0 -15
- package/examples/docs/complex-properties-and-allof-0.md +0 -19
- package/examples/docs/complex-properties-and-allof-1.md +0 -19
- package/examples/docs/complex-properties-and.md +0 -21
- package/examples/docs/complex-properties-or-anyof-0.md +0 -15
- package/examples/docs/complex-properties-or-anyof-1.md +0 -19
- package/examples/docs/complex-properties-or.md +0 -21
- package/examples/docs/complex-properties-reflocalfiledef.md +0 -39
- package/examples/docs/complex-properties-refnestedobj-properties-refobj.md +0 -39
- package/examples/docs/complex-properties-refnestedobj.md +0 -39
- package/examples/docs/complex-properties-refobj.md +0 -39
- package/examples/docs/complex-properties-xor-oneof-0.md +0 -19
- package/examples/docs/complex-properties-xor-oneof-1.md +0 -19
- package/examples/docs/complex-properties-xor.md +0 -21
- package/examples/docs/complex.md +0 -285
- package/examples/docs/constants-properties-hello.md +0 -23
- package/examples/docs/constants.md +0 -47
- package/examples/docs/custom-allof-0.md +0 -15
- package/examples/docs/custom-allof-1.md +0 -39
- package/examples/docs/custom-allof-2.md +0 -39
- package/examples/docs/custom-definitions-first-properties-foo.md +0 -15
- package/examples/docs/custom-definitions-first-properties.md +0 -15
- package/examples/docs/custom-definitions-first.md +0 -39
- package/examples/docs/custom-definitions-second-properties-bar.md +0 -15
- package/examples/docs/custom-definitions-second-properties.md +0 -15
- package/examples/docs/custom-definitions-second.md +0 -39
- package/examples/docs/custom-definitions.md +0 -15
- package/examples/docs/custom.md +0 -85
- package/examples/docs/deepextending-allof-0.md +0 -49
- package/examples/docs/deepextending-allof-1.md +0 -89
- package/examples/docs/deepextending-allof-3.md +0 -39
- package/examples/docs/deepextending-definitions-fourth-properties-hey.md +0 -15
- package/examples/docs/deepextending-definitions-fourth-properties.md +0 -15
- package/examples/docs/deepextending-definitions-fourth.md +0 -39
- package/examples/docs/deepextending-definitions.md +0 -15
- package/examples/docs/deepextending.md +0 -57
- package/examples/docs/definitions-definitions-myid-properties-id-1.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties-id.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties-metaid.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties.md +0 -15
- package/examples/docs/definitions-definitions-myid.md +0 -89
- package/examples/docs/definitions-definitions.md +0 -15
- package/examples/docs/definitions.md +0 -117
- package/examples/docs/enums-properties-enumerated-nested-properties-test.md +0 -25
- package/examples/docs/enums-properties-enumerated-nested.md +0 -49
- package/examples/docs/enums-properties-hello.md +0 -24
- package/examples/docs/enums.md +0 -67
- package/examples/docs/example-properties-bar.md +0 -25
- package/examples/docs/example-properties-foo.md +0 -21
- package/examples/docs/example.md +0 -83
- package/examples/docs/examples-properties-bar.md +0 -25
- package/examples/docs/examples-properties-foo.md +0 -21
- package/examples/docs/examples.md +0 -90
- package/examples/docs/extending-definitions-third-properties-baaaz.md +0 -21
- package/examples/docs/extending-definitions-third.md +0 -45
- package/examples/docs/extending-definitions.md +0 -15
- package/examples/docs/extending.md +0 -61
- package/examples/docs/extensible-definitions-first-properties-foo.md +0 -21
- package/examples/docs/extensible-definitions-first-properties.md +0 -15
- package/examples/docs/extensible-definitions-first.md +0 -45
- package/examples/docs/extensible-definitions-second-properties-bar.md +0 -25
- package/examples/docs/extensible-definitions-second-properties.md +0 -15
- package/examples/docs/extensible-definitions-second.md +0 -49
- package/examples/docs/extensible-definitions.md +0 -15
- package/examples/docs/extensible.md +0 -93
- package/examples/docs/identifiable-properties-id.md +0 -19
- package/examples/docs/identifiable.md +0 -43
- package/examples/docs/join-oneof-0-not-oneof-0-properties-foo.md +0 -21
- package/examples/docs/join-oneof-0-not-oneof-0.md +0 -45
- package/examples/docs/join-oneof-0-not-oneof-1-properties-bar.md +0 -21
- package/examples/docs/join-oneof-0-not-oneof-1.md +0 -45
- package/examples/docs/join-oneof-0-not.md +0 -21
- package/examples/docs/join-oneof-0.md +0 -23
- package/examples/docs/join-oneof-1-allof-0-properties-foo.md +0 -21
- package/examples/docs/join-oneof-1-allof-0.md +0 -45
- package/examples/docs/join-oneof-1.md +0 -19
- package/examples/docs/join-oneof-2-anyof-0-properties-bar.md +0 -21
- package/examples/docs/join-oneof-2-anyof-0.md +0 -45
- package/examples/docs/join-oneof-2.md +0 -19
- package/examples/docs/join.md +0 -33
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-patternproperties-.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-patternproperties.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-properties-id.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators.md +0 -58
- package/examples/docs/nestedobj-properties-settings.md +0 -39
- package/examples/docs/nestedobj.md +0 -39
- package/examples/docs/pattern-patternproperties-0-9.md +0 -21
- package/examples/docs/pattern-patternproperties.md +0 -15
- package/examples/docs/pattern.md +0 -45
- package/examples/docs/simple-properties-id.md +0 -19
- package/examples/docs/simple.md +0 -43
- package/examples/docs/simpletypes-properties-integer_threes.md +0 -23
- package/examples/docs/simpletypes-properties-interger_constrained.md +0 -19
- package/examples/docs/simpletypes-properties-interger_unconstrained.md +0 -15
- package/examples/docs/simpletypes-properties-number_constrained.md +0 -19
- package/examples/docs/simpletypes-properties-number_unconstrained.md +0 -15
- package/examples/docs/simpletypes-properties-string_date.md +0 -19
- package/examples/docs/simpletypes-properties-string_email.md +0 -19
- package/examples/docs/simpletypes-properties-string_hostname.md +0 -19
- package/examples/docs/simpletypes-properties-string_ipv4.md +0 -19
- package/examples/docs/simpletypes-properties-string_ipv6.md +0 -19
- package/examples/docs/simpletypes-properties-string_length.md +0 -31
- package/examples/docs/simpletypes-properties-string_pattern-metaenum.md +0 -15
- package/examples/docs/simpletypes-properties-string_pattern.md +0 -39
- package/examples/docs/simpletypes-properties-string_pattern_noexample.md +0 -25
- package/examples/docs/simpletypes-properties-string_pattern_singleexample.md +0 -31
- package/examples/docs/simpletypes-properties-string_unconstrained.md +0 -21
- package/examples/docs/simpletypes-properties-string_uri.md +0 -19
- package/examples/docs/simpletypes-properties-yesno.md +0 -15
- package/examples/docs/simpletypes.md +0 -455
- package/examples/docs/stabilizing-properties-id.md +0 -19
- package/examples/docs/stabilizing.md +0 -43
- package/examples/docs/subdir-allof-0.md +0 -43
- package/examples/docs/subdir-definitions-content-properties-id.md +0 -19
- package/examples/docs/subdir-definitions-content-properties.md +0 -15
- package/examples/docs/subdir-definitions-content.md +0 -43
- package/examples/docs/subdir-definitions.md +0 -15
- package/examples/docs/subdir.md +0 -55
- package/examples/docs/typearrays-properties-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-number-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-number.md +0 -15
- package/examples/docs/typearrays.md +0 -96
- package/examples/docsWithoutHeader/arrays.schema.md +0 -254
- package/examples/generated-schemas/abstract.schema.json +0 -1
- package/examples/generated-schemas/arrays.schema.json +0 -1
- package/examples/generated-schemas/complex.schema.json +0 -1
- package/examples/generated-schemas/constants.schema.json +0 -1
- package/examples/generated-schemas/custom.schema.json +0 -1
- package/examples/generated-schemas/deepextending.schema.json +0 -1
- package/examples/generated-schemas/definitions.schema.json +0 -1
- package/examples/generated-schemas/enums.schema.json +0 -1
- package/examples/generated-schemas/example.schema.json +0 -1
- package/examples/generated-schemas/examples.schema.json +0 -1
- package/examples/generated-schemas/extending.schema.json +0 -1
- package/examples/generated-schemas/extensible.schema.json +0 -1
- package/examples/generated-schemas/identifiable.schema.json +0 -1
- package/examples/generated-schemas/join.schema.json +0 -1
- package/examples/generated-schemas/nestedobj.schema.json +0 -1
- package/examples/generated-schemas/pattern.schema.json +0 -1
- package/examples/generated-schemas/simple.schema.json +0 -1
- package/examples/generated-schemas/simpletypes.schema.json +0 -1
- package/examples/generated-schemas/stabilizing.schema.json +0 -1
- package/examples/generated-schemas/subdir/subdir.schema.json +0 -1
- package/examples/generated-schemas/typearrays.schema.json +0 -1
- package/examples/schemas/abstract.schema.json +0 -44
- package/examples/schemas/arrays.schema.json +0 -185
- package/examples/schemas/complex.schema.json +0 -123
- package/examples/schemas/constants.schema.json +0 -25
- package/examples/schemas/custom.schema.json +0 -41
- package/examples/schemas/deepextending.schema.json +0 -37
- package/examples/schemas/definitions.description.md +0 -17
- package/examples/schemas/definitions.schema.json +0 -46
- package/examples/schemas/enums.schema.json +0 -42
- package/examples/schemas/example.example.1.json +0 -4
- package/examples/schemas/example.schema.json +0 -29
- package/examples/schemas/examples.example.1.json +0 -4
- package/examples/schemas/examples.example.2.json +0 -4
- package/examples/schemas/examples.schema.json +0 -32
- package/examples/schemas/extending.schema.json +0 -38
- package/examples/schemas/extensible.schema.json +0 -38
- package/examples/schemas/identifiable.schema.json +0 -22
- package/examples/schemas/join.schema.json +0 -88
- package/examples/schemas/nestedobj.schema.json +0 -35
- package/examples/schemas/pattern.schema.json +0 -21
- package/examples/schemas/simple.schema.json +0 -22
- package/examples/schemas/simpletypes.schema.json +0 -151
- package/examples/schemas/stabilizing.schema.json +0 -23
- package/examples/schemas/subdir/subdir.schema.json +0 -29
- package/examples/schemas/typearrays.schema.json +0 -39
- package/examples/status.md +0 -3
- package/test/api.test.js +0 -55
- package/test/cyclicSchemaIntegration.test.js +0 -87
- package/test/fixtures/additionalprops/additionalprops.schema.json +0 -6
- package/test/fixtures/additionalprops/arrays.schema.json +0 -9
- package/test/fixtures/arrays/arrays.schema.json +0 -201
- package/test/fixtures/arrays/tuple.schema.json +0 -35
- package/test/fixtures/content/html.schema.json +0 -5
- package/test/fixtures/content/jwt.schema.json +0 -26
- package/test/fixtures/content/png.schema.json +0 -6
- package/test/fixtures/cyclic/one.description.md +0 -1
- package/test/fixtures/cyclic/one.example.1.json +0 -1
- package/test/fixtures/cyclic/one.schema.json +0 -17
- package/test/fixtures/cyclic/three.schema.json +0 -17
- package/test/fixtures/cyclic/two.schema.json +0 -17
- package/test/fixtures/deadref/deadref.schema.json +0 -6
- package/test/fixtures/enums/arrayenums.schema.json +0 -29
- package/test/fixtures/enums/enums.schema.json +0 -29
- package/test/fixtures/example/example.schema.json +0 -52
- package/test/fixtures/format/format.schema.json +0 -25
- package/test/fixtures/identifiable/identifiable.schema.json +0 -22
- package/test/fixtures/not/not.schema.json +0 -7
- package/test/fixtures/null/null.schema.json +0 -14
- package/test/fixtures/nullable/array.schema.json +0 -17
- package/test/fixtures/readme-1/abstract.schema.json +0 -50
- package/test/fixtures/readme-1/complex.schema.json +0 -118
- package/test/fixtures/readme-1/simple.schema.json +0 -30
- package/test/fixtures/skipproperties/complete.schema.json +0 -29
- package/test/fixtures/stringformats/simpletypes.schema.json +0 -211
- package/test/fixtures/title/meta.schema.json +0 -53
- package/test/fixtures/type/button.schema.json +0 -28
- package/test/fixtures/type/type.schema.json +0 -20
- package/test/fixtures/types/merged.schema.json +0 -10
- package/test/fixtures/types/object.schema.json +0 -3
- package/test/fixtures/types/objectorarray.schema.json +0 -3
- package/test/fixtures/types/undefined.schema.json +0 -3
- package/test/fixtures/types/wrong.schema.json +0 -6
- package/test/formatting.test.js +0 -59
- package/test/markdownBuilder.test.js +0 -441
- package/test/readmeBuilder.test.js +0 -106
- package/test/schemaProxy.test.js +0 -187
- package/test/testUtils.js +0 -88
- package/test/testintegration.test.js +0 -65
- package/test/traverseSchema.test.js +0 -111
- package/test/zSchemaCoverage.test.js +0 -186
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
/* eslint-env mocha */
|
|
13
|
-
/* eslint-disable no-unused-expressions */
|
|
14
|
-
const { assertMarkdown, loadschemas } = require('./testUtils');
|
|
15
|
-
|
|
16
|
-
const build = require('../lib/markdownBuilder');
|
|
17
|
-
|
|
18
|
-
describe('Testing Markdown Builder: content', () => {
|
|
19
|
-
let results;
|
|
20
|
-
|
|
21
|
-
before(async () => {
|
|
22
|
-
const schemas = await loadschemas('content');
|
|
23
|
-
const builder = build({ header: false });
|
|
24
|
-
results = builder(schemas);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('PNG Schema looks OK', () => {
|
|
28
|
-
assertMarkdown(results.png)
|
|
29
|
-
.contains('**encoding**: the string content must be using the base64 content encoding.');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('HTML Schema looks OK', () => {
|
|
33
|
-
assertMarkdown(results.html)
|
|
34
|
-
.contains('**media type**: the media type of the contents of this string is: `text/html`');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('JWT Schema looks OK', () => {
|
|
38
|
-
assertMarkdown(results.jwt)
|
|
39
|
-
.contains('**schema**: the contents of this string should follow this schema: [JSON Web Token](jwt-json-web-token.md "check type definition")')
|
|
40
|
-
.contains('**media type**: the media type of the contents of this string is: `application/jwt`');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('Testing Markdown Builder: not', () => {
|
|
45
|
-
let results;
|
|
46
|
-
|
|
47
|
-
before(async () => {
|
|
48
|
-
const schemas = await loadschemas('not');
|
|
49
|
-
const builder = build({ header: false });
|
|
50
|
-
results = builder(schemas);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('Not Schema looks OK', () => {
|
|
54
|
-
assertMarkdown(results.not)
|
|
55
|
-
.fuzzy`## Not true Type
|
|
56
|
-
|
|
57
|
-
merged type ([Not true](not.md))
|
|
58
|
-
|
|
59
|
-
not
|
|
60
|
-
|
|
61
|
-
* [True](not-true.md "check type definition")`;
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('Testing Markdown Builder: nullable', () => {
|
|
66
|
-
let results;
|
|
67
|
-
|
|
68
|
-
before(async () => {
|
|
69
|
-
const schemas = await loadschemas('nullable');
|
|
70
|
-
const builder = build({ header: false });
|
|
71
|
-
results = builder(schemas);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('Nullable Array Type Schema looks OK', () => {
|
|
75
|
-
assertMarkdown(results.array)
|
|
76
|
-
.fuzzy`| [sampleProp](#sampleprop) | \`string\` | Required | can be null | [Type Array Repro](array-properties-sample-property.md "http://example.com/type-array-repro.json#/properties/sampleProp") |`;
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('Testing Markdown Builder: title', () => {
|
|
81
|
-
let results;
|
|
82
|
-
|
|
83
|
-
before(async () => {
|
|
84
|
-
const schemas = await loadschemas('title');
|
|
85
|
-
const builder = build({ header: false });
|
|
86
|
-
results = builder(schemas);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('Meta Schema looks OK', () => {
|
|
90
|
-
assertMarkdown(results.meta)
|
|
91
|
-
.fuzzy`defined in: [Meta](meta-definitions-meta-properties-title.md "https://ns.adobe.com/helix/pipeline/meta#/definitions/meta/properties/title")`;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('Title Schema looks OK', () => {
|
|
95
|
-
assertMarkdown(results['meta-definitions-meta-properties-title'])
|
|
96
|
-
.fuzzy`## title Type\n\n\`string\`\n`;
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('Testing Markdown Builder: type', () => {
|
|
101
|
-
let results;
|
|
102
|
-
|
|
103
|
-
before(async () => {
|
|
104
|
-
const schemas = await loadschemas('type');
|
|
105
|
-
const builder = build({ header: false });
|
|
106
|
-
results = builder(schemas);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('Type Schema looks OK', () => {
|
|
110
|
-
assertMarkdown(results.type)
|
|
111
|
-
.fuzzy`The type of the Button (not used for anchors).`
|
|
112
|
-
.print();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('Button Schema looks OK', () => {
|
|
116
|
-
assertMarkdown(results.button)
|
|
117
|
-
.fuzzy`## Button Type`
|
|
118
|
-
.print();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('Testing Markdown Builder: format', () => {
|
|
123
|
-
let results;
|
|
124
|
-
|
|
125
|
-
before(async () => {
|
|
126
|
-
const schemas = await loadschemas('format');
|
|
127
|
-
const builder = build({ header: false });
|
|
128
|
-
results = builder(schemas);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('Format Schema looks OK', () => {
|
|
132
|
-
assertMarkdown(results.format)
|
|
133
|
-
.fuzzy`Formatting used to display the date.`;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('Format Schema has JSON examples', () => {
|
|
137
|
-
assertMarkdown(results.format)
|
|
138
|
-
.fuzzy`## Properties Examples
|
|
139
|
-
|
|
140
|
-
\`\`\`json
|
|
141
|
-
{
|
|
142
|
-
"format": "Coolness",
|
|
143
|
-
"value": "Maximum"
|
|
144
|
-
}
|
|
145
|
-
\`\`\``;
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe('Testing Markdown Builder: YAML examples', () => {
|
|
150
|
-
let results;
|
|
151
|
-
|
|
152
|
-
before(async () => {
|
|
153
|
-
const schemas = await loadschemas('format');
|
|
154
|
-
const builder = build({ header: false, exampleFormat: 'yaml' });
|
|
155
|
-
results = builder(schemas);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('Format Schema has JSON examples', () => {
|
|
159
|
-
assertMarkdown(results.format)
|
|
160
|
-
.fuzzy`## Properties Examples
|
|
161
|
-
|
|
162
|
-
\`\`\`yaml
|
|
163
|
-
format: Coolness
|
|
164
|
-
value: Maximum
|
|
165
|
-
|
|
166
|
-
\`\`\``;
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe('Testing Markdown Builder: enums', () => {
|
|
171
|
-
let results;
|
|
172
|
-
|
|
173
|
-
before(async () => {
|
|
174
|
-
const schemas = await loadschemas('enums');
|
|
175
|
-
const builder = build({ header: true, includeProperties: ['foo', 'bar'] });
|
|
176
|
-
results = builder(schemas);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('Enums Schema looks OK', () => {
|
|
180
|
-
assertMarkdown(results.enums)
|
|
181
|
-
.contains('| `"bas"` | from ancient Egyptian religion, an aspect of the soul |')
|
|
182
|
-
.contains('| `"baa"` | |')
|
|
183
|
-
.contains('foo: bar')
|
|
184
|
-
.contains('bar: foo')
|
|
185
|
-
.contains('**enum**: the value of this property must be equal to one of the following values:');
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('Array Enums Schema looks OK', () => {
|
|
189
|
-
assertMarkdown(results.arrayenums)
|
|
190
|
-
.contains('| `["P","M"]` | Post Meridiem? |');
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
describe('Testing Markdown Builder: null', () => {
|
|
195
|
-
let results;
|
|
196
|
-
|
|
197
|
-
before(async () => {
|
|
198
|
-
const schemas = await loadschemas('null');
|
|
199
|
-
const builder = build({ header: true });
|
|
200
|
-
results = builder(schemas);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('Null Schema looks OK', () => {
|
|
204
|
-
assertMarkdown(results.null)
|
|
205
|
-
.contains('the value must be null')
|
|
206
|
-
.contains('can be null')
|
|
207
|
-
.contains('the value of this property must be equal to:');
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe('Testing Markdown Builder: additionalprops', () => {
|
|
212
|
-
let results;
|
|
213
|
-
|
|
214
|
-
before(async () => {
|
|
215
|
-
const schemas = await loadschemas('additionalprops');
|
|
216
|
-
const builder = build({ header: true });
|
|
217
|
-
results = builder(schemas);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('Additional Properties Schema looks OK', () => {
|
|
221
|
-
assertMarkdown(results.additionalprops)
|
|
222
|
-
.contains('**maximum number of properties**: the maximum number of properties for this object is: `99`')
|
|
223
|
-
.contains('**minimum number of properties**: the minimum number of properties for this object is: `10`')
|
|
224
|
-
.has('heading > text[value="Additional Properties"]');
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('Arrays Schema looks OK', () => {
|
|
228
|
-
assertMarkdown(results.arrays)
|
|
229
|
-
.contains('**minimum number of contained items**: this array may not contain fewer than 1 items that validate against the schema: [Untitled boolean in undefined](arrays-contains.md "check type definition")')
|
|
230
|
-
.contains('**maximum number of contained items**: this array may not contain more than 9 items that validate against the schema: [Untitled boolean in undefined](arrays-contains.md "check type definition")')
|
|
231
|
-
.contains('**unique items**: all items in this array must be unique. Duplicates are not allowed.');
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('Testing Markdown Builder: types', () => {
|
|
236
|
-
let results;
|
|
237
|
-
|
|
238
|
-
before(async () => {
|
|
239
|
-
const schemas = await loadschemas('types');
|
|
240
|
-
const builder = build({ header: true });
|
|
241
|
-
results = builder(schemas);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('Object Schema looks OK', () => {
|
|
245
|
-
assertMarkdown(results.object)
|
|
246
|
-
.has('paragraph > inlineCode[value="object"]');
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('Merged Schema looks OK', () => {
|
|
250
|
-
assertMarkdown(results.merged)
|
|
251
|
-
.has('paragraph > text[value^="merged type"]');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('Multiple Typed Schema looks OK', () => {
|
|
255
|
-
assertMarkdown(results.objectorarray)
|
|
256
|
-
.has('paragraph > text[value="any of the folllowing: "]');
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it('Undefined Schema looks OKish', () => {
|
|
260
|
-
assertMarkdown(results.undefined)
|
|
261
|
-
.has('paragraph > text[value="unknown"]');
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('Wrong Schema looks OKish', () => {
|
|
265
|
-
assertMarkdown(results.wrong)
|
|
266
|
-
.has('paragraph > text[value="unknown"]');
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
describe('Testing Markdown Builder: identifiable', () => {
|
|
271
|
-
let results;
|
|
272
|
-
|
|
273
|
-
before(async () => {
|
|
274
|
-
const schemas = await loadschemas('identifiable');
|
|
275
|
-
const builder = build({ header: true });
|
|
276
|
-
results = builder(schemas);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('Identifiable Schema looks OK', () => {
|
|
280
|
-
assertMarkdown(results.identifiable)
|
|
281
|
-
.has('table > tableRow > tableCell > text[value="Identifiable"]')
|
|
282
|
-
.has('table > tableRow > tableCell > text[value="Yes"]');
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('Testing Markdown Builder: arrays', () => {
|
|
287
|
-
let results;
|
|
288
|
-
|
|
289
|
-
before(async () => {
|
|
290
|
-
const schemas = await loadschemas('arrays');
|
|
291
|
-
const builder = build({ header: true });
|
|
292
|
-
results = builder(schemas);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('Arrays Schema looks OK', () => {
|
|
296
|
-
assertMarkdown(results.arrays)
|
|
297
|
-
.contains('and all following items may follow any schema');
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it('Tuple Schema looks OK', () => {
|
|
301
|
-
assertMarkdown(results.tuple)
|
|
302
|
-
.fuzzy`
|
|
303
|
-
* is optional
|
|
304
|
-
|
|
305
|
-
* Type: an array where each item follows the corresponding schema in the following list:
|
|
306
|
-
|
|
307
|
-
1. [Positive Integer](tuple-properties-tuple-items-positive-integer.md "check type definition")
|
|
308
|
-
|
|
309
|
-
2. [Negative Integer](tuple-properties-tuple-items-negative-integer.md "check type definition")
|
|
310
|
-
|
|
311
|
-
3. and all following items must follow the schema: [Zero](tuple-properties-tuple-zero.md "check type definition")
|
|
312
|
-
|
|
313
|
-
* cannot be null
|
|
314
|
-
|
|
315
|
-
* defined in: [Arrays](tuple-properties-tuple.md "https://example.com/schemas/arrays#/properties/tuple")
|
|
316
|
-
|
|
317
|
-
### tuple Type
|
|
318
|
-
|
|
319
|
-
an array where each item follows the corresponding schema in the following list:
|
|
320
|
-
|
|
321
|
-
1. [Positive Integer](tuple-properties-tuple-items-positive-integer.md "check type definition")
|
|
322
|
-
|
|
323
|
-
2. [Negative Integer](tuple-properties-tuple-items-negative-integer.md "check type definition")
|
|
324
|
-
|
|
325
|
-
3. and all following items must follow the schema: [Zero](tuple-properties-tuple-zero.md "check type definition")`;
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
describe('Testing Markdown Builder: stringformats', () => {
|
|
330
|
-
let results;
|
|
331
|
-
|
|
332
|
-
before(async () => {
|
|
333
|
-
const schemas = await loadschemas('stringformats');
|
|
334
|
-
const builder = build({ header: true });
|
|
335
|
-
results = builder(schemas);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('Simple Types Schema looks OK', () => {
|
|
339
|
-
assertMarkdown(results.simpletypes)
|
|
340
|
-
.contains('maximum (exclusive)')
|
|
341
|
-
.contains('minimum (exclusive)')
|
|
342
|
-
.fuzzy`### string_pattern Constraints
|
|
343
|
-
|
|
344
|
-
**pattern**: the string must match the following regular expression: ${null}
|
|
345
|
-
\`\`\`regexp
|
|
346
|
-
^ba.$
|
|
347
|
-
`
|
|
348
|
-
.fuzzy`### string_date Constraints
|
|
349
|
-
|
|
350
|
-
**date time**: the string must be a date time string, according to [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339 "check the specification")
|
|
351
|
-
`;
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
describe('Testing Markdown Builder: readme-1', () => {
|
|
356
|
-
let results;
|
|
357
|
-
|
|
358
|
-
before(async () => {
|
|
359
|
-
const schemas = await loadschemas('readme-1');
|
|
360
|
-
const builder = build({ header: true, links: { abstract: 'fooabstract.html' } });
|
|
361
|
-
results = builder(schemas);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it('Abstract Schema looks OK', () => {
|
|
365
|
-
assertMarkdown(results.abstract)
|
|
366
|
-
.equals('heading > text', { type: 'text', value: 'Abstract Schema' })
|
|
367
|
-
.contains('cannot be read or written')
|
|
368
|
-
.contains('nonfoo Access Restrictions')
|
|
369
|
-
.contains('bar Access Restrictions')
|
|
370
|
-
.contains('### foo Access Restrictions')
|
|
371
|
-
.fuzzy`
|
|
372
|
-
## Definitions group second
|
|
373
|
-
|
|
374
|
-
Reference this group by using
|
|
375
|
-
|
|
376
|
-
\`\`\`json
|
|
377
|
-
{"$ref":"https://example.com/schemas/abstract#/$defs/second"}
|
|
378
|
-
\`\`\``
|
|
379
|
-
.fuzzy`
|
|
380
|
-
\`bar\`
|
|
381
|
-
|
|
382
|
-
* is optional
|
|
383
|
-
|
|
384
|
-
* Type: \`string\`
|
|
385
|
-
|
|
386
|
-
* cannot be null
|
|
387
|
-
|
|
388
|
-
* defined in: [Abstract](abstract-defs-second-properties-bar.md "https://example.com/schemas/abstract#/$defs/second/properties/bar")
|
|
389
|
-
|
|
390
|
-
#### bar Type
|
|
391
|
-
|
|
392
|
-
\`string\``
|
|
393
|
-
.contains('fooabstract.html');
|
|
394
|
-
// .inspect()
|
|
395
|
-
// .print();
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it('Complex Schema looks OK', () => {
|
|
399
|
-
assertMarkdown(results.complex)
|
|
400
|
-
.contains('Read only')
|
|
401
|
-
.contains('# Complex References Schema');
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it('Simple Schema looks OK', () => {
|
|
405
|
-
assertMarkdown(results.simple)
|
|
406
|
-
.contains('Deprecated')
|
|
407
|
-
.contains('"Simply Untitled"')
|
|
408
|
-
.contains('Write only')
|
|
409
|
-
.contains('> This should be here')
|
|
410
|
-
.contains('living a simple life')
|
|
411
|
-
.contains('# Simple Schema');
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
describe('Testing Markdown Builder: Skip properties', () => {
|
|
416
|
-
let schemas;
|
|
417
|
-
|
|
418
|
-
before(async () => {
|
|
419
|
-
schemas = await loadschemas('skipproperties');
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('Skipped properties exist', () => {
|
|
423
|
-
const builder = build({});
|
|
424
|
-
const results = builder(schemas);
|
|
425
|
-
|
|
426
|
-
assertMarkdown(results.complete)
|
|
427
|
-
.contains('### bar Type')
|
|
428
|
-
.contains('| Property | Type | Required |')
|
|
429
|
-
.contains('* defined in: [Complete JSON Schema]');
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
it('Skips the expected properties', () => {
|
|
433
|
-
const builder = build({ skipProperties: ['typesection', 'definedinfact', 'proptable'] });
|
|
434
|
-
const results = builder(schemas);
|
|
435
|
-
|
|
436
|
-
assertMarkdown(results.complete)
|
|
437
|
-
.doesNotContain('### bar Type')
|
|
438
|
-
.doesNotContain('| Property | Type | Required |')
|
|
439
|
-
.doesNotContain('- defined in: [Complete JSON Schema]');
|
|
440
|
-
});
|
|
441
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
/* eslint-env mocha */
|
|
13
|
-
/* eslint-disable no-unused-expressions */
|
|
14
|
-
const assert = require('assert');
|
|
15
|
-
const { assertMarkdown, loadschemas } = require('./testUtils');
|
|
16
|
-
|
|
17
|
-
const build = require('../lib/readmeBuilder');
|
|
18
|
-
const { loader } = require('../lib/schemaProxy');
|
|
19
|
-
|
|
20
|
-
describe('Testing Readme Builder', () => {
|
|
21
|
-
it('Readme Builder is a function', () => {
|
|
22
|
-
assert.equal(typeof build, 'function');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Readme Builder does nothing when not required', () => {
|
|
26
|
-
const builder = build({ readme: false });
|
|
27
|
-
assert.equal(builder(), null);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('Readme Builder builds a README for type', async () => {
|
|
31
|
-
const schemas = await loadschemas('type');
|
|
32
|
-
const builder = build({ readme: true });
|
|
33
|
-
const result = builder(schemas);
|
|
34
|
-
|
|
35
|
-
assertMarkdown(result)
|
|
36
|
-
.contains('# README')
|
|
37
|
-
.print();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('Readme Builder builds a medium README for multiple Schemas', async () => {
|
|
41
|
-
const schemas = await loadschemas('readme-1');
|
|
42
|
-
const builder = build({ readme: true });
|
|
43
|
-
const result = builder(schemas);
|
|
44
|
-
|
|
45
|
-
assertMarkdown(result)
|
|
46
|
-
.contains('# README')
|
|
47
|
-
.contains('The schemas linked above')
|
|
48
|
-
.doesNotContain('complex-properties-definitionnamed.md')
|
|
49
|
-
.fuzzy`
|
|
50
|
-
## Top-level Schemas
|
|
51
|
-
|
|
52
|
-
* [Abstract](./abstract.md "This is an abstract schema") – ${null}
|
|
53
|
-
* [Complex References](./complex.md "This is an example schema that uses types defined in other schemas") – ${null}
|
|
54
|
-
* [Simple](./simple.md "This is a very simple example of a JSON schema") – ${null}
|
|
55
|
-
`;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('Readme Builder builds a small README for a single Schema', () => {
|
|
59
|
-
const builder = build({ readme: true });
|
|
60
|
-
const schemaloader = loader();
|
|
61
|
-
const schemas = [
|
|
62
|
-
schemaloader({
|
|
63
|
-
type: 'object',
|
|
64
|
-
title: 'Test Schema',
|
|
65
|
-
description: 'Not much',
|
|
66
|
-
properties: {
|
|
67
|
-
foo: {
|
|
68
|
-
const: 1,
|
|
69
|
-
},
|
|
70
|
-
obj: {
|
|
71
|
-
type: 'object',
|
|
72
|
-
title: 'An Object',
|
|
73
|
-
},
|
|
74
|
-
arr: {
|
|
75
|
-
type: 'array',
|
|
76
|
-
title: 'An Array',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
}, 'example.schema.json'),
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
const result = builder(schemas);
|
|
83
|
-
// eslint-disable-next-line no-unused-expressions
|
|
84
|
-
assertMarkdown(result)
|
|
85
|
-
.contains('# README')
|
|
86
|
-
.matches(/Top-level Schemas/)
|
|
87
|
-
.has('heading > text')
|
|
88
|
-
.equals('heading > text', {
|
|
89
|
-
type: 'text',
|
|
90
|
-
value: 'README',
|
|
91
|
-
})
|
|
92
|
-
.fuzzy`# README
|
|
93
|
-
|
|
94
|
-
## Top-level Schemas
|
|
95
|
-
|
|
96
|
-
* [Test Schema](./example.md "Not much") – ${undefined}
|
|
97
|
-
|
|
98
|
-
## Other Schemas
|
|
99
|
-
|
|
100
|
-
### Objects
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
### Arrays`;
|
|
105
|
-
});
|
|
106
|
-
});
|