thim81 / openapi-format

Format an OpenAPI document by ordering, formatting and filtering fields.
https://openapi-format-playground.vercel.app
MIT License
100 stars 15 forks source link

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

Open wedi opened 3 years ago

wedi commented 3 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 3 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 3 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 3 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 3 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.

thim81 commented 2 months ago

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.