Skip to content

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

Open
@cogwirrel

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions