jsonschema2md icon indicating copy to clipboard operation
jsonschema2md copied to clipboard

ERR_INVALID_ARG_TYPE: The "path" argument must be of type string. Received undefined

Open dominic-simplan opened this issue 2 years ago • 15 comments

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

dominic-simplan avatar Feb 03 '22 14:02 dominic-simplan

Having the same problem on OSX.

stevecox avatar Feb 10 '22 00:02 stevecox

+1 Windows 10

RawleCurtis avatar Feb 12 '22 00:02 RawleCurtis

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.

CarlosBergillos avatar Feb 13 '22 17:02 CarlosBergillos

Blocked by #395

trieloff avatar Feb 14 '22 10:02 trieloff

I have the same issue whenever I use a $ref. (Running on Ubuntu)

Finkman avatar Mar 10 '22 08:03 Finkman

Same here, probably because the Schema director is expecting multiple schemas. Maybe a workaround to develop is to be able to give in input just a single schema file instead of a schema directory ?

leverdeterre avatar Apr 04 '22 09:04 leverdeterre

This can be solved by adding to your schema an $id with the path to itself from the root of the project.

gloaysa avatar May 20 '22 10:05 gloaysa

Seams to be an ugly workaround which does not lead to portable code

Finkman avatar May 20 '22 11:05 Finkman

Having the same problem on OSX.

huruji avatar Jun 08 '22 17:06 huruji

@trieloff i see #395 is merged. Is it possible to progress a fix?

grillba avatar Sep 02 '22 06:09 grillba

@trieloff a fix would be highly appreciated.

zurmuehl avatar Oct 04 '22 15:10 zurmuehl

Still getting this with v7.1.5, any updates?

slhck avatar Feb 10 '23 10:02 slhck

Year passed, still totally unusable. Nice!

pkit avatar May 06 '23 17:05 pkit

This can be solved by adding to your schema an $id with the path to itself from the root of the project.

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.

deepakkumar18035 avatar May 27 '23 06:05 deepakkumar18035

Same issue here

RuiRomano avatar Jun 07 '23 17:06 RuiRomano

Any update on this issue? I'm having the same problem and the "$id" workaround unfortunately is not an option

vivdesign avatar Apr 24 '24 16:04 vivdesign