@adobe/jsonschema2md 8.1.2 → 8.1.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [8.1.4](https://github.com/adobe/jsonschema2md/compare/v8.1.3...v8.1.4) (2026-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 🐛 correct handle yaml example-format for default values ([93a389c](https://github.com/adobe/jsonschema2md/commit/93a389cc16f98e5e7149c72c3788968159a74bfe)), closes [#246](https://github.com/adobe/jsonschema2md/issues/246)
7
+ * **markdownBuilder:** render falsy YAML defaults, keep block-scalar newlines ([9dd17bf](https://github.com/adobe/jsonschema2md/commit/9dd17bf4f79c34ea937b67e1ad82a1da29f71053))
8
+ * support schema content with pathy `fileName` ([7018c70](https://github.com/adobe/jsonschema2md/commit/7018c701479009889cdf0d954b9702b3f1ae0f14))
9
+
10
+ ## [8.1.3](https://github.com/adobe/jsonschema2md/compare/v8.1.2...v8.1.3) (2026-12-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **deps:** update external majors and Node.js 26 ([23b645c](https://github.com/adobe/jsonschema2md/commit/23b645c10145399404deaf05f37904c7803edbcb))
16
+
1
17
  ## [8.1.2](https://github.com/adobe/jsonschema2md/compare/v8.1.1...v8.1.2) (2026-12-04)
2
18
 
3
19
 
package/README.md CHANGED
@@ -62,7 +62,7 @@ $ jsonschema2md -d examples/schemas -o examples/docs -v 06 -h false
62
62
 
63
63
  ## Examples as YAML
64
64
 
65
- If you are using JSON Schema to validate YAML documents, for instance configuration files, you might wish for examples to be formatted as YAML, not JSON. Using the command line option `-f yaml` or `--example-format yaml` achieves this goal.
65
+ If you are using JSON Schema to validate YAML documents, for instance configuration files, you might wish for examples and default values to be formatted as YAML, not JSON. Using the command line option `-f yaml` or `--example-format yaml` achieves this goal.
66
66
 
67
67
  ## Using JSON Schema Markdown Tools from `npm`
68
68
 
package/lib/index.js CHANGED
@@ -33,19 +33,19 @@ const __dirname = nodepath.dirname(__filename);
33
33
  const { debug, info, error } = console;
34
34
 
35
35
  /**
36
- * @typedef {import("../types/api").JsonSchema} JsonSchema
36
+ * @typedef {import("../types/api.js").JsonSchema} JsonSchema
37
37
  */
38
38
  /**
39
- * @typedef {import("../types/api").SchemaList} SchemaList
39
+ * @typedef {import("../types/api.js").SchemaList} SchemaList
40
40
  */
41
41
  /**
42
- * @typedef {import("../types/api").SchemaContent} SchemaContent
42
+ * @typedef {import("../types/api.js").SchemaContent} SchemaContent
43
43
  */
44
44
  /**
45
- * @typedef {import("../types/api").SchemaFiles} SchemaFiles
45
+ * @typedef {import("../types/api.js").SchemaFiles} SchemaFiles
46
46
  */
47
47
  /**
48
- * @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
48
+ * @typedef {import("../types/api.js").GeneratedOutput} GeneratedOutput
49
49
  */
50
50
 
51
51
  /**
@@ -68,7 +68,8 @@ const { debug, info, error } = console;
68
68
  * @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
69
69
  * JSON files used for internationalization.
70
70
  * @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
71
- * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
71
+ * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format
72
+ * examples and default values.
72
73
  * @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
73
74
  * which should be also in the description of an element.
74
75
  * @param {boolean} [options.header=true] - (optional) Whether or not to include the header
@@ -276,7 +277,7 @@ export async function main(args) {
276
277
  .default('l', 'en_US')
277
278
 
278
279
  .alias('f', 'example-format')
279
- .describe('f', 'how to format examples')
280
+ .describe('f', 'how to format examples and default values')
280
281
  .choices('f', ['json', 'yaml'])
281
282
  .default('f', 'json')
282
283
 
@@ -30,7 +30,7 @@ import {
30
30
  } from 'mdast-builder';
31
31
  import i from 'es2015-i18n-tag';
32
32
  import GhSlugger from 'github-slugger';
33
- import yaml from 'js-yaml';
33
+ import * as yaml from 'js-yaml';
34
34
  import s from './symbols.js';
35
35
  import { gentitle } from './formattingTools.js';
36
36
  import { keyword } from './keywords.js';
@@ -734,14 +734,18 @@ export default function build({
734
734
  }
735
735
 
736
736
  function makedefault(schema, level = 1) {
737
- if (schema[keyword`default`] !== undefined) {
738
- return [
739
- heading(level + 1, text(i18n`${simpletitle(schema)} Default Value`)),
740
- paragraph(text(i18n`The default value is:`)),
741
- paragraph(code('json', JSON.stringify(schema[keyword`default`], undefined, 2))),
742
- ];
737
+ if (schema[keyword`default`] === undefined) {
738
+ return [];
743
739
  }
744
- return [];
740
+ const value = schema[keyword`default`];
741
+ return [
742
+ heading(level + 1, text(i18n`${simpletitle(schema)} Default Value`)),
743
+ paragraph(text(i18n`The default value is:`)),
744
+ exampleFormat === 'yaml'
745
+ // only drop the final newline: more would change `|+` block scalars
746
+ ? paragraph(code('yaml', yaml.dump(value, undefined, 2).replace(/\n$/, '')))
747
+ : paragraph(code('json', JSON.stringify(value, undefined, 2))),
748
+ ];
745
749
  }
746
750
 
747
751
  function makerestrictions(schema, level = 1) {
@@ -42,7 +42,7 @@ function makeversionnote(schemas) {
42
42
  /**
43
43
  * Generate the README.md
44
44
  * @param {object} opts
45
- * @returns {function(Array): import('unist').Parent|null}
45
+ * @returns {(schemas: Array) => import('unist').Parent|null}
46
46
  */
47
47
  export default function build({ readme = true }) {
48
48
  return (schemas) => {
package/lib/symbols.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  /**
14
- * @typedef {import("../types/api").UniqueSymbols} UniqueSymbols
14
+ * @typedef {import("../types/api.js").UniqueSymbols} UniqueSymbols
15
15
  */
16
16
 
17
17
  export const filename = Symbol('filename');
@@ -15,16 +15,16 @@ import { unified } from 'unified';
15
15
  import gfm from 'remark-gfm';
16
16
  import path from 'path';
17
17
  import fs from 'fs-extra';
18
- import yaml from 'js-yaml';
18
+ import * as yaml from 'js-yaml';
19
19
 
20
20
  /**
21
- * @typedef {import("../types/api").MarkdownAst} MarkdownAst
21
+ * @typedef {import("../types/api.js").MarkdownAst} MarkdownAst
22
22
  */
23
23
  /**
24
- * @typedef {import("../types/api").MarkdownContent} MarkdownContent
24
+ * @typedef {import("../types/api.js").MarkdownContent} MarkdownContent
25
25
  */
26
26
  /**
27
- * @typedef {import("../types/api").ReadmeContent} ReadmeContent
27
+ * @typedef {import("../types/api.js").ReadmeContent} ReadmeContent
28
28
  */
29
29
  /**
30
30
  * @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
@@ -14,10 +14,10 @@ import path from 'path';
14
14
  import s from './symbols.js';
15
15
 
16
16
  /**
17
- * @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
17
+ * @typedef {import("../types/api.js").ExtendedJsonSchema} ExtendedJsonSchema
18
18
  */
19
19
  /**
20
- * @typedef {import("../types/api").SchemaContent} SchemaContent
20
+ * @typedef {import("../types/api.js").SchemaContent} SchemaContent
21
21
  */
22
22
 
23
23
  /**
@@ -38,7 +38,7 @@ export default function writeSchema({ schemadir, origindir }) {
38
38
  const inputPath = schema[s.fullpath] || (origindir && path.join(origindir, fileName));
39
39
  let content = schema;
40
40
 
41
- if (inputPath) {
41
+ if (inputPath && fs.existsSync(inputPath)) {
42
42
  content = fs.readJsonSync(inputPath);
43
43
  if (schema[s.meta] && schema[s.meta].description) {
44
44
  // copy description from external file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adobe/jsonschema2md",
3
3
  "description": "Validate and document complex JSON Schemas the easy way.",
4
- "version": "8.1.2",
4
+ "version": "8.1.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "types",
7
7
  "bin": {
@@ -27,7 +27,7 @@
27
27
  "ferrum": "1.9.4",
28
28
  "fs-extra": "11.4.1",
29
29
  "github-slugger": "2.0.0",
30
- "js-yaml": "4.3.2",
30
+ "js-yaml": "5.5.0",
31
31
  "json-schema": "^0.4.0",
32
32
  "mdast-builder": "1.1.1",
33
33
  "mdast-util-to-string": "4.0.0",
@@ -42,23 +42,22 @@
42
42
  "devDependencies": {
43
43
  "@adobe/eslint-config-helix": "3.0.35",
44
44
  "@eslint/config-helpers": "0.7.0",
45
- "@semantic-release/changelog": "6.0.3",
46
- "@semantic-release/git": "10.0.1",
45
+ "@semantic-release/changelog": "7.0.0",
46
+ "@semantic-release/git": "11.0.1",
47
47
  "@semantic-release/github": "12.0.11",
48
48
  "@types/fs-extra": "11.0.4",
49
49
  "@types/github-slugger": "2.0.0",
50
- "@types/js-yaml": "4.0.9",
51
- "@types/node": "24.19.2",
50
+ "@types/node": "26.6.6",
52
51
  "@types/yargs": "17.0.35",
53
- "c8": "11.0.0",
52
+ "c8": "12.0.0",
54
53
  "eslint": "9.39.5",
55
54
  "husky": "9.1.7",
56
55
  "i18n-tag-schema": "2.5.0",
57
56
  "json-logic-js": "axa-ch/cyclic-schemas-test",
58
57
  "lint-staged": "17.6.1",
59
- "mocha": "11.8.0",
58
+ "mocha": "12.0.3",
60
59
  "semantic-release": "25.0.9",
61
- "typescript": "6.0.3",
60
+ "typescript": "7.0.2",
62
61
  "unist-util-select": "5.1.0"
63
62
  },
64
63
  "engines": {
@@ -1,10 +1,10 @@
1
1
  export default function formatmeta(schema: any): {
2
- longcomment: import("mdast").Root;
3
- shortcomment: any;
4
- comment: string;
5
2
  longdescription: import("mdast").Root;
6
3
  shortdescription: any;
7
4
  description: any;
5
+ longcomment: import("mdast").Root;
6
+ shortcomment: any;
7
+ comment: string;
8
8
  abstract: boolean;
9
9
  extensible: boolean;
10
10
  status: any;
@@ -1,2 +1,2 @@
1
- export function gentitle(titles: any, type: any): any;
2
- export function gendescription(schema: any): any;
1
+ export declare function gentitle(titles: any, type: any): any;
2
+ export declare function gendescription(schema: any): any;
package/types/index.d.ts CHANGED
@@ -1,17 +1,22 @@
1
+ export type JsonSchema = import("../types/api.js").JsonSchema;
2
+ export type SchemaList = import("../types/api.js").SchemaList;
3
+ export type SchemaContent = import("../types/api.js").SchemaContent;
4
+ export type SchemaFiles = import("../types/api.js").SchemaFiles;
5
+ export type GeneratedOutput = import("../types/api.js").GeneratedOutput;
1
6
  /**
2
- * @typedef {import("../types/api").JsonSchema} JsonSchema
7
+ * @typedef {import("../types/api.js").JsonSchema} JsonSchema
3
8
  */
4
9
  /**
5
- * @typedef {import("../types/api").SchemaList} SchemaList
10
+ * @typedef {import("../types/api.js").SchemaList} SchemaList
6
11
  */
7
12
  /**
8
- * @typedef {import("../types/api").SchemaContent} SchemaContent
13
+ * @typedef {import("../types/api.js").SchemaContent} SchemaContent
9
14
  */
10
15
  /**
11
- * @typedef {import("../types/api").SchemaFiles} SchemaFiles
16
+ * @typedef {import("../types/api.js").SchemaFiles} SchemaFiles
12
17
  */
13
18
  /**
14
- * @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
19
+ * @typedef {import("../types/api.js").GeneratedOutput} GeneratedOutput
15
20
  */
16
21
  /**
17
22
  * Public API for jsonschema2md that can be used to turn JSON Schema files
@@ -33,7 +38,8 @@
33
38
  * @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
34
39
  * JSON files used for internationalization.
35
40
  * @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
36
- * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
41
+ * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format
42
+ * examples and default values.
37
43
  * @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
38
44
  * which should be also in the description of an element.
39
45
  * @param {boolean} [options.header=true] - (optional) Whether or not to include the header
@@ -44,7 +50,7 @@
44
50
  * per schema, inlining all property documentation instead of creating separate files.
45
51
  * @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
46
52
  */
47
- export function jsonschema2md(schema: JsonSchema | SchemaFiles, options: {
53
+ export declare function jsonschema2md(schema: JsonSchema | SchemaFiles, options: {
48
54
  schemaPath?: string;
49
55
  outDir?: string;
50
56
  metadata?: {
@@ -68,11 +74,6 @@ export function jsonschema2md(schema: JsonSchema | SchemaFiles, options: {
68
74
  * @param {{ [key:string]: unknown }} args CLI arguments from user input
69
75
  * @returns The generated Markdown files to the specified output directory
70
76
  */
71
- export function main(args: {
77
+ export declare function main(args: {
72
78
  [key: string]: unknown;
73
79
  }): Promise<number>;
74
- export type JsonSchema = import("../types/api").JsonSchema;
75
- export type SchemaList = import("../types/api").SchemaList;
76
- export type SchemaContent = import("../types/api").SchemaContent;
77
- export type SchemaFiles = import("../types/api").SchemaFiles;
78
- export type GeneratedOutput = import("../types/api").GeneratedOutput;
@@ -1,2 +1,2 @@
1
- export function keyword(str: any): any;
2
- export function report(): Set<any>;
1
+ export declare function keyword(str: any): any;
2
+ export declare function report(): Set<any>;
@@ -1,8 +1,8 @@
1
1
  export default function build({ header, links, includeProperties, rewritelinks, exampleFormat, skipProperties: rawSkipProperties, singleFile, }?: {
2
- links?: {};
2
+ exampleFormat?: string;
3
3
  includeProperties?: any[];
4
+ links?: {};
4
5
  rewritelinks?: (x: any) => any;
5
- exampleFormat?: string;
6
- skipProperties?: any[];
7
6
  singleFile?: boolean;
7
+ skipProperties?: any[];
8
8
  }): (schemas: any) => any;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Generate the README.md
3
3
  * @param {object} opts
4
- * @returns {function(Array): import('unist').Parent|null}
4
+ * @returns {(schemas: Array) => import('unist').Parent|null}
5
5
  */
6
- export default function build({ readme }: object): (arg0: any[]) => import("unist").Parent | null;
6
+ export default function build({ readme }: object): (schemas: any[]) => import('unist').Parent | null;
@@ -1,11 +1,11 @@
1
+ export type UniqueSymbols = import("../types/api.js").UniqueSymbols;
1
2
  /**
2
- * @typedef {import("../types/api").UniqueSymbols} UniqueSymbols
3
+ * @typedef {import("../types/api.js").UniqueSymbols} UniqueSymbols
3
4
  */
4
- export const filename: unique symbol;
5
- export const fullpath: unique symbol;
6
- export default symbols;
7
- export type UniqueSymbols = import("../types/api").UniqueSymbols;
5
+ export declare const filename: unique symbol;
6
+ export declare const fullpath: unique symbol;
8
7
  /**
9
8
  * @type {UniqueSymbols}
10
9
  * */
11
10
  declare const symbols: UniqueSymbols;
11
+ export default symbols;
@@ -1,11 +1,17 @@
1
+ export type MarkdownAst = import("../types/api.js").MarkdownAst;
2
+ export type MarkdownContent = import("../types/api.js").MarkdownContent;
3
+ export type ReadmeContent = import("../types/api.js").ReadmeContent;
4
+ export type MarkdownAstFiles = {
5
+ [name: string]: MarkdownAst;
6
+ };
1
7
  /**
2
- * @typedef {import("../types/api").MarkdownAst} MarkdownAst
8
+ * @typedef {import("../types/api.js").MarkdownAst} MarkdownAst
3
9
  */
4
10
  /**
5
- * @typedef {import("../types/api").MarkdownContent} MarkdownContent
11
+ * @typedef {import("../types/api.js").MarkdownContent} MarkdownContent
6
12
  */
7
13
  /**
8
- * @typedef {import("../types/api").ReadmeContent} ReadmeContent
14
+ * @typedef {import("../types/api.js").ReadmeContent} ReadmeContent
9
15
  */
10
16
  /**
11
17
  * @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
@@ -20,7 +26,7 @@
20
26
  * @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
21
27
  * @returns {(astFiles: MarkdownAstFiles) => MarkdownContent[]}
22
28
  */
23
- export function writemarkdown({ out, error, meta, }: {
29
+ export declare function writemarkdown({ out, error, meta, }: {
24
30
  out?: string;
25
31
  error?: Function;
26
32
  info?: Function;
@@ -39,7 +45,7 @@ export function writemarkdown({ out, error, meta, }: {
39
45
  * @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
40
46
  * @returns {(markdownAst: MarkdownAst) => ReadmeContent}
41
47
  */
42
- export function writereadme({ out, error, info, meta, }: {
48
+ export declare function writereadme({ out, error, info, meta, }: {
43
49
  out?: string;
44
50
  error?: Function;
45
51
  info?: Function;
@@ -48,9 +54,3 @@ export function writereadme({ out, error, info, meta, }: {
48
54
  [key: string]: string;
49
55
  };
50
56
  }): (markdownAst: MarkdownAst) => ReadmeContent;
51
- export type MarkdownAst = import("../types/api").MarkdownAst;
52
- export type MarkdownContent = import("../types/api").MarkdownContent;
53
- export type ReadmeContent = import("../types/api").ReadmeContent;
54
- export type MarkdownAstFiles = {
55
- [name: string]: MarkdownAst;
56
- };
@@ -1,8 +1,10 @@
1
+ export type ExtendedJsonSchema = import("../types/api.js").ExtendedJsonSchema;
2
+ export type SchemaContent = import("../types/api.js").SchemaContent;
1
3
  /**
2
- * @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
4
+ * @typedef {import("../types/api.js").ExtendedJsonSchema} ExtendedJsonSchema
3
5
  */
4
6
  /**
5
- * @typedef {import("../types/api").SchemaContent} SchemaContent
7
+ * @typedef {import("../types/api.js").SchemaContent} SchemaContent
6
8
  */
7
9
  /**
8
10
  * Write the JSON Schemas to filesystem or an object
@@ -15,5 +17,3 @@ export default function writeSchema({ schemadir, origindir }: {
15
17
  schemadir?: string;
16
18
  origindir?: string;
17
19
  }): (schemas: ExtendedJsonSchema[]) => SchemaContent[];
18
- export type ExtendedJsonSchema = import("../types/api").ExtendedJsonSchema;
19
- export type SchemaContent = import("../types/api").SchemaContent;