Skip to content

Commit 189321f

Browse files
authored
Merge pull request #149 from dfrommi/swagger-yaml
support swagger spec in yaml format
2 parents 800e2e9 + 52267fb commit 189321f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

http_prompt/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import unicode_literals
22

33
import json
4+
import yaml
45
import os
56
import re
67
import sys
@@ -113,9 +114,12 @@ def cli(spec, env, url, http_options):
113114
try:
114115
spec = json.loads(content)
115116
except json.JSONDecodeError:
116-
click.secho("Warning: Specification file '%s' is not JSON" %
117-
spec, err=True, fg='red')
118-
spec = None
117+
try:
118+
spec = yaml.load(content)
119+
except yaml.YAMLError:
120+
click.secho("Warning: Specification file '%s' is neither valid JSON nor YAML" %
121+
spec, err=True, fg='red')
122+
spec = None
119123
finally:
120124
f.close()
121125

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ parsimonious>=0.6.2
44
prompt-toolkit>=1.0.0,<2.0.0
55
Pygments>=2.1.0
66
six>=1.10.0
7+
PyYAML>=3.0

0 commit comments

Comments
 (0)