jsonschema2md: ERR_INVALID_ARG_TYPE: The "path" argument must be of type string. Received undefined
Expected Behaviour
Converts JSON schema to MD.
Actual Behaviour
The following error is thrown:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:371:5)
at validateString (node:internal/validators:119:11)
at Object.parse (node:path:913:5)
at Object.get (node_modules\@adobe\jsonschema2md\lib\schemaProxy.js:123:27)
at Function.values (<anonymous>)
at reducer (node_modules\@adobe\jsonschema2md\lib\traverseSchema.js:42:23)
at Array.reduce (<anonymous>)
at reducer (\node_modules\@adobe\jsonschema2md\lib\traverseSchema.js:36:41)
at Array.reduce (<anonymous>)
at reducer (node_modules\@adobe\jsonschema2md\lib\traverseSchema.js:42:39) {
code: 'ERR_INVALID_ARG_TYPE'
Reproduce Scenario (including but not limited to)
Steps to Reproduce
Running with jsonschema2md -d input -o output
JSON Schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ItemLink": {
"properties": {
"allowedSuccessors": {
"items": {
"type": "string"
},
"type": "array"
},
"class": {
"type": "string"
}
},
"type": "object"
},
"ItemLinkOptions": {
"properties": {
"allowedLinks": {
"items": {
"$ref": "#/definitions/ItemLink"
},
"type": "array"
},
"maxIncoming": {
"type": "number"
},
"maxOutgoing": {
"type": "number"
}
},
"type": "object"
}
},
"properties": {
"id": {
"type": "string"
},
"items": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/ItemLink"
}
]
},
"type": "array"
},
"version": {
"type": "string"
}
},
"type": "object"
}
Platform and Version
Windows 10
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 20
- Comments: 16
Commits related to this issue
- test(markdown): add test for failing self-references test for #392 — committed to adobe/jsonschema2md by trieloff 2 years ago
As a temporal solution you can use an explicit local URI in your
$ref
’s, pointing to the same file.So in your schema, instead of:
"$ref": "#/definitions/ItemLink"
Try:
"$ref": "./xxx.schema.json/#/definitions/ItemLink"
This is not ideal, and having no explicit URI should work per spec, but I’m not familiar enough with this library to know when it broke or how to fix it in a PR.
This can be solved by adding to your schema an $id with the path to itself from the root of the project.
Still getting this with v7.1.5, any updates?
As gloaysa mentioned, this can be solved by adding an
$id
to your schema; the value can be any string that uniquely identifies it, not necessarily the path to itself.Year passed, still totally unusable. Nice!
@trieloff a fix would be highly appreciated.
Seams to be an ugly workaround which does not lead to portable code