github.com/skf/moby@v1.13.1/hack/validate/swagger-gen (about)

     1  #!/bin/bash
     2  
     3  export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
     4  source "${SCRIPTDIR}/.validate"
     5  
     6  IFS=$'\n'
     7  files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) )
     8  unset IFS
     9  
    10  if [ ${#files[@]} -gt 0 ]; then
    11  	${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
    12  	# Let see if the working directory is clean
    13  	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
    14  	if [ "$diffs" ]; then
    15  		{
    16  			echo 'The result of hack/generate-swagger-api.sh differs'
    17  			echo
    18  			echo "$diffs"
    19  			echo
    20  			echo 'Please update api/swagger.yaml with any api changes, then '
    21  			echo 'run `hack/generate-swagger-api.sh`.'
    22  		} >&2
    23  		false
    24  	else
    25  		echo 'Congratulations! All api changes are done the right way.'
    26  	fi
    27  else
    28      echo 'No api/types/ or api/swagger.yaml changes in diff.'
    29  fi