Skip to content

Commit 2682741

Browse files
committed
feat: Add experimental OPEN_API_3_1; Update openapi.json look up logic
1 parent 2a4bd6e commit 2682741

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

tools/cloudharness-test/cloudharness_test/apitest_init.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
import logging
3-
import requests
43

54
import schemathesis as st
5+
st.experimental.OPEN_API_3_1.enable()
66

77
from cloudharness.auth import get_token
88

@@ -20,16 +20,18 @@
2020
logging.exception("The local schema file %s cannot be loaded. Attempting loading from URL", openapi_uri)
2121

2222
if not schema:
23-
# remote testing: might be /api/openapi.json or /openapi.json
23+
# Try app_url/openapi.json
2424
try:
25-
openapi_uri = openapi_uri = app_url + "/openapi.json"
25+
openapi_uri = app_url.rstrip("/") + "/openapi.json"
2626
logging.info("Using openapi spec at %s", openapi_uri)
2727
schema = st.from_uri(openapi_uri)
2828
except st.exceptions.SchemaError:
29-
# Use alternative configuration
29+
logging.warning("Failed to load schema from %s", openapi_uri)
30+
31+
# Then try app_url/api/openapi.json
3032
try:
31-
openapi_uri = app_url.replace("/api", "") + "/openapi.json"
32-
print(requests.get(openapi_uri))
33+
openapi_uri = app_url.rstrip("/") + "/api/openapi.json"
34+
logging.info("Using openapi spec at %s", openapi_uri)
3335
schema = st.from_uri(openapi_uri)
3436
except st.exceptions.SchemaError as e:
3537
raise Exception(

0 commit comments

Comments
 (0)