Skip to content

Bulk types generation #1091

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
roman-certn opened this issue Apr 26, 2023 · 3 comments · Fixed by #1281
Closed

Bulk types generation #1091

roman-certn opened this issue Apr 26, 2023 · 3 comments · Fixed by #1281
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library question Further information is requested

Comments

@roman-certn
Copy link

roman-certn commented Apr 26, 2023

Description

Previously we were running the following command:
npx openapi-typescript 'generated-schemas/**/*.yml' --output generated-schemas

It would get all .yml files in the folder and bulk convert them into appropriate .ts files.

Version 6.2.3 broke it and started throwing the following error:

Error: EISDIR: illegal operation on a directory, open `/path/generated-schemas'
    at Object.openSync (node:fs:585:3)
    at Object.writeFileSync (node:fs:2155:35)
    at generateSchema (file:///path/node_modules/openapi-typescript/bin/cli.js:122:8)
    at async file:///path/node_modules/openapi-typescript/bin/cli.js:195:7
    at async Promise.all (index 0)
    at async main (file:///path/node_modules/openapi-typescript/bin/cli.js:185:3) {
  errno: -21,
  syscall: 'open',
  code: 'EISDIR',
  path: '/path/generated-schemas'
}
error Command failed with exit code 1.

Our solution was to convert each file separately, but would be great to get the old way working.

npx openapi-typescript generated-schemas/file1.yml --output generated-schemas/file1.ts
npx openapi-typescript generated-schemas/file2.yml --output generated-schemas/file2.ts

Reproduction

Version 6.2.0 works

@drwpow drwpow added bug Something isn't working question Further information is requested labels May 15, 2023
@drwpow
Copy link
Contributor

drwpow commented May 15, 2023

Question: does 'generated-schemas/**/*.yml' return multiple schemas? With the glob generation, even using asterisks, if only one schema is found then it will run in single-file mode.

If you’re able to put together a minimal reproduction I’d be able to investigate further. But I’m not sure exactly what the issue is just from your error message without knowing more about the filesystem paths.

@roman-certn
Copy link
Author

I have 2 different schemas in generated-schemas folder, like this:

generated-schemas/
  schema1.yml
  schema1.ts
  schema2.yml
  schema2.ts

Using version 6.2.0, you can run this command to bulk generate schemas in a folder:
npx openapi-typescript 'generated-schemas/**/*.yml' --output generated-schemas

6.2.3 broke this feature and it started throwing errors.

You should be able to reproduce the issue by having multiple schemas in one folder and running the command from above.

@drwpow drwpow added the openapi-ts Relevant to the openapi-typescript library label May 22, 2023
@SchabaJo
Copy link
Contributor

Hi! We're also affected by this issue. All output files are named like their input files and placed right next to them, eg:

  • path/to/schema.yaml --> path/to/schema.ts
  • path/to/another/schema.yaml --> path/to/another/schema.ts

The parameter --output is not respected at all, as the files above were generated using yarn openapi-typescript path/to/**/*.yaml --output types.

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

Successfully merging a pull request may close this issue.

3 participants