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

Cannot convert undefined or null to object. #76

Closed
BusterNeece opened this issue Jan 15, 2020 · 3 comments
Closed

Cannot convert undefined or null to object. #76

BusterNeece opened this issue Jan 15, 2020 · 3 comments

Comments

@BusterNeece
Copy link

Attempting to run API Platform client generation on a very basic API Platform with no particularly complex entities set up, running into this error when attempting to parse with OpenAPI version 3:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /home/node/.npm/_npx/233/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:19:34
    at Array.map (<anonymous>)
    at Object.default_1 [as default] (/home/node/.npm/_npx/233/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:16:27)
    at /home/node/.npm/_npx/233/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/parseOpenApi3Documentation.js:12:45
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

the JSON I'm handing it, which is autogenerated by API Platform, is valid and the OpenAPI spec says it's completely fine, except it's missing "description" fields on the properties (though these aren't necessary by my understanding).

Given the relative opacity of this error it's not clear where it's failing to parse my JSON. I've spent several hours spinning my wheels on this with no progress, and I'm starting to feel quite bad about it, so any help would be much appreciated.

@soyuka
Copy link
Member

soyuka commented Jan 17, 2020

Looks like Object.keys(response.paths) can't be called, the response doesn't have any paths?

I'd like to reproduce if you could check what data is given to the handleJson file maybe we can have more informations.

@jfoliveira
Copy link

@soyuka I could reproduce it using the API-Platform demo when specifying --format openapi3:

npx @api-platform/client-generator https://demo.api-platform.com/docs.json src/ --resource Book --format openapi3

Exception:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:19:34
    at Array.map (<anonymous>)
    at Object.default_1 [as default] (/Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/handleJson.js:16:27)
    at /Users/{myuser}/.npm/_npx/10629/lib/node_modules/@api-platform/client-generator/node_modules/@api-platform/api-doc-parser/lib/openapi3/parseOpenApi3Documentation.js:12:45

I tried but couldn't find a fix though.

@soyuka
Copy link
Member

soyuka commented Feb 17, 2020

Can you check the json response and if it has some paths? Maybe that a proper fix would be to throw a better error?

soyuka added a commit that referenced this issue Aug 4, 2020
@soyuka soyuka closed this as completed in 965f98b Aug 5, 2020
soyuka added a commit that referenced this issue Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants