@@ -89,7 +89,7 @@ def normalize_url(ctx, param, value):
89
89
callback = normalize_url )
90
90
@click .option ('--env' , help = "Environment file to preload." ,
91
91
type = click .Path (exists = True ))
92
- @click .argument ('url' , default = 'http://localhost:8000 ' )
92
+ @click .argument ('url' , default = '' )
93
93
@click .argument ('http_options' , nargs = - 1 , type = click .UNPROCESSED )
94
94
@click .version_option (message = '%(version)s' )
95
95
def cli (spec , env , url , http_options ):
@@ -112,13 +112,18 @@ def cli(spec, env, url, http_options):
112
112
content = f .read ().decode ('utf-8' )
113
113
try :
114
114
spec = json .loads (content )
115
+ if url == '' and spec :
116
+ url = spec .get ('host' , '' ) + spec .get ('basePath' , '' )
115
117
except json .JSONDecodeError :
116
118
click .secho ("Warning: Specification file '%s' is not JSON" %
117
119
spec , err = True , fg = 'red' )
118
120
spec = None
119
121
finally :
120
122
f .close ()
121
123
124
+ if url == '' :
125
+ url = 'http://localhost:8000'
126
+
122
127
url = fix_incomplete_url (url )
123
128
context = Context (url , spec = spec )
124
129
0 commit comments