thim81 / openapi-format

Format an OpenAPI document by ordering, formatting and filtering fields.
MIT License
79 stars 14 forks source link

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

Open wedi opened 2 years ago

wedi commented 2 years ago

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:

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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

bodograumann commented 1 year ago

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.