Skip to content

Cannot read properties of undefined (reading 'schema') #975

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

Closed
1 task
bachu-shannon opened this issue Nov 9, 2022 · 6 comments · Fixed by #977
Closed
1 task

Cannot read properties of undefined (reading 'schema') #975

bachu-shannon opened this issue Nov 9, 2022 · 6 comments · Fixed by #977
Labels
bug Something isn't working question Further information is requested

Comments

@bachu-shannon
Copy link

Description

A brief description of the bug.

✨ openapi-typescript 6.0.1
file:///C:/Users/ba4yr/AppData/Local/npm-cache/_npx/21d31b7563e6adbc/node_modules/openapi-typescript/dist/load.js:141
    walk(options.schemas[schemaID].schema, (rawNode, nodePath) => {
                                   ^

TypeError: Cannot read properties of undefined (reading 'schema')
m-cache/_npx/21d31b7563e6adbc/node_modules/openapi-typescript/bin/cli.js:156:5)
Name Version
openapi-typescript v6.0.1
Node.js v16.17.0
OS + version Windows 10.

Reproduction

npx openapi-typescript {LINK} --output {PATH}

Expected result

(in case it’s not obvious)

Checklist

@drwpow drwpow added bug Something isn't working question Further information is requested labels Nov 9, 2022
@drwpow
Copy link
Contributor

drwpow commented Nov 9, 2022

This sounds like a bug but I’m not able to reproduce it without the schema. Could you provide either the schema or a small example reproducing the bug?

@dolegi
Copy link

dolegi commented Nov 9, 2022

I have the same issue. v5.4.1 works. But v6.0.1 causes this error. Can't share the schema public unfortunately, just wanted to add it another data point where it's happened and I'll try and get an example schema I can share

Name Version
openapi-typescript v6.0.1
Node.js v16.17.1
OS + version Windows 10.

@wolfy1339
Copy link

I have this issue as well. I'm compiling the GitHub Next schema

See octokit/octokit-next.js#101 (comment)

@drwpow
Copy link
Contributor

drwpow commented Nov 9, 2022

@wolfy1339 thank you! I will add Octokit to the test suite. We were testing the GitHub REST API but not Octokit. Will get this fixed later today.

@drwpow
Copy link
Contributor

drwpow commented Nov 10, 2022

Fixed a known occurrence of this issue in the Octokit schema. If this occurs for anyone again, please share a reproducible example and we can get it fixed! 🙏

@fehnomenal
Copy link

fehnomenal commented Nov 10, 2022

Sorry, ignore this post. The problem was the missing file extension in the url.

Nice, that this got fixed so fast. But sadly I get the same error with this schema: https://rmi-services.tecalliance.net/swagger/docs/4_2_22290_1241

> pnpm openapi-typescript https://rmi-services.tecalliance.net/swagger/docs/4_2_22290_1241 --output ./src/tec-rmi/schema.ts
✨ openapi-typescript 6.0.2
file:///.../node_modules/.pnpm/[email protected]/node_modules/openapi-typescript/dist/load.js:140
    const currentSchema = options.schemas[schemaID].schema;
                                                    ^

TypeError: Cannot read properties of undefined (reading 'schema')
    at load (file:///.../node_modules/.pnpm/[email protected]/node_modules/openapi-typescript/dist/load.js:140:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async openapiTS (file:///.../node_modules/.pnpm/[email protected]/node_modules/openapi-typescript/dist/index.js:37:5)
    at async generateSchema (file:///.../node_modules/.pnpm/[email protected]/node_modules/openapi-typescript/bin/cli.js:89:18)
    at async main (file:///.../node_modules/.pnpm/[email protected]/node_modules/openapi-typescript/bin/cli.js:156:5)

Node.js v18.9.0
Exception: pnpm exited with 1

Edit: Could the cause be that the url has no file extension? OK, yes that was it. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants