Skip to content

schema input from stdin #870

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

Merged
merged 3 commits into from
Mar 28, 2022
Merged

schema input from stdin #870

merged 3 commits into from
Mar 28, 2022

Conversation

kgtkr
Copy link
Contributor

@kgtkr kgtkr commented Feb 1, 2022

fix: #869

@changeset-bot
Copy link

changeset-bot bot commented Feb 1, 2022

⚠️ No Changeset found

Latest commit: bea4963

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I’m in favor of this change and would like to see this merged. However, before we do, could you please add a test to cli.test.js?

There is a test for stdout already; please add one there for stdin so we can be sure there are no regressions with this in the future.

@codecov
Copy link

codecov bot commented Feb 13, 2022

Codecov Report

Merging #870 (e13a9f1) into main (1151a54) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #870   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines            1         1           
=========================================
  Hits             1         1           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34b9acb...e13a9f1. Read the comment docs.

@kgtkr kgtkr requested a review from drwpow February 15, 2022 08:31
@kgtkr
Copy link
Contributor Author

kgtkr commented Feb 15, 2022

@drwpow
Thank you for your review. I added a test.

@drwpow
Copy link
Contributor

drwpow commented Feb 15, 2022

Nice test! It looks like we have a failure on windows:

 Error: Could not locate /dev/stdin
    at resolveSchema (file:///D:/a/openapi-typescript/openapi-typescript/dist/load.js:39:15)
    at openapiTS (file:///D:/a/openapi-typescript/openapi-typescript/dist/index.js:30:52)
    at generateSchema (file:///D:/a/openapi-typescript/openapi-typescript/bin/cli.js:83:24)
    at main (file:///D:/a/openapi-typescript/openapi-typescript/bin/cli.js:148:11)
    at file:///D:/a/openapi-typescript/openapi-typescript/bin/cli.js:183:1
    at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Maybe we can do something different if os.platform is win32?

@Richard87
Copy link

I would love this feature as well! I saw the readline-sync library on npmjs.org with 760'000 weekly downloads, but the logic seemed pretty complicated to get right in all environments, maybe pull in that library if you want stdin support for windows (and powershell +++) instead of managing it yourself?

https://www.npmjs.com/package/readline-sync
https://github.com/anseki/readline-sync/blob/master/lib/readline-sync.js

@kgtkr
Copy link
Contributor Author

kgtkr commented Mar 10, 2022

Sorry I'm late. I was able to fix it.
But in CI, pnpm install fails in one place. I think it will be sucuceed if you re-execute.

@drwpow
Copy link
Contributor

drwpow commented Mar 28, 2022

Thanks for fixing! 🙏 Re-running the test now to see if it’s just flaky (and will fix in a followup)

@drwpow drwpow merged commit a18b8a6 into openapi-ts:main Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Input yaml from stdin
3 participants