@adobe/jsonschema2md 8.1.3 → 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,12 @@
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
+
1
10
  ## [8.1.3](https://github.com/adobe/jsonschema2md/compare/v8.1.2...v8.1.3) (2026-12-04)
2
11
 
3
12
 
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
@@ -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
 
@@ -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) {
@@ -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.3",
4
+ "version": "8.1.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "types",
7
7
  "bin": {
package/types/index.d.ts CHANGED
@@ -38,7 +38,8 @@ export type GeneratedOutput = import("../types/api.js").GeneratedOutput;
38
38
  * @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
39
39
  * JSON files used for internationalization.
40
40
  * @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
41
- * @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.
42
43
  * @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
43
44
  * which should be also in the description of an element.
44
45
  * @param {boolean} [options.header=true] - (optional) Whether or not to include the header