Files
moby/api/scripts/validate-swagger.sh
T
Paweł Gronowski f2395eeaff api/scripts: Always rerun the Swagger projection check
The Go test cache does not recheck files outside the module root, so
editing only openapi.yaml or swagger.yaml could reuse a cached
TestCheckedInSwagger result and miss a stale projection in a
persistent development container.
Pass -count=1 to disable caching.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-10-29 11:34:27 +01:00

28 lines
606 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# Expected to be in api directory
cd "$(dirname "${BASH_SOURCE[0]}")/.."
echo "Validating openapi.yaml..."
fy-tool --yaml-1.2 --null-output openapi.yaml
yamllint -f parsable -c validate/yamllint.yaml openapi.yaml
(
cd scripts/swagger-spec
# The test cache ignores the specifications outside this module.
go test -count=1 ./...
)
if out=$(openapi-spec-validator --schema 3.2 openapi.yaml); then
echo "Validation done! ${out}"
else
echo "${out}" >&2
false
fi
echo "Validating swagger.yaml..."
fy-tool --yaml-1.2 --null-output swagger.yaml
swagger validate swagger.yaml