Skip to content

Quick start from docs doesn't work #117

New issue

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

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

Already on GitHub? # to your account

Closed
mauriciabad opened this issue Jul 23, 2024 · 7 comments
Closed

Quick start from docs doesn't work #117

mauriciabad opened this issue Jul 23, 2024 · 7 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@mauriciabad
Copy link
Contributor

Hi, I can't use the library because the quick start described in the docs doesn't work.

npx openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml \
  --output-dir src/api

It gives this error:

npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/openapi-qraft - Not found
npm error 404
npm error 404  'openapi-qraft@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: /Users/username/.npm/_logs/2024-07-23T22_42_02_653Z-debug-0.log

And if I change the command to @openapi-qraft/cli:

npx @openapi-qraft/cli --plugin tanstack-query-react --plugin openapi-typescript https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --output-dir src/api

I get this other error:

(node:7177) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/modules/esm/assert:88
        throw new ERR_IMPORT_ATTRIBUTE_MISSING(url, 'type', validType);
              ^

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///Users/username/.npm/_npx/09ac6d5fc70ce7ef/node_modules/@openapi-qraft/plugin/package.json" needs an import attribute of "type: json"
    at validateAttributes (node:internal/modules/esm/assert:88:15)
    at defaultLoad (node:internal/modules/esm/load:143:3)
    at async ModuleLoader.load (node:internal/modules/esm/loader:555:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:45)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19) {
  code: 'ERR_IMPORT_ATTRIBUTE_MISSING'
}

Node.js v22.2.0

Even doing it from the package.json doesn't work:

{
  "scripts": {
    "generate-client": "openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --output-dir src/api"
  },
  "devDependencies": {
    "@openapi-qraft/cli": "1.12.1"
  }
}

It also gives the ERR_IMPORT_ATTRIBUTE_MISSING error.

@radist2s radist2s self-assigned this Aug 5, 2024
@radist2s radist2s added the documentation Improvements or additions to documentation label Aug 6, 2024
@radist2s
Copy link
Collaborator

radist2s commented Aug 6, 2024

@mauriciabad, thank you for the report. I've updated the documentation.

@radist2s
Copy link
Collaborator

radist2s commented Aug 6, 2024

@mauriciabad, released v1.13.0-beta.2. If you get a chance, let me know if it helped.

@mauriciabad
Copy link
Contributor Author

Cool, now it works and doesn't crash.

@mauriciabad
Copy link
Contributor Author

But the punycode error is still being displayed.

Screenshot 2024-08-06 at 12 15 54 PM

@radist2s
Copy link
Collaborator

radist2s commented Aug 6, 2024

Unfortunately, this warning occurs when importing openapi-typescript ==> @redocly/openapi-core ==> node-fetch ==> whatwg-url@5.0.0. node-fetch is not updated for a year, but there is a rejected PR.

@mauriciabad
Copy link
Contributor Author

mauriciabad commented Aug 9, 2024

But fetch is available since Node.js@18 https://nodejs.org/docs/v20.16.0/api/globals.html#fetch
There's no need to have the node-fetch dependency.

I'll open a issue/PR in @redocly/openapi-core to see if they can stop using node-fetch.

@radist2s
Copy link
Collaborator

@mauriciabad, thanks for the collaboration. Looking forward to updating either node-fetch or redocly/openapi-core.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants