#!/usr/bin/env sh

set -eu

YML_IN="spec/submission-api.yaml"
YML_OUT="spec/submission-api-bundled.yaml"

docker run --rm -v "$(pwd):/work" jeanberu/swagger-cli \
  swagger-cli bundle -t yaml -o "/work/$YML_OUT" "/work/$YML_IN"

# Fix: files in docker are created as root:root
# Not needed on macOS
if [ "$(uname)" = "Linux" ]
then
  sudo chown "$USER:$USER" $YML_OUT
fi