@adobe/jsonschema2md 6.1.4 → 7.0.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 +26 -0
- 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/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 +39 -28
- 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
|
@@ -19,13 +19,13 @@ module.exports = {
|
|
|
19
19
|
// eslintrc files in parent directories.
|
|
20
20
|
root: true,
|
|
21
21
|
parserOptions: {
|
|
22
|
-
sourceType: '
|
|
23
|
-
ecmaVersion:
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
ecmaVersion: 2020,
|
|
24
24
|
},
|
|
25
25
|
plugins: [
|
|
26
26
|
'header',
|
|
27
27
|
],
|
|
28
|
-
extends: '
|
|
28
|
+
extends: '@adobe/helix',
|
|
29
29
|
rules: {
|
|
30
30
|
strict: 0,
|
|
31
31
|
|
|
@@ -47,19 +47,5 @@ module.exports = {
|
|
|
47
47
|
argsIgnorePattern: '^_.*$',
|
|
48
48
|
caughtErrorsIgnorePattern: '^_.*$',
|
|
49
49
|
}],
|
|
50
|
-
|
|
51
|
-
// enforce license header (todo: improve plugin to support patterns for multi-lines)
|
|
52
|
-
'header/header': [2, 'block', ['',
|
|
53
|
-
{ pattern: ' * Copyright \\d{4} Adobe\\. All rights reserved\\.', template: ' * Copyright 2021 Adobe. All rights reserved.' },
|
|
54
|
-
' * This file is licensed to you under the Apache License, Version 2.0 (the "License");',
|
|
55
|
-
' * you may not use this file except in compliance with the License. You may obtain a copy',
|
|
56
|
-
' * of the License at http://www.apache.org/licenses/LICENSE-2.0',
|
|
57
|
-
' *',
|
|
58
|
-
' * Unless required by applicable law or agreed to in writing, software distributed under',
|
|
59
|
-
' * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS',
|
|
60
|
-
' * OF ANY KIND, either express or implied. See the License for the specific language',
|
|
61
|
-
' * governing permissions and limitations under the License.',
|
|
62
|
-
' ',
|
|
63
|
-
]],
|
|
64
50
|
},
|
|
65
51
|
};
|
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# [7.0.0](https://github.com/adobe/jsonschema2md/compare/v6.1.4...v7.0.0) (2022-02-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-log to v6 ([#363](https://github.com/adobe/jsonschema2md/issues/363)) ([6298ed2](https://github.com/adobe/jsonschema2md/commit/6298ed2808d4797429d907159c762ac79d19627b))
|
|
7
|
+
* **index:** remove reference to single input file ([7324427](https://github.com/adobe/jsonschema2md/commit/732442777d067e6a9091a6af50e21fcfca9fbd47)), closes [#386](https://github.com/adobe/jsonschema2md/issues/386)
|
|
8
|
+
* **symbols:** tweak exports ([d31ab23](https://github.com/adobe/jsonschema2md/commit/d31ab239385cbe51eede6ff794fdfa58d7109717))
|
|
9
|
+
* **tests:** use fileToURLPath for dirname ([352d032](https://github.com/adobe/jsonschema2md/commit/352d032dccbc16e094359ae7e0d6d44e8ffd7863))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Code Refactoring
|
|
13
|
+
|
|
14
|
+
* use esm ([a628755](https://github.com/adobe/jsonschema2md/commit/a6287553800fbe98396af193ebf0a56ca3cabde0))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **api:** change shape of input and output data ([797090f](https://github.com/adobe/jsonschema2md/commit/797090fce370296ddb7c3c3fe3605330fcde02ff))
|
|
20
|
+
* **api:** create typescript declaration for api ([92426f9](https://github.com/adobe/jsonschema2md/commit/92426f9038c5b9e04fc6ea33fd34fbea7de6a29b))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
* `jsonschema2md` now uses ECMAScript Modules (`import`/`export`) instead of CommonJS Modules (`require`/`exports`). This was driven by the desire to stay up to date with dependencies that switched to ESM.
|
|
26
|
+
|
|
1
27
|
## [6.1.4](https://github.com/adobe/jsonschema2md/compare/v6.1.3...v6.1.4) (2021-09-20)
|
|
2
28
|
|
|
3
29
|
|
package/cli.js
CHANGED
package/lib/formatInfo.js
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { unified } from 'unified';
|
|
15
|
+
import parse from 'remark-parse';
|
|
16
|
+
import gfm from 'remark-gfm';
|
|
17
|
+
import { toString as stringify } from 'mdast-util-to-string';
|
|
18
|
+
import s from './symbols.js';
|
|
19
|
+
import { keyword } from './keywords.js';
|
|
20
20
|
|
|
21
21
|
function isabstract(schema) {
|
|
22
22
|
return schema.definitions !== undefined
|
|
@@ -49,24 +49,24 @@ function iscustom(schema) {
|
|
|
49
49
|
function getdefined(schema) {
|
|
50
50
|
if (schema[s.parent]) {
|
|
51
51
|
return {
|
|
52
|
-
text: `${
|
|
53
|
-
link: schema[s.
|
|
52
|
+
text: `${schema[s.filename]}*`,
|
|
53
|
+
link: schema[s.fullpath],
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
|
-
text:
|
|
58
|
-
link: schema[s.
|
|
57
|
+
text: schema[s.filename],
|
|
58
|
+
link: schema[s.fullpath],
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function plaindescription(schema) {
|
|
63
63
|
try {
|
|
64
|
-
if (schema[s.
|
|
65
|
-
const
|
|
66
|
-
path.dirname(schema[s.
|
|
64
|
+
if (schema[s.fullpath] && !schema[s.parent]) {
|
|
65
|
+
const fullPath = path.resolve(
|
|
66
|
+
path.dirname(schema[s.fullpath]),
|
|
67
67
|
schema[s.filename].replace(/\..*$/, '.description.md'),
|
|
68
68
|
);
|
|
69
|
-
const longdesc = fs.readFileSync(
|
|
69
|
+
const longdesc = fs.readFileSync(fullPath);
|
|
70
70
|
return longdesc.toString();
|
|
71
71
|
}
|
|
72
72
|
} catch {
|
|
@@ -119,7 +119,7 @@ function getrestrictions(schema) {
|
|
|
119
119
|
return undefined;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
function formatmeta(schema) {
|
|
122
|
+
export default function formatmeta(schema) {
|
|
123
123
|
return {
|
|
124
124
|
abstract: isabstract(schema),
|
|
125
125
|
extensible: isextensible(schema),
|
|
@@ -133,5 +133,3 @@ function formatmeta(schema) {
|
|
|
133
133
|
...parsecomment(schema[keyword`$comment`]),
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
module.exports.formatmeta = formatmeta;
|
package/lib/formattingTools.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import i from 'es2015-i18n-tag';
|
|
13
|
+
import s from './symbols.js';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const { default: i18n } = i;
|
|
16
|
+
|
|
17
|
+
export function gentitle(titles, type) {
|
|
16
18
|
if (!Array.isArray(titles)) {
|
|
17
19
|
return i18n`Untitled schema`;
|
|
18
20
|
}
|
|
@@ -34,10 +36,6 @@ function gentitle(titles, type) {
|
|
|
34
36
|
return i18n`Untitled undefined type in ${firsttitle}`;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
function gendescription(schema) {
|
|
39
|
+
export function gendescription(schema) {
|
|
38
40
|
return (schema && schema[s.meta]) ? schema[s.meta].shortdescription : '';
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
gentitle, gendescription,
|
|
43
|
-
};
|
package/lib/index.js
CHANGED
|
@@ -9,67 +9,160 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const logger = require('@adobe/helix-log');
|
|
19
|
-
const {
|
|
12
|
+
/* @ts-check */
|
|
13
|
+
import yargs from 'yargs';
|
|
14
|
+
import fs from 'fs-extra';
|
|
15
|
+
import readdirp from 'readdirp';
|
|
16
|
+
import { createDefaultLogger, SimpleInterface } from '@adobe/helix-log';
|
|
17
|
+
import {
|
|
20
18
|
iter, pipe, filter, map, obj,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
19
|
+
} from 'ferrum';
|
|
20
|
+
import nodepath from 'path';
|
|
21
|
+
import { i18nConfig } from 'es2015-i18n-tag';
|
|
22
|
+
import { fileURLToPath } from 'url';
|
|
23
|
+
import traverse from './traverseSchema.js';
|
|
24
|
+
import build from './markdownBuilder.js';
|
|
25
|
+
import { writereadme, writemarkdown } from './writeMarkdown.js';
|
|
26
|
+
import readme from './readmeBuilder.js';
|
|
27
|
+
import loader from './schemaProxy.js';
|
|
28
|
+
import writeSchema from './writeSchema.js';
|
|
29
|
+
|
|
30
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
31
|
+
const __dirname = nodepath.dirname(__filename);
|
|
32
|
+
|
|
33
|
+
const logger = new SimpleInterface({
|
|
34
|
+
logger: createDefaultLogger(),
|
|
35
|
+
});
|
|
36
|
+
const debug = logger.debug.bind(logger);
|
|
37
|
+
const info = logger.info.bind(logger);
|
|
38
|
+
const error = logger.error.bind(logger);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {import("../types/api").JsonSchema} JsonSchema
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {import("../types/api").SchemaList} SchemaList
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {import("../types/api").SchemaContent} SchemaContent
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {import("../types/api").SchemaFiles} SchemaFiles
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Public API for jsonschema2md that can be used to turn JSON Schema files
|
|
58
|
+
* into readable Markdown documentation.
|
|
59
|
+
* @param {JsonSchema | SchemaFiles} schema JSON Schema input to get data from
|
|
60
|
+
* @param {Object} options Additional options for generation
|
|
61
|
+
* @param {string} [options.schemaPath] - (optional) Path to directory containing all JSON Schemas
|
|
62
|
+
* or a single JSON Schema file. This will be considered as the baseURL.
|
|
63
|
+
* @param {string} [options.outDir] - (optional) Path to output directory. Generating files will
|
|
64
|
+
* be skipped if directory is not specified.
|
|
65
|
+
* @param {{ [key:string]: string }} [options.metadata] - (optional) Add metadata elements to
|
|
66
|
+
* .md files.
|
|
67
|
+
* @param {string} [options.schemaOut] - (optional) Output JSON Schema files including
|
|
68
|
+
* description and validated examples in the specified folder.
|
|
69
|
+
* @param {boolean} [options.includeReadme=true] - (optional) Generate a README.md file in the
|
|
70
|
+
* output directory.
|
|
71
|
+
* @param {{ [key:string]: string }[]} [options.links] - (optional) Add this file as a link
|
|
72
|
+
* explaining the specified attribute.
|
|
73
|
+
* @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
|
|
74
|
+
* JSON files used for internationalization.
|
|
75
|
+
* @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
|
|
76
|
+
* @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
|
|
77
|
+
* @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
|
|
78
|
+
* which should be also in the description of an element.
|
|
79
|
+
* @param {boolean} [options.header=true] - (optional) Whether or not to include the header
|
|
80
|
+
* in markdown.
|
|
81
|
+
* @param {string[]} [options.skipProperties=[]] - (optional) Name of a default property to
|
|
82
|
+
* skip in markdown.
|
|
83
|
+
* @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
|
|
84
|
+
*/
|
|
85
|
+
export function jsonschema2md(schema, options) {
|
|
86
|
+
const {
|
|
87
|
+
schemaPath,
|
|
88
|
+
outDir,
|
|
89
|
+
metadata,
|
|
90
|
+
schemaOut,
|
|
91
|
+
includeReadme,
|
|
92
|
+
links,
|
|
93
|
+
i18n,
|
|
94
|
+
language,
|
|
95
|
+
exampleFormat,
|
|
96
|
+
includeProperties,
|
|
97
|
+
header,
|
|
98
|
+
skipProperties,
|
|
99
|
+
} = options;
|
|
100
|
+
if (!schema || typeof schema !== 'object') {
|
|
101
|
+
throw Error('Input is not valid. Provide JSON schema either as Object or Array.');
|
|
102
|
+
}
|
|
48
103
|
const locales = i18n || nodepath.resolve(__dirname, 'locales');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
104
|
+
i18nConfig(fs.readJSONSync(nodepath.resolve(locales, `${language || 'en_US'}.json`)));
|
|
105
|
+
let out = outDir;
|
|
106
|
+
if (options.out) {
|
|
107
|
+
// eslint-disable-next-line no-console
|
|
108
|
+
console.warn("Options 'out' has been deprecated. Please, use 'outDir' instead");
|
|
109
|
+
out = options.out;
|
|
110
|
+
}
|
|
111
|
+
let meta = metadata;
|
|
112
|
+
if (options.meta) {
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.warn("Options 'meta' has been deprecated. Please, use 'metadata' instead");
|
|
115
|
+
meta = options.meta;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** @type {SchemaFiles} */
|
|
119
|
+
let normalized;
|
|
120
|
+
if (Array.isArray(schema)) {
|
|
121
|
+
normalized = schema;
|
|
122
|
+
} else {
|
|
123
|
+
normalized = [{
|
|
124
|
+
fileName: 'definition.schema.json',
|
|
125
|
+
content: schema,
|
|
126
|
+
}];
|
|
59
127
|
}
|
|
60
128
|
|
|
129
|
+
const schemaLoader = loader();
|
|
130
|
+
|
|
131
|
+
// collect data about the schemas and turn everything into a big object
|
|
132
|
+
const schemas = pipe(
|
|
133
|
+
normalized,
|
|
134
|
+
// Checking if data contains the file path or its contents (JSON schema)
|
|
135
|
+
map(({ fileName, fullPath, content }) => {
|
|
136
|
+
if (!content && fullPath) {
|
|
137
|
+
return schemaLoader(fullPath, fs.readJSONSync(fullPath));
|
|
138
|
+
}
|
|
139
|
+
return schemaLoader(fileName, content);
|
|
140
|
+
}),
|
|
141
|
+
traverse,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @type {GeneratedOutput}
|
|
146
|
+
*/
|
|
147
|
+
const output = {};
|
|
148
|
+
|
|
149
|
+
console.log('preparing schemas...');
|
|
150
|
+
output.schema = writeSchema({
|
|
151
|
+
schemadir: schemaOut,
|
|
152
|
+
origindir: schemaPath,
|
|
153
|
+
})(schemas);
|
|
154
|
+
|
|
61
155
|
if (includeReadme) {
|
|
62
|
-
console.log('
|
|
63
|
-
pipe(
|
|
156
|
+
console.log('preparing README...');
|
|
157
|
+
output.readme = pipe(
|
|
64
158
|
schemas,
|
|
65
159
|
// build readme
|
|
66
160
|
readme({
|
|
67
|
-
readme:
|
|
161
|
+
readme: true,
|
|
68
162
|
}),
|
|
69
163
|
|
|
70
164
|
writereadme({
|
|
71
|
-
|
|
72
|
-
out: outOrDefault,
|
|
165
|
+
out,
|
|
73
166
|
info,
|
|
74
167
|
error,
|
|
75
168
|
debug,
|
|
@@ -78,8 +171,8 @@ function jsonschema2md(schema, {
|
|
|
78
171
|
);
|
|
79
172
|
}
|
|
80
173
|
|
|
81
|
-
console.log('
|
|
82
|
-
|
|
174
|
+
console.log('preparing documentation...');
|
|
175
|
+
output.markdown = pipe(
|
|
83
176
|
schemas,
|
|
84
177
|
// generate Markdown ASTs
|
|
85
178
|
build({
|
|
@@ -89,21 +182,24 @@ function jsonschema2md(schema, {
|
|
|
89
182
|
exampleFormat,
|
|
90
183
|
skipProperties,
|
|
91
184
|
rewritelinks: (origin) => {
|
|
92
|
-
const mddir =
|
|
185
|
+
const mddir = out;
|
|
186
|
+
if (!mddir) {
|
|
187
|
+
return origin;
|
|
188
|
+
}
|
|
93
189
|
const srcdir = schemaPath;
|
|
94
190
|
const schemadir = schemaOut || schemaPath;
|
|
95
191
|
|
|
96
|
-
const target =
|
|
192
|
+
const target = nodepath.relative(
|
|
97
193
|
mddir,
|
|
98
|
-
|
|
99
|
-
).split(
|
|
194
|
+
nodepath.resolve(schemadir, nodepath.relative(srcdir, origin)),
|
|
195
|
+
).split(nodepath.sep).join(nodepath.posix.sep);
|
|
100
196
|
return target;
|
|
101
197
|
},
|
|
102
198
|
}),
|
|
103
199
|
|
|
104
200
|
// write to files
|
|
105
201
|
writemarkdown({
|
|
106
|
-
out
|
|
202
|
+
out,
|
|
107
203
|
info,
|
|
108
204
|
error,
|
|
109
205
|
debug,
|
|
@@ -111,19 +207,24 @@ function jsonschema2md(schema, {
|
|
|
111
207
|
}),
|
|
112
208
|
);
|
|
113
209
|
|
|
114
|
-
return
|
|
210
|
+
return output;
|
|
115
211
|
}
|
|
116
212
|
|
|
117
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Main function used in the CLI.
|
|
215
|
+
* @param {{ [key:string]: unknown }} args CLI arguments from user input
|
|
216
|
+
* @returns The generated Markdown files to the specified output directory
|
|
217
|
+
*/
|
|
218
|
+
export async function main(args) {
|
|
118
219
|
// parse/process command line arguments
|
|
119
220
|
const { argv } = yargs(args)
|
|
120
221
|
.usage('Generate Markdown documentation from JSON Schema.\n\nUsage: $0')
|
|
121
222
|
|
|
122
223
|
.demand('d')
|
|
123
224
|
.alias('d', 'input')
|
|
124
|
-
.describe('d', 'path to directory containing all JSON Schemas
|
|
225
|
+
.describe('d', 'path to directory containing all JSON Schemas to process. This will be considered as the baseURL. By default only files ending in .schema.json will be processed, unless the schema-extension is set with the -e flag.')
|
|
125
226
|
.coerce('d', (d) => {
|
|
126
|
-
const resolved = nodepath.resolve(d);
|
|
227
|
+
const resolved = d && nodepath.resolve(d);
|
|
127
228
|
if (fs.existsSync(resolved) && fs.lstatSync(d).isDirectory()) {
|
|
128
229
|
return resolved;
|
|
129
230
|
}
|
|
@@ -198,8 +299,8 @@ async function main(args) {
|
|
|
198
299
|
);
|
|
199
300
|
|
|
200
301
|
const schemaPath = argv.d;
|
|
201
|
-
const
|
|
202
|
-
const
|
|
302
|
+
const outDir = argv.o;
|
|
303
|
+
const metadata = argv.m;
|
|
203
304
|
const schemaOut = argv.x !== '-' ? argv.x : null;
|
|
204
305
|
const includeReadme = !argv.n;
|
|
205
306
|
const i18n = argv.i;
|
|
@@ -211,27 +312,23 @@ async function main(args) {
|
|
|
211
312
|
|
|
212
313
|
const schemaExtension = argv.e;
|
|
213
314
|
|
|
214
|
-
const schemaloader = loader();
|
|
215
|
-
|
|
216
315
|
// list all schema files in the specified directory
|
|
217
|
-
const
|
|
316
|
+
const schemaFiles = await readdirp.promise(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtension}` });
|
|
218
317
|
|
|
219
|
-
console.log(`loading ${
|
|
318
|
+
console.log(`loading ${schemaFiles.length} schemas`);
|
|
220
319
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
traverse,
|
|
229
|
-
);
|
|
320
|
+
/**
|
|
321
|
+
* @type {SchemaList[]}
|
|
322
|
+
* */
|
|
323
|
+
const schemas = schemaFiles.map((schema) => ({
|
|
324
|
+
fileName: schema.basename,
|
|
325
|
+
fullPath: schema.fullPath,
|
|
326
|
+
}));
|
|
230
327
|
|
|
231
|
-
jsonschema2md(
|
|
328
|
+
jsonschema2md(schemas, {
|
|
232
329
|
schemaPath,
|
|
233
|
-
|
|
234
|
-
|
|
330
|
+
outDir,
|
|
331
|
+
metadata,
|
|
235
332
|
schemaOut,
|
|
236
333
|
includeReadme,
|
|
237
334
|
links,
|
|
@@ -245,5 +342,3 @@ async function main(args) {
|
|
|
245
342
|
|
|
246
343
|
return 1;
|
|
247
344
|
}
|
|
248
|
-
|
|
249
|
-
module.exports = { jsonschema2md, main };
|
package/lib/keywords.js
CHANGED
|
@@ -11,13 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const used = new Set();
|
|
13
13
|
|
|
14
|
-
function keyword(str) {
|
|
14
|
+
export function keyword(str) {
|
|
15
15
|
used.add(str[0]);
|
|
16
16
|
return str.join('');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function report() {
|
|
19
|
+
export function report() {
|
|
20
20
|
return used;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
module.exports = { keyword, report };
|
package/lib/locales/update.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import { exportTranslationKeys } from 'i18n-tag-schema';
|
|
14
|
+
import fs from 'fs-extra';
|
|
15
15
|
|
|
16
16
|
exportTranslationKeys({ rootPath: './lib' })
|
|
17
17
|
.then((result) => {
|