Created
September 16, 2019 08:47
-
-
Save yann2192/6ebca4efbaf4121c920e143c2a154e58 to your computer and use it in GitHub Desktop.
Launch swagger-ui with given filepath (use docker)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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