@adobe/jsonschema2md 8.1.3 → 8.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # [8.2.0](https://github.com/adobe/jsonschema2md/compare/v8.1.4...v8.2.0) (2026-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **cli:** clean up --link-titles option ([76919eb](https://github.com/adobe/jsonschema2md/commit/76919eb08c0e91c1bc98f9676afcf698606c0945))
7
+ * **cli:** don't treat --link-titles as a --link-* attribute link ([dd01da4](https://github.com/adobe/jsonschema2md/commit/dd01da48b4f6a1cb8a82c5b9052469d4b8381cd8))
8
+ * **types:** don't make emitted types/symbols.d.ts a tsc input ([b39bd0e](https://github.com/adobe/jsonschema2md/commit/b39bd0eaa9e5412acafef8250bda9c34bea04e6f))
9
+ * **types:** keep require() and deep paths working with the exports map ([5ecfdda](https://github.com/adobe/jsonschema2md/commit/5ecfdda8f07d0ff2a4847ddf3ec04efdc7c07a25))
10
+ * **types:** keep type-only deep imports from types/* working ([7e97df8](https://github.com/adobe/jsonschema2md/commit/7e97df81afde07be2d19ba9fba091ed98222d6a0))
11
+
12
+
13
+ ### Features
14
+
15
+ * added flag (--no-titles-in-links) to skip generating titles in links ([e899a7c](https://github.com/adobe/jsonschema2md/commit/e899a7c9453f5fdb45ae7d3bfb7a1450e93cae82))
16
+ * **types:** support Node16 TypeScript resolution ([3037e76](https://github.com/adobe/jsonschema2md/commit/3037e767468e02a07bad08d05142ba01aa49315e))
17
+
18
+ ## [8.1.4](https://github.com/adobe/jsonschema2md/compare/v8.1.3...v8.1.4) (2026-12-04)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * 🐛 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)
24
+ * **markdownBuilder:** render falsy YAML defaults, keep block-scalar newlines ([9dd17bf](https://github.com/adobe/jsonschema2md/commit/9dd17bf4f79c34ea937b67e1ad82a1da29f71053))
25
+ * support schema content with pathy `fileName` ([7018c70](https://github.com/adobe/jsonschema2md/commit/7018c701479009889cdf0d954b9702b3f1ae0f14))
26
+
1
27
  ## [8.1.3](https://github.com/adobe/jsonschema2md/compare/v8.1.2...v8.1.3) (2026-12-04)
2
28
 
3
29
 
package/README.md CHANGED
@@ -60,9 +60,16 @@ In some cases you do not need a header because it does not provide any useful in
60
60
  $ jsonschema2md -d examples/schemas -o examples/docs -v 06 -h false
61
61
  ```
62
62
 
63
+ ## Disable titles in links
64
+ By default, links in the generated Markdown carry a title (for example `[foo](foo.md "https://example.com/schema#/properties/foo")`), which most renderers show as a tooltip. With `--link-titles false` (or `-t false`) the titles are left out.
65
+
66
+ ```bash
67
+ $ jsonschema2md -d examples/schemas -o examples/docs -t false
68
+ ```
69
+
63
70
  ## Examples as YAML
64
71
 
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.
72
+ 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
73
 
67
74
  ## Using JSON Schema Markdown Tools from `npm`
68
75
 
package/lib/index.js CHANGED
@@ -63,12 +63,14 @@ const { debug, info, error } = console;
63
63
  * description and validated examples in the specified folder.
64
64
  * @param {boolean} [options.includeReadme=true] - (optional) Generate a README.md file in the
65
65
  * output directory.
66
+ * @param {boolean} [options.linkTitles=true] - (optional) Render titles in Markdown links.
66
67
  * @param {{ [key:string]: string }[]} [options.links] - (optional) Add this file as a link
67
68
  * explaining the specified attribute.
68
69
  * @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
69
70
  * JSON files used for internationalization.
70
71
  * @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
71
- * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
72
+ * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format
73
+ * examples and default values.
72
74
  * @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
73
75
  * which should be also in the description of an element.
74
76
  * @param {boolean} [options.header=true] - (optional) Whether or not to include the header
@@ -86,6 +88,7 @@ export function jsonschema2md(schema, options) {
86
88
  metadata,
87
89
  schemaOut,
88
90
  includeReadme,
91
+ linkTitles,
89
92
  links,
90
93
  i18n,
91
94
  language,
@@ -161,6 +164,7 @@ export function jsonschema2md(schema, options) {
161
164
  // build readme
162
165
  readme({
163
166
  readme: true,
167
+ linkTitles,
164
168
  }),
165
169
 
166
170
  writereadme({
@@ -198,6 +202,7 @@ export function jsonschema2md(schema, options) {
198
202
  ).split(nodepath.sep).join(nodepath.posix.sep);
199
203
  return target;
200
204
  },
205
+ linkTitles,
201
206
  }),
202
207
 
203
208
  // write to files
@@ -263,6 +268,11 @@ export async function main(args) {
263
268
  .alias('n', 'no-readme')
264
269
  .describe('n', 'Do not generate a README.md file in the output directory')
265
270
 
271
+ .alias('t', 'link-titles')
272
+ .describe('t', 'Set this to false to disable rendering titles in markdown links')
273
+ .boolean('t')
274
+ .default('t', true)
275
+
266
276
  .describe('link-*', 'Add this file as a link the explain the * attribute, e.g. --link-abstract=abstract.md')
267
277
 
268
278
  .alias('i', 'i18n')
@@ -276,7 +286,7 @@ export async function main(args) {
276
286
  .default('l', 'en_US')
277
287
 
278
288
  .alias('f', 'example-format')
279
- .describe('f', 'how to format examples')
289
+ .describe('f', 'how to format examples and default values')
280
290
  .choices('f', ['json', 'yaml'])
281
291
  .default('f', 'json')
282
292
 
@@ -303,7 +313,7 @@ export async function main(args) {
303
313
 
304
314
  const links = pipe(
305
315
  iter(argv),
306
- filter(([key, _value]) => key.startsWith('link-')),
316
+ filter(([key, _value]) => key.startsWith('link-') && key !== 'link-titles'),
307
317
  map(([key, value]) => [key.substr(5), value]),
308
318
  obj,
309
319
  );
@@ -313,6 +323,7 @@ export async function main(args) {
313
323
  const metadata = argv.m;
314
324
  const schemaOut = argv.x !== '-' ? argv.x : null;
315
325
  const includeReadme = !argv.n;
326
+ const linkTitles = argv.t;
316
327
  const i18n = argv.i;
317
328
  const language = argv.l;
318
329
  const exampleFormat = argv.f;
@@ -345,6 +356,7 @@ export async function main(args) {
345
356
  metadata,
346
357
  schemaOut,
347
358
  includeReadme,
359
+ linkTitles,
348
360
  links,
349
361
  i18n,
350
362
  language,
@@ -38,10 +38,11 @@ import { keyword } from './keywords.js';
38
38
  const { default: i18n } = i;
39
39
 
40
40
  export default function build({
41
- header,
41
+ header = false,
42
42
  links = {},
43
43
  includeProperties = [],
44
44
  rewritelinks = (x) => x,
45
+ linkTitles = true,
45
46
  exampleFormat = 'json',
46
47
  skipProperties: rawSkipProperties = [],
47
48
  singleFile = false,
@@ -50,11 +51,15 @@ export default function build({
50
51
  ? [...new Set([...rawSkipProperties, 'definedinfact'])]
51
52
  : rawSkipProperties;
52
53
 
54
+ function makelink(url, title, children) {
55
+ return link(url, linkTitles ? title : '', children);
56
+ }
57
+
53
58
  function schemaLink(url, title, children) {
54
59
  if (singleFile) {
55
60
  return children;
56
61
  }
57
- return link(url, title, children);
62
+ return makelink(url, title, children);
58
63
  }
59
64
 
60
65
  const formats = {
@@ -278,7 +283,7 @@ export default function build({
278
283
  headerprops,
279
284
  ({ name, title }) => {
280
285
  if (links[name]) {
281
- return tableCell(link(links[name], i18n`What does ${title} mean?`, text(title)));
286
+ return tableCell(makelink(links[name], i18n`What does ${title} mean?`, text(title)));
282
287
  }
283
288
  return tableCell(text(title));
284
289
  },
@@ -293,7 +298,7 @@ export default function build({
293
298
  && typeof schema[s.meta][prop.name] === 'object'
294
299
  && schema[s.meta][prop.name].link
295
300
  && schema[s.meta][prop.name].text) {
296
- return tableCell(link(rewritelinks(schema[s.meta][prop.name].link), i18n`open original schema`, [text(schema[s.meta][prop.name].text)]));
301
+ return tableCell(makelink(rewritelinks(schema[s.meta][prop.name].link), i18n`open original schema`, [text(schema[s.meta][prop.name].text)]));
297
302
  }
298
303
  const value = schema[s.meta] ? schema[s.meta][prop.name] : undefined;
299
304
  return tableCell(text(prop[`${String(value)}label`] || i18n`Unknown`));
@@ -336,7 +341,7 @@ export default function build({
336
341
  function makepropheader(required = [], ispattern = false, slugger) {
337
342
  return ([name, definition]) => {
338
343
  const cells = [
339
- tableCell(ispattern ? inlineCode(name) : link(`#${slugger.slug(name)}`, '', text(name))), // Property
344
+ tableCell(ispattern ? inlineCode(name) : makelink(`#${slugger.slug(name)}`, '', text(name))), // Property
340
345
  tableCell(type(definition)),
341
346
  tableCell(text(required.indexOf(name) > -1 ? i18n`Required` : i18n`Optional`)),
342
347
  tableCell(nullable(definition)),
@@ -478,7 +483,7 @@ export default function build({
478
483
  // destination would be confusing. Titled types above still render their
479
484
  // name via schemaLink (which removes the link markup while keeping the text).
480
485
  if (singleFile) return [];
481
- return [text(' ('), link(`${definition[s.slug]}.md`, '', text(i18n`Details`)), text(')')];
486
+ return [text(' ('), makelink(`${definition[s.slug]}.md`, '', text(i18n`Details`)), text(')')];
482
487
  }
483
488
  return [];
484
489
  })();
@@ -649,7 +654,7 @@ export default function build({
649
654
  // console.log('pattern!', schema[s.filename], schema[s.pointer]);
650
655
  constraints.push(paragraph([strong(text(i18n`pattern`)), text(': '), text(i18n`the string must match the following regular expression: `)]));
651
656
  constraints.push(code('regexp', schema[keyword`pattern`]));
652
- constraints.push(paragraph([link(`https://regexr.com/?expression=${encodeURIComponent(schema[keyword`pattern`])}`, i18n`try regular expression with regexr.com`, text(i18n`try pattern`))]));
657
+ constraints.push(paragraph([makelink(`https://regexr.com/?expression=${encodeURIComponent(schema[keyword`pattern`])}`, i18n`try regular expression with regexr.com`, text(i18n`try pattern`))]));
653
658
  }
654
659
  // https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.7.3
655
660
  if (schema.format && typeof schema.format === 'string' && formats[schema.format]) {
@@ -657,7 +662,7 @@ export default function build({
657
662
  strong(text(formats[keyword([schema.format])].label)),
658
663
  text(': '),
659
664
  text(formats[schema.format].text),
660
- link(formats[schema.format].speclink, i18n`check the specification`, text(formats[schema.format].specname)),
665
+ makelink(formats[schema.format].speclink, i18n`check the specification`, text(formats[schema.format].specname)),
661
666
  ]));
662
667
  } else if (schema.format && typeof schema.format === 'string') {
663
668
  constraints.push(paragraph([strong(text(i18n`unknown format`)), text(': '), text(i18n`the value of this string must follow the format: `), inlineCode(String(schema.format))]));
@@ -734,14 +739,18 @@ export default function build({
734
739
  }
735
740
 
736
741
  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
- ];
742
+ if (schema[keyword`default`] === undefined) {
743
+ return [];
743
744
  }
744
- return [];
745
+ const value = schema[keyword`default`];
746
+ return [
747
+ heading(level + 1, text(i18n`${simpletitle(schema)} Default Value`)),
748
+ paragraph(text(i18n`The default value is:`)),
749
+ exampleFormat === 'yaml'
750
+ // only drop the final newline: more would change `|+` block scalars
751
+ ? paragraph(code('yaml', yaml.dump(value, undefined, 2).replace(/\n$/, '')))
752
+ : paragraph(code('json', JSON.stringify(value, undefined, 2))),
753
+ ];
745
754
  }
746
755
 
747
756
  function makerestrictions(schema, level = 1) {
@@ -44,8 +44,11 @@ function makeversionnote(schemas) {
44
44
  * @param {object} opts
45
45
  * @returns {(schemas: Array) => import('unist').Parent|null}
46
46
  */
47
- export default function build({ readme = true }) {
47
+ export default function build({ readme = true, linkTitles = true }) {
48
48
  return (schemas) => {
49
+ function makelink(url, title, description) {
50
+ return link(url, linkTitles ? title : '', description);
51
+ }
49
52
  if (readme) {
50
53
  console.log('building readme');
51
54
  const toplevel = flist(pipe(
@@ -53,7 +56,7 @@ export default function build({ readme = true }) {
53
56
  filter((schema) => !schema[s.parent]), // remove schemas with a parent
54
57
  mapSort((schema) => gentitle(schema[s.titles], schema[keyword`type`])),
55
58
  map((schema) => listItem(paragraph([
56
- link(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
59
+ makelink(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
57
60
  text(' – '),
58
61
  inlineCode(schema[keyword`$id`] || '-'),
59
62
  ]))),
@@ -66,7 +69,7 @@ export default function build({ readme = true }) {
66
69
  filter((schema) => !schema.$ref), // it is not a reference
67
70
  mapSort((schema) => gentitle(schema[s.titles], schema[keyword`type`])),
68
71
  map((schema) => listItem(paragraph([
69
- link(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
72
+ makelink(`./${schema[s.slug]}.md`, gendescription(schema), [text(gentitle(schema[s.titles], schema[keyword`type`]))]),
70
73
  text(' – '),
71
74
  inlineCode(`${schema[s.id]}#${schema[s.pointer]}`),
72
75
  ]))),
@@ -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,13 +1,36 @@
1
1
  {
2
2
  "name": "@adobe/jsonschema2md",
3
3
  "description": "Validate and document complex JSON Schemas the easy way.",
4
- "version": "8.1.3",
4
+ "version": "8.2.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "types",
7
7
  "bin": {
8
8
  "jsonschema2md": "./cli.js"
9
9
  },
10
10
  "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./types/index.d.ts",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./lib/*.js": {
17
+ "types": "./types/*.d.ts",
18
+ "default": "./lib/*.js"
19
+ },
20
+ "./lib/*": {
21
+ "types": "./types/*.d.ts",
22
+ "default": "./lib/*.js"
23
+ },
24
+ "./lib/locales/*.json": "./lib/locales/*.json",
25
+ "./cli.js": "./cli.js",
26
+ "./types/*.js": {
27
+ "types": "./types/*.d.ts"
28
+ },
29
+ "./types/*": {
30
+ "types": "./types/*.d.ts"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
11
34
  "scripts": {
12
35
  "semantic-release": "npm run emit-types && npx semantic-release",
13
36
  "lint": "eslint .",
package/types/api.d.ts CHANGED
@@ -12,7 +12,6 @@
12
12
 
13
13
  import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
14
14
  import { Root } from "mdast";
15
- import { filename, fullpath } from "../lib/symbols.js";
16
15
 
17
16
  export type UniqueSymbols = {
18
17
  readonly pointer: unique symbol;
@@ -38,8 +37,9 @@ export type SchemaContent = {
38
37
  };
39
38
  export type SchemaFiles = (SchemaList | SchemaContent)[];
40
39
  export type ExtendedJsonSchema = JsonSchema & {
41
- [filename]: string;
42
- [fullpath]?: string;
40
+ [K in UniqueSymbols["filename"]]: string;
41
+ } & {
42
+ [K in UniqueSymbols["fullpath"]]?: string;
43
43
  };
44
44
 
45
45
  export type MarkdownAst = Root;
package/types/index.d.ts CHANGED
@@ -33,12 +33,14 @@ export type GeneratedOutput = import("../types/api.js").GeneratedOutput;
33
33
  * description and validated examples in the specified folder.
34
34
  * @param {boolean} [options.includeReadme=true] - (optional) Generate a README.md file in the
35
35
  * output directory.
36
+ * @param {boolean} [options.linkTitles=true] - (optional) Render titles in Markdown links.
36
37
  * @param {{ [key:string]: string }[]} [options.links] - (optional) Add this file as a link
37
38
  * explaining the specified attribute.
38
39
  * @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
39
40
  * JSON files used for internationalization.
40
41
  * @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
41
- * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
42
+ * @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format
43
+ * examples and default values.
42
44
  * @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
43
45
  * which should be also in the description of an element.
44
46
  * @param {boolean} [options.header=true] - (optional) Whether or not to include the header
@@ -57,6 +59,7 @@ export declare function jsonschema2md(schema: JsonSchema | SchemaFiles, options:
57
59
  };
58
60
  schemaOut?: string;
59
61
  includeReadme?: boolean;
62
+ linkTitles?: boolean;
60
63
  links?: {
61
64
  [key: string]: string;
62
65
  }[];
@@ -1,6 +1,8 @@
1
- export default function build({ header, links, includeProperties, rewritelinks, exampleFormat, skipProperties: rawSkipProperties, singleFile, }?: {
1
+ export default function build({ header, links, includeProperties, rewritelinks, linkTitles, exampleFormat, skipProperties: rawSkipProperties, singleFile, }?: {
2
2
  exampleFormat?: string;
3
+ header?: boolean;
3
4
  includeProperties?: any[];
5
+ linkTitles?: boolean;
4
6
  links?: {};
5
7
  rewritelinks?: (x: any) => any;
6
8
  singleFile?: boolean;
@@ -3,4 +3,4 @@
3
3
  * @param {object} opts
4
4
  * @returns {(schemas: Array) => import('unist').Parent|null}
5
5
  */
6
- export default function build({ readme }: object): (schemas: any[]) => import('unist').Parent | null;
6
+ export default function build({ readme, linkTitles }: object): (schemas: any[]) => import('unist').Parent | null;