Skip to content

Instantly share code, notes, and snippets.

@yann2192
Created September 16, 2019 08:47
Show Gist options
  • Save yann2192/6ebca4efbaf4121c920e143c2a154e58 to your computer and use it in GitHub Desktop.
Save yann2192/6ebca4efbaf4121c920e143c2a154e58 to your computer and use it in GitHub Desktop.
Launch swagger-ui with given filepath (use docker)
#!/usr/bin/env python
import os
import subprocess
import sys
if subprocess.check_call('docker pull swaggerapi/swagger-ui', shell=True) != 0:
print("Error pulling swagger-ui")
path = os.path.abspath(sys.argv[1])
if os.path.exists(path) is not True:
print("Error: file does not exist")
dir = os.path.dirname(path)
f = os.path.basename(path)
s = "docker run --rm -p 80:8080 -e SWAGGER_JSON=/foo/{} -v {}:/foo swaggerapi/swagger-ui"
s = s.format(f, dir)
print("running ...")
if subprocess.check_call(s, shell=True) != 0:
print("Error running swagger-ui")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment