python-openapi / openapi-spec-validator

OpenAPI Spec Validator is a CLI, pre-commit hook and python package that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification.
Apache License 2.0
329 stars 61 forks source link

Allow Multiple Spec Files #250

Closed channyein87 closed 1 year ago

channyein87 commented 1 year ago

Is there a way to use pre-commit hook to run against multiple spec files? I have multiple spec files in the repo for deploying multiple API Gateways (e.g. api1.openapi.yaml, api2.openapi.yaml).

p1c2u commented 1 year ago

Hi @channyein87

the hook should run against all files that meet the name pattern .*openapi.*\.(json|yaml|yml)

If you're looking for option that you can specify your files , there is no atm.

channyein87 commented 1 year ago

Hi @p1c2u

Thanks for the reply.

I got the below error when trying to use multiple spec files. Please refer the sample test workflow below. https://github.com/channyein87/temp/actions/runs/5639881716/job/15275717895#step:4:106

openapi-spec-validator...................................................Failed
- hook id: openapi-spec-validator
- exit code: 2

usage: openapi-spec-validator [-h] [--errors {best-match,all}]
                              [--schema {2.0,3.0.0,3.1.0,detect}]
                              filename
openapi-spec-validator: error: unrecognized arguments: src/openapi-specs/petstore-simple.openapi.yaml

I put the spec files in https://github.com/channyein87/temp/tree/openapi-spec-validator/src/openapi-specs

It looks like the pre-commit hook found the 2 spec files and pass to openapi-spec-validator.

openapi-spec-validator file1.yaml file2.yaml
p1c2u commented 1 year ago

I see the issue now.

guglie commented 11 months ago

Thanks! As this is very useful, can you release a version 0.6.1 with this fix?