joxoo / jsonschema-md

Generate Documentation from json-schema as Markdown
5 stars 3 forks source link

`Error: ENOENT, no such file or directory` when including file extension. #6

Open retrosight opened 7 years ago

retrosight commented 7 years ago

Input

"defaultValue": {
  "type": "object",
  "items": { "$ref": "customField.schema.json" },
  "description": "The source or content of the default value for the form field"
}

Result

➜  current git:(master) ✗ jsonschema-md allocationFormField.schema.json > temp.md
Error: ENOENT, no such file or directory '{fullpath}/customField.schema.json.json'Error: ENOENT, no such file or directory '{fullpath}/customField.schema.json.json'
    at Error (native)
    at Object.fs.openSync (fs.js:500:18)
    at Object.fs.readFileSync (fs.js:352:15)
    at parser._loadReferencesForItem (/usr/local/lib/node_modules/jsonschema-md/src/parser.js:17:30)
    at parser._loadReferencesForItem (/usr/local/lib/node_modules/jsonschema-md/src/parser.js:25:27)
    at /usr/local/lib/node_modules/jsonschema-md/src/parser.js:54:26
    at Function.forIn (/usr/local/lib/node_modules/jsonschema-md/node_modules/lodash/dist/lodash.js:2024:15)
    at parser._parseProperties (/usr/local/lib/node_modules/jsonschema-md/src/parser.js:53:7)
    at parser._parse (/usr/local/lib/node_modules/jsonschema-md/src/parser.js:101:14)
    at parser.parse (/usr/local/lib/node_modules/jsonschema-md/src/parser.js:107:14)%

It works if I remove the file extension:

"defaultValue": {
  "type": "object",
  "items": { "$ref": "customField.schema" },
  "description": "The source or content of the default value for the form field"
}
retrosight commented 7 years ago

Issue appears to be...

parser.prototype._loadReferencesForItem = function (item) {
    var ref, json;

    if (item.$ref) {
        ref = path.resolve(this.path, item.$ref.replace("#/", "") + '.json'); <-- ...right here.