Registry / devops / json-schema-static-docs

json-schema-static-docs

JSON →
library0.28.1jsnpmunverified

Generates static HTML documentation from JSON Schema files (YAML or JSON). Version 0.28.1, actively maintained with multiple releases per year. Supports draft-06, draft-07, draft-2019-09, and draft-2020-12. Key differentiator: outputs human-readable docs for API or data model schemas, unlike JSON Schema validation or tooling. Requires Node >=14. Not a UI component library; heads-down documentation generation.

npm install json-schema-static-docs
INSTALL
IMPORT
SIG · JSON-SCHEMA-STATIC
J
json-schema-static-docs
devopsjavascriptv0.28.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JsonSchemaStaticDocs
import JsonSchemaStaticDocs from 'json-schema-static-docs'
const jsonSchemaStaticDocs = require('json-schema-static-docs')
Package has a default export, named import does not work. Use default import.
JsonSchemaStaticDocs (CommonJS)
const JsonSchemaStaticDocs = require('json-schema-static-docs')
CommonJS require is still supported for Node <14 compatibility.
TypeScript usage
import JsonSchemaStaticDocs from 'json-schema-static-docs'; const opts: ConstructorParameters<typeof JsonSchemaStaticDocs>[0] = {};
const docs = new JsonSchemaStaticDocs(); // missing required options
TypeScript types are not bundled; use 'declare module' or check DefinitelyTyped.

Creates a documentation generator instance, configures paths and schema version, then generates HTML docs.

import JsonSchemaStaticDocs from 'json-schema-static-docs'; const generator = new JsonSchemaStaticDocs({ inputPath: './schema', outputPath: './docs', jsonSchemaVersion: 'https://json-schema.org/draft/2020-12/schema', ajvOptions: { allowUnionTypes: true } }); try { await generator.generate(); console.log('Documentation generated successfully.'); } catch (error) { console.error('Generation failed:', error); }
Debug
Known issues
gotchaAll schema documents must use the same JSON Schema version specified in options.jsonSchemaVersion. Mixing draft-07 and draft-2020-12 will cause validation errors.
fix
Ensure all schema files have a '$schema' property matching the configured version.
affects: >=0.1.0
breakingOptions object structure changed between v0.12 and v0.13: 'outputDir' renamed to 'outputPath'
fix
Use 'outputPath' instead of 'outputDir' in options.
affects: <0.13.0
deprecatedThe 'target' option was deprecated in v0.15.0 and removed in v0.20.0. Use 'jsonSchemaVersion' instead.
fix
Replace 'target' with 'jsonSchemaVersion' with a URI string.
affects: >=0.15.0 <0.20.0
gotchaWhen using draft-2020-12, you must also set 'jsonSchemaVersion' option; merely having '$schema' in schema files is not enough.
fix
Explicitly set 'jsonSchemaVersion' to 'https://json-schema.org/draft/2020-12/schema'.
affects: >=0.10.0
gotchaInput schema files can be .yml or .json, but file extension is used to parse; ensure they are well-formed.
fix
Verify YAML files parse correctly; use .json for strict JSON.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: JsonSchemaStaticDocs is not a constructor
Using require() incorrectly with named import, or missing default import in ESM.
fix
Use `import JsonSchemaStaticDocs from 'json-schema-static-docs'` or `const { default: JsonSchemaStaticDocs } = require('json-schema-static-docs')` in CommonJS.
Error: Invalid schema version. Supported versions: draft-06, draft-07, draft-2019-09, draft-2020-12
The '$schema' in schema file or options.jsonSchemaVersion is not one of the supported versions.
fix
Set options.jsonSchemaVersion to a valid URI (e.g., 'https://json-schema.org/draft/2020-12/schema') and ensure all schema files match.
Error: Cannot find module 'ajv'
Ajv is not installed or not in package.json dependencies (optional peer dependency).
fix
Run `npm install ajv` as a direct dependency.
TypeError: generator.generate is not a function
Using CommonJS require but not accessing default export properly.
fix
Use `const JsonSchemaStaticDocs = require('json-schema-static-docs').default;` or `const { default: JsonSchemaStaticDocs } = require('json-schema-static-docs');`.
Error: ENOENT: no such file or directory, open '...'
The inputPath or outputPath directory does not exist.
fix
Create the input and output directories before running the generator.
Upgrade
Version history
0.28.1latest on npm
Audit
Dependencies
ajvoptionalUsed internally for schema validation and compilation
Agent activity
4 hits · last 30 days
node
4
Resources
json-schema-static-docs — npm install json-schema-static-docs · libregistry