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

Suggestion: Prettier like parameters to allow for easy script usage #16

Open
wedi opened this issue Oct 25, 2021 · 6 comments
Open

Suggestion: Prettier like parameters to allow for easy script usage #16

wedi opened this issue Oct 25, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@wedi
Copy link

wedi commented Oct 25, 2021

Hi,
first of all, thanks for your tool that helps keeping API definitions and commits clean. ❤️

prettier has a CLI that makes it really easy to use it in scripts, e.g. in CI:

  • --write replaces the input files
  • it accepts (multiple) paths/glob patterns
  • --check makes it fail if something changed

That might be a nice addition to openapi-format, too, although you can work arround the first two with find . -name '*.yaml' -exec yarn run openapi-format {} -o {} \;.

@thim81
Copy link
Owner

thim81 commented Oct 25, 2021

Hi @wedi

Thanks for your input.

Do I understand correct that you are requesting the option "--write" which executes the formatting based on a glob matching patterns? Like prettier does?

@wedi
Copy link
Author

wedi commented Oct 25, 2021

Exactly. That would make things much tidier.

--check is nice to have, too, but you could work arround that with git diff --exit-code.

@thim81
Copy link
Owner

thim81 commented Nov 18, 2021

@wedi It will be a bit more work, since I would have to scan folders for patterns.

I understand the local usage use case for ---write

@wedi
Copy link
Author

wedi commented Nov 20, 2021

Maybe you could use a library for that, e.g. https://www.npmjs.com/package/glob

@thim81 thim81 added the enhancement New feature or request label Jan 5, 2022
@bodograumann
Copy link

This would be extremely helpful.
You don't even have to implement the globbing as a first step.
Just doing npx openapi-format --write *.yaml and npx openapi-format --check *.yaml in the CI without any output format would things make easier.

@thim81
Copy link
Owner

thim81 commented Sep 10, 2024

hi @wedi & @bodograumann

Although it is not exactly the feature requested, in release v1.23.0, we introduced the support for .openapiformatrc which allows you to define all openapi-format options in 1 file, that will be automatically picked up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants