Registry /
devops / json-schema-static-docs
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.fixEnsure 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'fixUse '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.fixReplace '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.fixExplicitly 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.fixVerify 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.
fixUse `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.
fixSet 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).
fixRun `npm install ajv` as a direct dependency.
TypeError: generator.generate is not a function
Using CommonJS require but not accessing default export properly.
fixUse `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.
fixCreate the input and output directories before running the generator.
Audit
Dependencies
ajvoptionalUsed internally for schema validation and compilation