Skip to content

Commit

Permalink
Merge pull request #149 from dfrommi/swagger-yaml
Browse files Browse the repository at this point in the history
support swagger spec in yaml format
  • Loading branch information
eliangcs authored Jan 15, 2019
2 parents 800e2e9 + 52267fb commit 189321f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions http_prompt/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

import json
import yaml
import os
import re
import sys
Expand Down Expand Up @@ -113,9 +114,12 @@ def cli(spec, env, url, http_options):
try:
spec = json.loads(content)
except json.JSONDecodeError:
click.secho("Warning: Specification file '%s' is not JSON" %
spec, err=True, fg='red')
spec = None
try:
spec = yaml.load(content)
except yaml.YAMLError:
click.secho("Warning: Specification file '%s' is neither valid JSON nor YAML" %
spec, err=True, fg='red')
spec = None
finally:
f.close()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ parsimonious>=0.6.2
prompt-toolkit>=1.0.0,<2.0.0
Pygments>=2.1.0
six>=1.10.0
PyYAML>=3.0

0 comments on commit 189321f

Please sign in to comment.