@adobe/jsonschema2md 8.1.4 → 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,20 @@
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
+
1
18
  ## [8.1.4](https://github.com/adobe/jsonschema2md/compare/v8.1.3...v8.1.4) (2026-12-04)
2
19
 
3
20
 
package/README.md CHANGED
@@ -60,6 +60,13 @@ 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
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.
package/lib/index.js CHANGED
@@ -63,6 +63,7 @@ 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
@@ -87,6 +88,7 @@ export function jsonschema2md(schema, options) {
87
88
  metadata,
88
89
  schemaOut,
89
90
  includeReadme,
91
+ linkTitles,
90
92
  links,
91
93
  i18n,
92
94
  language,
@@ -162,6 +164,7 @@ export function jsonschema2md(schema, options) {
162
164
  // build readme
163
165
  readme({
164
166
  readme: true,
167
+ linkTitles,
165
168
  }),
166
169
 
167
170
  writereadme({
@@ -199,6 +202,7 @@ export function jsonschema2md(schema, options) {
199
202
  ).split(nodepath.sep).join(nodepath.posix.sep);
200
203
  return target;
201
204
  },
205
+ linkTitles,
202
206
  }),
203
207
 
204
208
  // write to files
@@ -264,6 +268,11 @@ export async function main(args) {
264
268
  .alias('n', 'no-readme')
265
269
  .describe('n', 'Do not generate a README.md file in the output directory')
266
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
+
267
276
  .describe('link-*', 'Add this file as a link the explain the * attribute, e.g. --link-abstract=abstract.md')
268
277
 
269
278
  .alias('i', 'i18n')
@@ -304,7 +313,7 @@ export async function main(args) {
304
313
 
305
314
  const links = pipe(
306
315
  iter(argv),
307
- filter(([key, _value]) => key.startsWith('link-')),
316
+ filter(([key, _value]) => key.startsWith('link-') && key !== 'link-titles'),
308
317
  map(([key, value]) => [key.substr(5), value]),
309
318
  obj,
310
319
  );
@@ -314,6 +323,7 @@ export async function main(args) {
314
323
  const metadata = argv.m;
315
324
  const schemaOut = argv.x !== '-' ? argv.x : null;
316
325
  const includeReadme = !argv.n;
326
+ const linkTitles = argv.t;
317
327
  const i18n = argv.i;
318
328
  const language = argv.l;
319
329
  const exampleFormat = argv.f;
@@ -346,6 +356,7 @@ export async function main(args) {
346
356
  metadata,
347
357
  schemaOut,
348
358
  includeReadme,
359
+ linkTitles,
349
360
  links,
350
361
  i18n,
351
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))]));
@@ -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
  ]))),
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.4",
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,6 +33,7 @@ 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
@@ -58,6 +59,7 @@ export declare function jsonschema2md(schema: JsonSchema | SchemaFiles, options:
58
59
  };
59
60
  schemaOut?: string;
60
61
  includeReadme?: boolean;
62
+ linkTitles?: boolean;
61
63
  links?: {
62
64
  [key: string]: string;
63
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;