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

inline openapi specs fail to load in a node environment #1730

Open
cogwirrel opened this issue Feb 18, 2025 · 0 comments
Open

inline openapi specs fail to load in a node environment #1730

cogwirrel opened this issue Feb 18, 2025 · 0 comments
Labels
bug 🔥 Something isn't working

Comments

@cogwirrel
Copy link

cogwirrel commented Feb 18, 2025

Description

If you use the createClient function in a node environment and pass in an OpenAPI spec as an object, createClient attempts to read the current directory instead of using the spec.

eg:

createClient({
  input: { openapi: '3.0.3', info: ... },
  output: 'out',
  dryRun: true,
  plugins: ['@hey-api/client-fetch'],
});

Results in the error:

🔥 Unexpected error occurred. Error opening file "/path/to/my/project" 
EISDIR: illegal operation on a directory, read

Reproducible example or configuration

https://github.com/cogwirrel/heyapi-bug-inline-spec

npm install
npx node broken.js

Notice that it works ok if we pretend we're in a browser:

// Pretend to be in a web environment
global.window = {};
global.location = { href: 'https://some-website/' };

await createClient({
  input: { openapi: '3.0.3', info: ... },
  output: 'out',
  dryRun: true,
  plugins: ['@hey-api/client-fetch'],
});

OpenAPI specification (optional)

No response

System information (optional)

Node v20.18.0

@cogwirrel cogwirrel added the bug 🔥 Something isn't working label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant