Skip to content

Commit 0420e1f

Browse files
committed
readme update
1 parent ce56227 commit 0420e1f

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Runs a security scan of an OpenAPI specification using OWASP ZAP.
263263

264264
* Executes inside Docker
265265
* Accepts an OpenAPI file or directory (default: `openapi`)
266-
* Relative `-f` paths are resolved from the script location
266+
* Relative `-f` paths are resolved from the git repository root (fallback: current working directory)
267267
* For file paths, supports `.yml`/`.yaml` extension fallback
268268
* Skips execution if no OpenAPI specification can be resolved
269269

@@ -297,7 +297,7 @@ Validates an OpenAPI specification for schema correctness.
297297

298298
* Runs the OpenAPI validator in Docker
299299
* Accepts an OpenAPI file or directory (default: `openapi`)
300-
* Relative `-f` paths are resolved from the script location
300+
* Relative `-f` paths are resolved from the git repository root (fallback: current working directory)
301301
* For file paths, supports `.yml`/`.yaml` extension fallback
302302
* Skips execution if no OpenAPI specification can be resolved
303303

@@ -319,6 +319,11 @@ curl -s $(baseUrl)/check-openapi-validation.sh | bash
319319
curl -s $(baseUrl)/check-openapi-validation.sh | bash -s -- -f openapi/openapi.yaml
320320
```
321321

322+
```sh
323+
# Monorepo/nested project example (path relative to git root)
324+
curl -s $(baseUrl)/check-openapi-validation.sh | bash -s -- -f mail-examples/mail-example-openapi/openapi/openapi.yaml
325+
```
326+
322327
---
323328

324329
### check-swift-headers.sh
@@ -586,7 +591,7 @@ Serves OpenAPI documentation locally using Docker.
586591
#### Behavior
587592

588593
* Accepts an OpenAPI file or directory (default: `openapi`)
589-
* Relative `-f` paths are resolved from the script location
594+
* Relative `-f` paths are resolved from the git repository root (fallback: current working directory)
590595
* If a file is provided, mounts its parent directory
591596
* For file paths, supports `.yml`/`.yaml` extension fallback
592597
* Runs Nginx in the foreground

tests/bats/openapi-scripts.bats

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,25 @@ YAML
167167
docker_call="$(cat "$DOCKER_LOG")"
168168
[[ "$docker_call" == *"/openapi/openapi.yaml:/openapi.yaml"* ]]
169169
}
170+
171+
@test "check-openapi-validation supports piped execution with -f path relative to git root" {
172+
repo="$(make_temp_repo)"
173+
copy_openapi_scripts_into_repo "$repo"
174+
install_docker_stub "$repo"
175+
176+
mkdir -p "$repo/mail-examples/mail-example-openapi/openapi"
177+
cat >"$repo/mail-examples/mail-example-openapi/openapi/openapi.yaml" <<'YAML'
178+
openapi: 3.0.0
179+
info:
180+
title: Nested API
181+
version: 1.0.0
182+
paths: {}
183+
YAML
184+
185+
export DOCKER_LOG="$repo/docker.log"
186+
run bash -c "cd '$repo' && cat scripts/check-openapi-validation.sh | bash -s -- -f mail-examples/mail-example-openapi/openapi/openapi.yaml"
187+
188+
[ "$status" -eq 0 ]
189+
docker_call="$(cat "$DOCKER_LOG")"
190+
[[ "$docker_call" == *"/mail-examples/mail-example-openapi/openapi/openapi.yaml:/openapi.yaml"* ]]
191+
}

0 commit comments

Comments
 (0)