Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dominic-simplan opened this issue Feb 3, 2022 · 16 comments
Labels

Comments

@dominic-simplan
Copy link

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

@stevecox
Copy link

Having the same problem on OSX.

@RawleCurtis
Copy link

RawleCurtis commented Feb 12, 2022

+1 Windows 10

@CarlosBergillos
Copy link

CarlosBergillos commented Feb 13, 2022

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.

trieloff added a commit that referenced this issue Feb 14, 2022
@trieloff trieloff added the bug label Feb 14, 2022
@trieloff
Copy link
Collaborator

Blocked by #395

@Finkman
Copy link

Finkman commented Mar 10, 2022

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

@leverdeterre
Copy link

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 ?

@gloaysa
Copy link

gloaysa commented May 20, 2022

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

@Finkman
Copy link

Finkman commented May 20, 2022

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

@huruji
Copy link

huruji commented Jun 8, 2022

Having the same problem on OSX.

@grillba
Copy link

grillba commented Sep 2, 2022

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

@zurmuehl
Copy link

zurmuehl commented Oct 4, 2022

@trieloff a fix would be highly appreciated.

@slhck
Copy link

slhck commented Feb 10, 2023

Still getting this with v7.1.5, any updates?

@pkit
Copy link

pkit commented May 6, 2023

Year passed, still totally unusable. Nice!

@deepakkumar18035
Copy link

deepakkumar18035 commented May 27, 2023

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.

@RuiRomano
Copy link

Same issue here

@vivdesign
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests