@@ -62,24 +62,35 @@ def main():
6262 import urllib .request
6363
6464 default_port = 8081 if is_oas3 else 8080
65- test_url = (
66- f"http://localhost:{ default_port } /api/v3/swagger.json"
65+ test_urls = (
66+ [
67+ f"http://localhost:{ default_port } /api/v3/openapi.json" ,
68+ f"http://localhost:{ default_port } /api/v3/swagger.json" ,
69+ f"http://localhost:{ default_port } /v3/openapi.json" ,
70+ ]
6771 if is_oas3
68- else f"http://localhost:{ default_port } /api/swagger.json"
72+ else [ f"http://localhost:{ default_port } /api/swagger.json" ]
6973 )
7074
7175 try :
72- print (f"Checking if existing mock server is pingable at { test_url } ..." )
73- urllib .request .urlopen (test_url , timeout = 2 )
74- host_port = str (default_port )
75- print (f"Found active mock server on port { host_port } " )
76+ print (f"Checking if existing mock server is pingable at { test_urls } ..." )
77+ for t_url in test_urls :
78+ try :
79+ urllib .request .urlopen (t_url , timeout = 2 )
80+ host_port = str (default_port )
81+ print (f"Found active mock server on port { host_port } at { t_url } " )
82+ break
83+ except Exception :
84+ continue
7685 except Exception :
7786 print ("No active mock server found." )
7887
7988 if not host_port :
8089 print ("Falling back to Docker JVM Petstore server..." )
8190 container_name = f"petstore_server_{ os .getpid ()} "
82- image_name = "swaggerapi/petstore-v3" if is_oas3 else "swaggerapi/petstore"
91+ image_name = (
92+ "openapitools/openapi-petstore" if is_oas3 else "swaggerapi/petstore"
93+ )
8394
8495 fallback_image_name = (
8596 "openapitools/openapi-petstore"
@@ -133,12 +144,17 @@ def main():
133144 try :
134145 for _ in range (15 ):
135146 time .sleep (2 )
136- try :
137- urllib .request .urlopen (test_url , timeout = 1 )
138- print ("Docker mock server is ready." )
147+ success = False
148+ for t_url in test_urls :
149+ try :
150+ urllib .request .urlopen (t_url , timeout = 1 )
151+ print (f"Docker mock server is ready at { t_url } " )
152+ success = True
153+ break
154+ except Exception :
155+ pass
156+ if success :
139157 break
140- except Exception :
141- pass
142158 else :
143159 print ("Docker mock server failed to become ready." )
144160 return
0 commit comments