@adobe/jsonschema2md 8.0.11 → 8.1.1

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,37 @@
1
+ ## [8.1.1](https://github.com/adobe/jsonschema2md/compare/v8.1.0...v8.1.1) (2026-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **markdownBuilder:** keep trailing newlines of YAML block scalars ([202e5de](https://github.com/adobe/jsonschema2md/commit/202e5dec5acdf717fff9a7eb68d5a54080f4232d)), closes [#789](https://github.com/adobe/jsonschema2md/issues/789)
7
+ * **markdownBuilder:** remove trailing blank line from YAML examples ([e18db78](https://github.com/adobe/jsonschema2md/commit/e18db7841563abcd4063646b480173d28bb666ae)), closes [#247](https://github.com/adobe/jsonschema2md/issues/247)
8
+
9
+ # [8.1.0](https://github.com/adobe/jsonschema2md/compare/v8.0.11...v8.1.0) (2026-12-04)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * address review comments on single-file mode PR ([35619fd](https://github.com/adobe/jsonschema2md/commit/35619fdf3e391dfcf1d4517c6e7b9f4e8e2edb08))
15
+ * **build:** make type emission work with TypeScript 6 ([12814e0](https://github.com/adobe/jsonschema2md/commit/12814e046fbab49fc459023ccd4956f09e3db4dd)), closes [#724](https://github.com/adobe/jsonschema2md/issues/724)
16
+ * **deps:** update dependency fs-extra to v11.4.1 ([#767](https://github.com/adobe/jsonschema2md/issues/767)) ([1285548](https://github.com/adobe/jsonschema2md/commit/12855483536a44ead9316e5ba679eea153b1489c))
17
+ * **deps:** update dependency js-yaml to v4.3.1 [security] ([#750](https://github.com/adobe/jsonschema2md/issues/750)) ([2d40673](https://github.com/adobe/jsonschema2md/commit/2d4067381236b0800450b611d6eda558eca0101a))
18
+ * **deps:** update dependency js-yaml to v4.3.2 [security] ([#757](https://github.com/adobe/jsonschema2md/issues/757)) ([01d2949](https://github.com/adobe/jsonschema2md/commit/01d29491da3be8f088a4925a4beb4d8c039d0bff))
19
+ * **deps:** update dependency readdirp to v5.1.1 ([#753](https://github.com/adobe/jsonschema2md/issues/753)) ([491756c](https://github.com/adobe/jsonschema2md/commit/491756cae28e11500ab6f8e65f8b937be7d5be93))
20
+ * **deps:** update dependency yargs to v18.2.0 ([#766](https://github.com/adobe/jsonschema2md/issues/766)) ([e135ae7](https://github.com/adobe/jsonschema2md/commit/e135ae700ae99fdfea864bcda4f2e4db1127deac))
21
+ * **deps:** update external fixes ([#733](https://github.com/adobe/jsonschema2md/issues/733)) ([552a2ab](https://github.com/adobe/jsonschema2md/commit/552a2abdda437fc237b1a4cd24bd03ef03dc992c))
22
+ * **deps:** update external fixes ([#738](https://github.com/adobe/jsonschema2md/issues/738)) ([ed3b516](https://github.com/adobe/jsonschema2md/commit/ed3b516a9eac82eb0392d46ef2b91a31c2985802))
23
+ * **deps:** update external fixes ([#744](https://github.com/adobe/jsonschema2md/issues/744)) ([ffc23dd](https://github.com/adobe/jsonschema2md/commit/ffc23ddb2b5d0c36f335127ba5ff3c70557e3774))
24
+ * **deps:** update external fixes ([#748](https://github.com/adobe/jsonschema2md/issues/748)) ([2264686](https://github.com/adobe/jsonschema2md/commit/2264686fed4d6a2533c0d714f3f60709bbb56dba))
25
+ * improve single-file mode code quality and test coverage ([0536b69](https://github.com/adobe/jsonschema2md/commit/0536b691a8942b8620243559aeb0b4946c28b921))
26
+ * **markdownBuilder:** include falsy custom attributes ([d9b2057](https://github.com/adobe/jsonschema2md/commit/d9b2057124b4d3d1307971d0a4d42a58950e77d3)), closes [#777](https://github.com/adobe/jsonschema2md/issues/777)
27
+ * **schemaProxy:** handle properties named $id ([7312a27](https://github.com/adobe/jsonschema2md/commit/7312a2737f9f056d99994bb7d122191c8e3137f0)), closes [#212](https://github.com/adobe/jsonschema2md/issues/212)
28
+ * **schemaproxy:** reuse canonical slugs for referenced schema IDs ([9a34ade](https://github.com/adobe/jsonschema2md/commit/9a34adeaca51c66a5500d8aee8d1d407a3386de8)), closes [#254](https://github.com/adobe/jsonschema2md/issues/254)
29
+
30
+
31
+ ### Features
32
+
33
+ * **adding a new generate option:** add single file mode ([501b49c](https://github.com/adobe/jsonschema2md/commit/501b49c7df971c15501827c6c7e8f2f7afded1c5)), closes [#531](https://github.com/adobe/jsonschema2md/issues/531) [#296](https://github.com/adobe/jsonschema2md/issues/296)
34
+
1
35
  ## [8.0.11](https://github.com/adobe/jsonschema2md/compare/v8.0.10...v8.0.11) (2026-03-23)
2
36
 
3
37
 
package/Contributing.md CHANGED
@@ -55,15 +55,15 @@ Feedback on the pull request will be given in writing, in GitHub.
55
55
 
56
56
  ## Commit Message Format
57
57
 
58
- This project uses a structured commit changelog format that should be used for every commit. Use npm run commit instead of your usual git commit to generate commit messages using a wizard.
58
+ This project uses [Conventional Commits](https://www.conventionalcommits.org/) (Angular convention) for every commit, so that `semantic-release` can determine the next version from the commit messages. Write your commit messages accordingly, e.g. `fix: handle empty response` or `feat(config): add support for …`.
59
59
 
60
60
  ```bash
61
61
  # either add all changed files
62
62
  $ git add -A
63
63
  # or selectively add files
64
64
  $ git add package.json
65
- # then commit using the wizard
66
- $ npm run commit
65
+ # then commit with a conventional commit message
66
+ $ git commit -m "fix: handle empty response"
67
67
  ```
68
68
 
69
69
  # Release Management
@@ -1,3 +1,3 @@
1
1
  Please mention the issue #… in the pull request.
2
2
 
3
- Please remember to follow the documented [commit process](https://github.com/adobe/jsonschema2md/blob/master/Contributing.md#commit-message-format), specifcally commit using `npm run commit` which will construct the commit template required for automated semantic releases.
3
+ Please remember to follow the documented [commit process](https://github.com/adobe/jsonschema2md/blob/master/Contributing.md#commit-message-format), specifically use [Conventional Commits](https://www.conventionalcommits.org/) for your commit messages, which are required for automated semantic releases.
package/lib/index.js CHANGED
@@ -24,6 +24,7 @@ import build from './markdownBuilder.js';
24
24
  import { writereadme, writemarkdown } from './writeMarkdown.js';
25
25
  import readme from './readmeBuilder.js';
26
26
  import loader from './schemaProxy.js';
27
+ import s from './symbols.js';
27
28
  import writeSchema from './writeSchema.js';
28
29
 
29
30
  const __filename = fileURLToPath(import.meta.url);
@@ -74,6 +75,8 @@ const { debug, info, error } = console;
74
75
  * in markdown.
75
76
  * @param {string[]} [options.skipProperties=[]] - (optional) Name of a default property to
76
77
  * skip in markdown.
78
+ * @param {boolean} [options.singleFile=false] - (optional) Generate a single Markdown file
79
+ * per schema, inlining all property documentation instead of creating separate files.
77
80
  * @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
78
81
  */
79
82
  export function jsonschema2md(schema, options) {
@@ -90,6 +93,7 @@ export function jsonschema2md(schema, options) {
90
93
  includeProperties,
91
94
  header,
92
95
  skipProperties,
96
+ singleFile,
93
97
  } = options;
94
98
  if (!schema || typeof schema !== 'object') {
95
99
  throw Error('Input is not valid. Provide JSON schema either as Object or Array.');
@@ -123,7 +127,7 @@ export function jsonschema2md(schema, options) {
123
127
  const schemaLoader = loader();
124
128
 
125
129
  // collect data about the schemas and turn everything into a big object
126
- const schemas = pipe(
130
+ const allSchemas = pipe(
127
131
  normalized,
128
132
  // Checking if data contains the file path or its contents (JSON schema)
129
133
  map(({ fileName, fullPath, content }) => {
@@ -135,6 +139,10 @@ export function jsonschema2md(schema, options) {
135
139
  traverse,
136
140
  );
137
141
 
142
+ const schemas = singleFile
143
+ ? allSchemas.filter((item) => !item[s.parent])
144
+ : allSchemas;
145
+
138
146
  /**
139
147
  * @type {GeneratedOutput}
140
148
  */
@@ -175,6 +183,7 @@ export function jsonschema2md(schema, options) {
175
183
  includeProperties,
176
184
  exampleFormat,
177
185
  skipProperties,
186
+ singleFile,
178
187
  rewritelinks: (origin) => {
179
188
  const mddir = out;
180
189
  if (!mddir) {
@@ -283,7 +292,14 @@ export async function main(args) {
283
292
  .alias('s', 'skip')
284
293
  .array('s')
285
294
  .describe('s', 'name of a default property to skip in markdown (may be used multiple times), e.g. -s typefact -s proptable')
286
- .default('s', []);
295
+ .default('s', [])
296
+
297
+ .option('S', {
298
+ alias: 'single-file',
299
+ type: 'boolean',
300
+ describe: 'generate a single Markdown file per schema, inlining all property documentation',
301
+ default: false,
302
+ });
287
303
 
288
304
  const links = pipe(
289
305
  iter(argv),
@@ -303,6 +319,7 @@ export async function main(args) {
303
319
  const includeProperties = argv.p;
304
320
  const header = argv.h;
305
321
  const skipProperties = argv.s;
322
+ const singleFile = argv.S;
306
323
 
307
324
  const schemaExtension = argv.e;
308
325
 
@@ -335,6 +352,7 @@ export async function main(args) {
335
352
  includeProperties,
336
353
  header,
337
354
  skipProperties,
355
+ singleFile,
338
356
  });
339
357
 
340
358
  return 1;
@@ -43,8 +43,20 @@ export default function build({
43
43
  includeProperties = [],
44
44
  rewritelinks = (x) => x,
45
45
  exampleFormat = 'json',
46
- skipProperties = [],
46
+ skipProperties: rawSkipProperties = [],
47
+ singleFile = false,
47
48
  } = {}) {
49
+ const skipProperties = singleFile
50
+ ? [...new Set([...rawSkipProperties, 'definedinfact'])]
51
+ : rawSkipProperties;
52
+
53
+ function schemaLink(url, title, children) {
54
+ if (singleFile) {
55
+ return children;
56
+ }
57
+ return link(url, title, children);
58
+ }
59
+
48
60
  const formats = {
49
61
  'date-time': {
50
62
  label: i18n`date time`,
@@ -322,17 +334,22 @@ export default function build({
322
334
  * @param {*} param0
323
335
  */
324
336
  function makepropheader(required = [], ispattern = false, slugger) {
325
- return ([name, definition]) => tableRow([
326
- tableCell(ispattern ? inlineCode(name) : link(`#${slugger.slug(name)}`, '', text(name))), // Property
327
- tableCell(type(definition)),
328
- tableCell(text(required.indexOf(name) > -1 ? i18n`Required` : i18n`Optional`)),
329
- tableCell(nullable(definition)),
330
- tableCell(link(
331
- `${definition[s.slug]}.md`,
332
- `${definition[s.id]}#${definition[s.pointer]}`,
333
- text(definition[s.titles] && definition[s.titles][0] ? definition[s.titles][0] : i18n`Untitled schema`),
334
- )),
335
- ]);
337
+ return ([name, definition]) => {
338
+ const cells = [
339
+ tableCell(ispattern ? inlineCode(name) : link(`#${slugger.slug(name)}`, '', text(name))), // Property
340
+ tableCell(type(definition)),
341
+ tableCell(text(required.indexOf(name) > -1 ? i18n`Required` : i18n`Optional`)),
342
+ tableCell(nullable(definition)),
343
+ ];
344
+ if (!singleFile) {
345
+ cells.push(tableCell(schemaLink(
346
+ `${definition[s.slug]}.md`,
347
+ `${definition[s.id]}#${definition[s.pointer]}`,
348
+ text(definition[s.titles] && definition[s.titles][0] ? definition[s.titles][0] : i18n`Untitled schema`),
349
+ )));
350
+ }
351
+ return tableRow(cells);
352
+ };
336
353
  }
337
354
 
338
355
  /**
@@ -353,27 +370,33 @@ export default function build({
353
370
  const additionalproprows = (() => {
354
371
  if (additionalProps) {
355
372
  const any = additionalProps === true;
356
- return [tableRow([
373
+ const cells = [
357
374
  tableCell(text(i18n`Additional Properties`)),
358
375
  tableCell(any ? text('Any') : type(additionalProps)),
359
376
  tableCell(text(i18n`Optional`)),
360
377
  tableCell(any ? text('can be null') : nullable(additionalProps)),
361
- tableCell(any ? text('') : link(`${additionalProps[s.slug]}.md`, `${additionalProps[s.id]}#${additionalProps[s.pointer]}`, text(additionalProps[s.titles][0] || i18n`Untitled schema`))),
362
- ])];
378
+ ];
379
+ if (!singleFile) {
380
+ cells.push(tableCell(any ? text('') : schemaLink(`${additionalProps[s.slug]}.md`, `${additionalProps[s.id]}#${additionalProps[s.pointer]}`, text(additionalProps[s.titles][0] || i18n`Untitled schema`))));
381
+ }
382
+ return [tableRow(cells)];
363
383
  }
364
384
  return [];
365
385
  })();
366
386
 
367
387
  // const proprows = flist(map(iter(props || {}), makepropheader(required)));
368
388
 
389
+ const headerCells = [
390
+ tableCell(text(i18n`Property`)),
391
+ tableCell(text(i18n`Type`)),
392
+ tableCell(text(i18n`Required`)),
393
+ tableCell(text(i18n`Nullable`)),
394
+ ];
395
+ if (!singleFile) {
396
+ headerCells.push(tableCell(text(i18n`Defined by`)));
397
+ }
369
398
  return table('left', [
370
- tableRow([
371
- tableCell(text(i18n`Property`)),
372
- tableCell(text(i18n`Type`)),
373
- tableCell(text(i18n`Required`)),
374
- tableCell(text(i18n`Nullable`)),
375
- tableCell(text(i18n`Defined by`)),
376
- ]),
399
+ tableRow(headerCells),
377
400
  ...proprows,
378
401
  ...patternproprows,
379
402
  ...additionalproprows,
@@ -388,7 +411,7 @@ export default function build({
388
411
  paragraph([text(i18n`Type: `), text(i18n`an array where each item follows the corresponding schema in the following list:`)]),
389
412
  list(
390
413
  'ordered',
391
- [...items.map((schema) => listItem(paragraph(link(
414
+ [...items.map((schema) => listItem(paragraph(schemaLink(
392
415
  `${schema[s.slug]}.md`,
393
416
  i18n`check type definition`,
394
417
  text(gentitle(schema[s.titles], schema[keyword`type`])),
@@ -398,7 +421,7 @@ export default function build({
398
421
  return [listItem(paragraph(text(i18n`and all following items may follow any schema`)))];
399
422
  } else if (typeof additional === 'object') {
400
423
  return [listItem(paragraph([text(i18n`and all following items must follow the schema: `),
401
- link(
424
+ schemaLink(
402
425
  `${additional[s.slug]}.md`,
403
426
  i18n`check type definition`,
404
427
  text(gentitle(additional[s.titles], additional[keyword`type`])),
@@ -448,8 +471,13 @@ export default function build({
448
471
  const typelink = (() => {
449
472
  if (definition[keyword`title`] && typeof definition[keyword`title`] === 'string') {
450
473
  // if the type has a title, always create a link to the schema
451
- return [text(' ('), link(`${definition[s.slug]}.md`, '', text(definition[keyword`title`])), text(')')];
474
+ return [text(' ('), schemaLink(`${definition[s.slug]}.md`, '', text(definition[keyword`title`])), text(')')];
452
475
  } else if (!singletype || firsttype === keyword`object` || merged) {
476
+ // In single-file mode, omit the "Details" link entirely — there is no
477
+ // separate file to point to, and a bare "(Details)" label without a
478
+ // destination would be confusing. Titled types above still render their
479
+ // name via schemaLink (which removes the link markup while keeping the text).
480
+ if (singleFile) return [];
453
481
  return [text(' ('), link(`${definition[s.slug]}.md`, '', text(i18n`Details`)), text(')')];
454
482
  }
455
483
  return [];
@@ -473,7 +501,7 @@ export default function build({
473
501
  function makedefinedinfact(definition) {
474
502
  return listItem(paragraph([
475
503
  text(i18n`defined in: `),
476
- link(`${definition[s.slug]}.md`, `${definition[s.id]}#${definition[s.pointer]}`, text(definition[s.titles] && definition[s.titles][0] ? definition[s.titles][0] : i18n`Untitled schema`)),
504
+ schemaLink(`${definition[s.slug]}.md`, `${definition[s.id]}#${definition[s.pointer]}`, text(definition[s.titles] && definition[s.titles][0] ? definition[s.titles][0] : i18n`Untitled schema`)),
477
505
  ]));
478
506
  }
479
507
 
@@ -497,7 +525,7 @@ export default function build({
497
525
  }
498
526
 
499
527
  const additionalfacts = includeProperties.map((propname) => {
500
- if (definition[propname]) {
528
+ if (definition[propname] !== undefined) {
501
529
  return listItem(text(`${propname}: ${String(definition[propname])}`));
502
530
  }
503
531
  return undefined;
@@ -544,7 +572,7 @@ export default function build({
544
572
  ];
545
573
  } else if (depth > 0) {
546
574
  return [
547
- link(`${schema[s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[s.titles], schema[keyword`type`]))),
575
+ schemaLink(`${schema[s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[s.titles], schema[keyword`type`]))),
548
576
  ];
549
577
  } else {
550
578
  return [];
@@ -645,7 +673,7 @@ export default function build({
645
673
  constraints.push(paragraph([
646
674
  strong(text(i18n`schema`)), text(': '),
647
675
  text(i18n`the contents of this string should follow this schema: `),
648
- link(`${schema[keyword`contentSchema`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contentSchema`][s.titles], schema[keyword`contentSchema`][keyword`type`])))]));
676
+ schemaLink(`${schema[keyword`contentSchema`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contentSchema`][s.titles], schema[keyword`contentSchema`][keyword`type`])))]));
649
677
  }
650
678
 
651
679
  // https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4
@@ -664,12 +692,12 @@ export default function build({
664
692
  if (schema[keyword`minContains`] !== undefined && schema[keyword`contains`]) {
665
693
  // console.log('minContains!', schema[s.filename], schema[s.pointer]);
666
694
  constraints.push(paragraph([strong(text(i18n`minimum number of contained items`)), text(': '), text(`${i18n`this array may not contain fewer than ${String(schema[keyword`minContains`])} items that validate against the schema:`} `),
667
- link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))]));
695
+ schemaLink(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))]));
668
696
  }
669
697
  if (schema[keyword`maxContains`] !== undefined && schema[keyword`contains`]) {
670
698
  // console.log('maxContains!', schema[s.filename], schema[s.pointer]);
671
699
  constraints.push(paragraph([strong(text(i18n`maximum number of contained items`)), text(': '), text(`${i18n`this array may not contain more than ${String(schema[keyword`maxContains`])} items that validate against the schema:`} `),
672
- link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))]));
700
+ schemaLink(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))]));
673
701
  }
674
702
 
675
703
  // https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5
@@ -692,7 +720,8 @@ export default function build({
692
720
  if (schema[keyword`examples`] && schema[keyword`examples`].length > 0 && exampleFormat === 'yaml') {
693
721
  return [
694
722
  heading(level + 1, text(i18n`${simpletitle(schema)} Examples`)),
695
- ...schema[keyword`examples`].map((example) => paragraph(code('yaml', yaml.dump(example, undefined, 2)))),
723
+ // only drop the final newline: more would change `|+` block scalars
724
+ ...schema[keyword`examples`].map((example) => paragraph(code('yaml', yaml.dump(example, undefined, 2).replace(/\n$/, '')))),
696
725
  ];
697
726
  }
698
727
  if (schema[keyword`examples`] && schema[keyword`examples`].length > 0 && exampleFormat === 'json') {
@@ -847,11 +876,13 @@ export default function build({
847
876
  /**
848
877
  * Generates the properties section for a schema
849
878
  * @param {*} schema
879
+ * @param {*} slugger
880
+ * @param {number} level - Base level for this schema
850
881
  */
851
- function makeproperties(schema, slugger) {
882
+ function makeproperties(schema, slugger, level = 1) {
852
883
  if (schema[keyword`properties`] || schema[keyword`patternProperties`] || schema[keyword`additionalProperties`]) {
853
884
  return [
854
- heading(1, text(i18n`${simpletitle(schema)} Properties`)),
885
+ heading(level, text(i18n`${simpletitle(schema)} Properties`)),
855
886
  makeproptable(
856
887
  schema[keyword`properties`],
857
888
  schema[keyword`patternProperties`],
@@ -864,25 +895,49 @@ export default function build({
864
895
  schema[keyword`patternProperties`],
865
896
  schema[keyword`additionalProperties`],
866
897
  schema[keyword`required`],
867
- 1,
898
+ level,
868
899
  ),
869
900
  ];
870
901
  }
871
902
  return [];
872
903
  }
873
904
 
905
+ /**
906
+ * Calculates the appropriate base header level for a schema based on its position
907
+ * in the schema hierarchy. Schemas within composition constructs (allOf/anyOf/oneOf)
908
+ * that are nested within properties should use higher header levels to maintain
909
+ * proper document hierarchy.
910
+ *
911
+ * @param {string} pointer - JSON pointer path to the schema
912
+ * @returns {number} The base header level (1-6)
913
+ */
914
+ function calculateBaseLevel(pointer) {
915
+ // Only adjust level for schemas within composition constructs
916
+ const isCompositionSchema = /\/(allOf|anyOf|oneOf)\//.test(pointer);
917
+ if (!isCompositionSchema) return 1;
918
+
919
+ // Calculate property nesting depth by counting /properties/ segments
920
+ const propertyDepth = (pointer.match(/\/properties\//g) || []).length;
921
+ return propertyDepth > 0 ? propertyDepth : 1;
922
+ }
923
+
874
924
  console.log('generating markdown');
875
925
  return (schemas) => foldl(schemas, {}, (pv, schema) => {
876
926
  const slugger = new GhSlugger();
927
+
928
+ // Calculate the appropriate base level for this schema based on its position
929
+ // in the hierarchy (composition constructs within properties need higher levels)
930
+ const baseLevel = calculateBaseLevel(schema[s.pointer]);
931
+
877
932
  // eslint-disable-next-line no-param-reassign
878
933
  pv[schema[s.slug]] = root([
879
934
  // todo add more elements
880
935
  ...makeheader(schema),
881
- ...maketypesection(schema, 1),
882
- ...makeconstraintssection(schema, 1),
883
- ...makedefault(schema, 1),
884
- ...makeexamples(schema, 1),
885
- ...makeproperties(schema, slugger),
936
+ ...maketypesection(schema, baseLevel),
937
+ ...makeconstraintssection(schema, baseLevel),
938
+ ...makedefault(schema, baseLevel),
939
+ ...makeexamples(schema, baseLevel),
940
+ ...makeproperties(schema, slugger, baseLevel),
886
941
  ...makedefinitions(schema, slugger),
887
942
  ]);
888
943
  return pv;
@@ -44,7 +44,7 @@ const handler = ({
44
44
  meta[symbols.fullpath] = () => fullpath;
45
45
  meta[symbols.id] = (target) => {
46
46
  // if the schema has it's own ID, use it
47
- if (target[keyword`$id`]) {
47
+ if (typeof target[keyword`$id`] === 'string') {
48
48
  return target[keyword`$id`];
49
49
  }
50
50
  if (parent) {
@@ -153,6 +153,10 @@ const handler = ({
153
153
  if (referenced !== null) {
154
154
  // inject the referenced schema into the current schema
155
155
  Object.assign(retval, referenced);
156
+ if (referenced && referenced[keyword`$id`]) {
157
+ // Traversal deduplicates schema IDs, so reuse the referenced page's slug.
158
+ retval[myslug] = referenced[symbols.slug];
159
+ }
156
160
  } else {
157
161
  console.error('cannot resolve', basedoc);
158
162
  }
@@ -179,7 +183,7 @@ const handler = ({
179
183
  subschemas.set(retval, subschema);
180
184
  }
181
185
 
182
- if (subschema[keyword`$id`]) {
186
+ if (typeof subschema[keyword`$id`] === 'string') {
183
187
  // stow away the schema for lookup
184
188
  // eslint-disable-next-line no-param-reassign
185
189
  schemas.known[subschema[keyword`$id`]] = subschema;
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.0.11",
4
+ "version": "8.1.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "types",
7
7
  "bin": {
@@ -10,14 +10,13 @@
10
10
  "type": "module",
11
11
  "scripts": {
12
12
  "semantic-release": "npm run emit-types && npx semantic-release",
13
- "commit": "git-cz",
14
13
  "lint": "eslint .",
15
14
  "lint-fix": "eslint . --fix",
16
15
  "start": "node cli.js",
17
16
  "examples": "node cli.js -d examples/schemas/ -o examples/docs/ -x examples/generated-schemas/",
18
17
  "test": " c8 --reporter=text --reporter=lcov --check-coverage --branches 80 --statements 95 --lines 95 mocha && node lib/locales/update.js",
19
18
  "test-ci": "c8 --reporter=text --reporter=lcov --check-coverage --branches 80 --statements 95 --lines 95 mocha --reporter xunit --reporter-options output=./junit/test-results.xml",
20
- "emit-types": "npx -p typescript tsc",
19
+ "emit-types": "tsc",
21
20
  "prepare": "husky install"
22
21
  },
23
22
  "dependencies": {
@@ -26,42 +25,40 @@
26
25
  "@types/unist": "^3.0.3",
27
26
  "es2015-i18n-tag": "1.6.1",
28
27
  "ferrum": "1.9.4",
29
- "fs-extra": "11.3.4",
28
+ "fs-extra": "11.4.1",
30
29
  "github-slugger": "2.0.0",
31
- "js-yaml": "4.1.1",
30
+ "js-yaml": "4.3.2",
32
31
  "json-schema": "^0.4.0",
33
32
  "mdast-builder": "1.1.1",
34
33
  "mdast-util-to-string": "4.0.0",
35
- "readdirp": "5.0.0",
34
+ "readdirp": "5.1.1",
36
35
  "remark-gfm": "^4.0.0",
37
36
  "remark-parse": "11.0.0",
38
37
  "remark-stringify": "11.0.0",
39
38
  "unified": "11.0.5",
40
39
  "unist-util-inspect": "8.1.0",
41
- "yargs": "18.0.0"
40
+ "yargs": "18.2.0"
42
41
  },
43
42
  "devDependencies": {
44
- "@adobe/eslint-config-helix": "3.0.22",
45
- "@eslint/config-helpers": "0.5.3",
43
+ "@adobe/eslint-config-helix": "3.0.35",
44
+ "@eslint/config-helpers": "0.7.0",
46
45
  "@semantic-release/changelog": "6.0.3",
47
46
  "@semantic-release/git": "10.0.1",
48
- "@semantic-release/github": "12.0.6",
47
+ "@semantic-release/github": "12.0.11",
49
48
  "@types/fs-extra": "11.0.4",
50
49
  "@types/github-slugger": "2.0.0",
51
50
  "@types/js-yaml": "4.0.9",
52
- "@types/node": "24.12.0",
51
+ "@types/node": "24.19.2",
53
52
  "@types/yargs": "17.0.35",
54
- "c8": "10.1.3",
55
- "commitizen": "4.3.1",
56
- "cz-conventional-changelog": "3.3.0",
57
- "eslint": "9.4.0",
53
+ "c8": "11.0.0",
54
+ "eslint": "9.39.5",
58
55
  "husky": "9.1.7",
59
56
  "i18n-tag-schema": "2.5.0",
60
57
  "json-logic-js": "axa-ch/cyclic-schemas-test",
61
- "lint-staged": "16.3.2",
62
- "mocha": "11.7.5",
63
- "semantic-release": "25.0.3",
64
- "typescript": "5.9.3",
58
+ "lint-staged": "17.6.1",
59
+ "mocha": "11.8.0",
60
+ "semantic-release": "25.0.9",
61
+ "typescript": "6.0.3",
65
62
  "unist-util-select": "5.1.0"
66
63
  },
67
64
  "engines": {
@@ -80,9 +77,6 @@
80
77
  "*.js": "eslint"
81
78
  },
82
79
  "config": {
83
- "commitizen": {
84
- "path": "node_modules/cz-conventional-changelog"
85
- },
86
80
  "ghooks": {
87
81
  "pre-commit": "npx lint-staged"
88
82
  }
package/types/index.d.ts CHANGED
@@ -40,6 +40,8 @@
40
40
  * in markdown.
41
41
  * @param {string[]} [options.skipProperties=[]] - (optional) Name of a default property to
42
42
  * skip in markdown.
43
+ * @param {boolean} [options.singleFile=false] - (optional) Generate a single Markdown file
44
+ * per schema, inlining all property documentation instead of creating separate files.
43
45
  * @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
44
46
  */
45
47
  export function jsonschema2md(schema: JsonSchema | SchemaFiles, options: {
@@ -59,6 +61,7 @@ export function jsonschema2md(schema: JsonSchema | SchemaFiles, options: {
59
61
  includeProperties?: string[];
60
62
  header?: boolean;
61
63
  skipProperties?: string[];
64
+ singleFile?: boolean;
62
65
  }): GeneratedOutput;
63
66
  /**
64
67
  * Main function used in the CLI.
@@ -1,7 +1,8 @@
1
- export default function build({ header, links, includeProperties, rewritelinks, exampleFormat, skipProperties, }?: {
1
+ export default function build({ header, links, includeProperties, rewritelinks, exampleFormat, skipProperties: rawSkipProperties, singleFile, }?: {
2
2
  links?: {};
3
3
  includeProperties?: any[];
4
4
  rewritelinks?: (x: any) => any;
5
5
  exampleFormat?: string;
6
6
  skipProperties?: any[];
7
+ singleFile?: boolean;
7
8
  }): (schemas: any) => any;