diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a1488b6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: local + hooks: + - id: swag-init + name: swag init + entry: bash -c 'export PATH=$PATH:$(go env GOPATH)/bin && cd db/src && swag init' + language: system + files: ^db/src/.*\.go$ + pass_filenames: false diff --git a/db/README.md b/db/README.md index 435dd67..e2f4669 100644 --- a/db/README.md +++ b/db/README.md @@ -21,7 +21,18 @@ docker compose up -d ## Development ### Swagger Documentation +To ensure the Swagger documentation is always up to date, we use [pre-commit](https://pre-commit.com/). It runs `swag init` automatically before each commit if any Go files in `db/src` have changed. +To install the hooks: +```bash +pre-commit install +``` + +Alternatively, you can run it manually: +```bash +pre-commit run --all-files +``` +or from `db/src`: ```bash swag init ```