Registry / devops / ramldt2jsonschema

ramldt2jsonschema

JSON →
library1.2.3jsnpmunverified

CLI and library to convert RAML 1.0 data types to JSON Schema Draft 4/6/7 and back. Stable version 1.2.3, maintained by the RAML organization. Uses webapi-parser under the hood. Key differentiators: bidirectional conversion (dt2js and js2dt), supports external references via basePath, and validation options. As of v1.2.3, there have been no recent releases; the package is in maintenance mode with known limitations (e.g., unsupported JSON Schema properties like allOf, oneOf) and issues (array items not properly converted).

npm install ramldt2jsonschema
INSTALL
IMPORT
SIG · RAMLDT2JSONSCHEMA
R
ramldt2jsonschema
devopsjavascriptv1.2.3
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.

dt2js
import { dt2js } from 'ramldt2jsonschema'
const dt2js = require('ramldt2jsonschema').dt2js
ESM import is identical to CJS destructure; package does not export default.
js2dt
import { js2dt } from 'ramldt2jsonschema'
const { js2dt } = require('ramldt2jsonschema')
Both ESM and CJS work; be careful to destructure correctly.
default import
import * as r2j from 'ramldt2jsonschema'
import r2j from 'ramldt2jsonschema'
No default export; use namespace import.

Converts a RAML data type named 'MyType' from a file 'types.raml' to JSON Schema using the library.

const { dt2js } = require('ramldt2jsonschema'); const path = require('path'); const fs = require('fs'); async function main() { const ramlData = fs.readFileSync(path.join(__dirname, 'types.raml'), 'utf-8'); try { const schema = await dt2js(ramlData, 'MyType'); console.log(JSON.stringify(schema, null, 2)); } catch (err) { console.error(err); } } main();
Debug
Known issues
breakingThe package uses webapi-parser which may break on certain RAML constructs.
fix
Ensure RAML files are valid per RAML 1.0 spec; check webapi-parser issues for known limitations.
affects: >=1.0.0
deprecatedjs2dt has known limitations: unsupported JSON Schema properties (allOf, oneOf, not, etc.) may produce incorrect conversions.
fix
Manually handle unsupported properties; consider using alternative tools for complex schemas.
affects: 1.2.3
gotchabasePath argument must be provided when external references are used; otherwise files will not be resolved.
fix
Always pass { basePath: ... } as third argument when using !include or $ref.
affects: >=1.0.0
gotchaArray items property not properly converted when items is an array (tuple typing) in js2dt (see issue #111).
fix
Avoid using tuple arrays in JSON Schema if converting to RAML; stay updated on fixes.
affects: <=1.2.3
deprecatedGreenkeeper badge is outdated; package may not be actively updated.
fix
Check for newer versions; consider forking or using alternatives.
affects: 1.2.3
Errors
Common errors & fixes
Error: Cannot find module 'webapi-parser'
Missing peer dependency webapi-parser
fix
npm install webapi-parser
TypeError: dt2js is not a function
Incorrect import (default import used)
fix
Use named import: const { dt2js } = require('ramldt2jsonschema')
Error: Input RAML type not found
Type name argument does not exist in RAML file
fix
Verify the type name exists in the RAML file; check spelling and case.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies
webapi-parserrequiredcore parsing dependency
js-yamlrequiredused in js2dt example for YAML output
ajvoptionaloptional validation for JSON Schema output
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
ramldt2jsonschema — npm install ramldt2jsonschema · libregistry