Open vanp33 opened 4 years ago
Hi @vanp33.
How exactly didn't it work? Please describe what's the expected and actual output.
Thanks!
Hi @postatum , the type, which is referenced by market_raml_file is not resolved. In the json file I got
"market": {
"description": "A Market"
// type is missing
}
It is expected that the type of market is resolved with the schema defined in the market_raml_file
References do work with command line, but they do not work in the javascript library.
I have two small RAML files. account.raml:
mediaType: application/json
properties:
id:
type: integer
description: Internal ID of an account
And linktest.raml:
mediaType: application/json
types:
account: !include account.raml
/accounts:
get:
responses:
200:
body:
application/json:
type: account
when I run in command line
dt2js linktest.raml account
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/account",
"definitions": {
"account": {
"type": "object",
"additionalProperties": true,
"required": [
"id"
],
"properties": {
"id": {
"type": "integer",
"description": "Internal ID of an account"
}
}
}
}
}
This is correct.
However, when I use the following server file:
const r2j = require("ramldt2jsonschema");
const join = require("path").join;
const fs = require("fs");
const currentDir = __dirname;
const ramlData = fs.readFileSync(join(currentDir, 'linktest.raml')).toString()
const main = async function () {
let schema;
try {
let schema = await r2j.dt2js(ramlData, "account");
console.log(JSON.stringify(schema, null, 2));
} catch (e) {
console.log(e);
}
return;
};
main();
And I launch from command line
node server.js
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/account",
"definitions": {
"account": true
}
}
The JSON Schema output is broken.
Any update on this?
Hi, at our project we have a bunch of raml-files, which have references to other ramls. Something like this:
I tried the example code but it didn't work. I don't know if there is something need to be configured in order to work? js:
Best regards