![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
ramldt2jsonschema
Advanced tools
Readme
CLI & Library to convert a RAML 1.0 DataType to a JSON Schema Draft 4, and back. Uses webapi-parser under the hood.
npm install -g ramldt2jsonschema
This will install two command-line tools:
dt2js
: RAML data type <> JSON schemajs2dt
: JSON schema <> RAML data typedt2js <ramlFile> <ramlTypeName> --draft=[version] [--validate]
Options
<ramlFile>
Path to a file containing at least one RAML data type (e.g. path/to/api.raml
)<ramlTypeName>
RAML type name to convert to JSON schema--draft
Optional JSON Shema draft version to convert to. Supported values are: 04
, 06
and 07
(default)--validate
Validate output JSON Schema with Ajv. Throws an error if schema is invalid. Requires "ajv" to be installed. (default: false)js2dt <jsonFile> <ramlTypeName> [--validate]
Options
<jsonFile>
Path to a JSON schema file (e.g. path/to/schema.json
)<ramlTypeName>
RAML type name to give to the exported RAML data type--validate
Validate output RAML with webapi-parser. Throws an error if it is invalid. (default: false)npm install ramldt2jsonschema --save
const r2j = require('ramldt2jsonschema')
const join = require('path').join
const fs = require('fs')
const filePath = join(__dirname, 'complex_cat.raml')
const ramlData = fs.readFileSync(filePath).toString()
async function main () {
let schema
try {
schema = await r2j.dt2js(ramlData, 'Cat')
} catch (err) {
console.log(err)
return
}
console.log(JSON.stringify(schema, null, 2))
}
main()
const r2j = require('ramldt2jsonschema')
const join = require('path').join
const fs = require('fs')
const yaml = require('js-yaml')
const filePath = join(__dirname, 'complex_cat.json')
const jsonData = fs.readFileSync(filePath).toString()
async function main () {
let raml
try {
raml = await r2j.js2dt(jsonData, 'Cat')
} catch (err) {
console.log(err)
return
}
console.log('#%RAML 1.0 Library\n')
console.log(yaml.safeDump(raml, { 'noRefs': true }))
}
main()
When the input contains external references (!include
, uses:
, $ref
, etc.) and the referred files are not in the same directory as the script it is being ran from, you may provide a third argument to both dt2js
and js2dt
. The argument must be an object with a basePath
key. All references will then be resolved relative to that base path.
Example of using basePath
argument in dt2js:
// Script below ran from /home/john/where/ever/
// Reference is located at /home/john/schemas/simple_person.json
const raml2json = require('ramldt2jsonschema')
const ramlStr = `
#%RAML 1.0 Library
types:
Person: !include simple_person.json
`
const basePath = '/home/john/schemas/' // or '../../schemas/'
const schema = raml2json.dt2js(ramlStr, 'Person', { basePath: basePath })
console.log(JSON.stringify(schema, null, 2))
dependencies, exclusiveMaximum, exclusiveMinimum, items (array value), allOf, oneOf, not, format (email, hostname, ipv4, ipv6, uri), readOnly
$schema, additionalItems, contains, id, $id, propertyNames, definitions, links, fragmentResolution, media, pathStart, targetSchema
items
property is not properly converted to RAML when it's value is an array of schemas (see #111)Apache 2.0
FAQs
Converts a RAML data type into JSON schema, and back
The npm package ramldt2jsonschema receives a total of 40,486 weekly downloads. As such, ramldt2jsonschema popularity was classified as popular.
We found that ramldt2jsonschema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.