Skip to content

Paths must start with a leading slash, response is an object, and des… #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion har_to_openapi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

# Uncomment the line below to validate the generated OpenAPI spec
# Commented out because of https://github.com/nloadholtes/har-to-openapi/issues/3
# validate_openapi_spec(openapi_spec)
validate_openapi_spec(openapi_spec)
# with open(sys.argv[1] + ".openapi_spec.json", "w") as f:
# json.dump(f, openapi_spec)
11 changes: 5 additions & 6 deletions har_to_openapi/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def har_to_openapi(har_file_path):
method = request["method"].lower()
url = request["url"]

path = url.replace("http://", "").replace("https://", "").split("/", 1)[-1]
path = "/" + url.replace("http://", "").replace("https://", "").split("/", 1)[-1]

if path not in openapi_spec["paths"]:
openapi_spec["paths"][path] = {}
Expand All @@ -37,11 +37,10 @@ def har_to_openapi(har_file_path):
if method not in openapi_spec["paths"][path]:
openapi_spec["paths"][path][method] = {"responses": {}}
responses = openapi_spec["paths"][path][method]["responses"]
responses[response["status"]] = (
{
"description": response.get("content"),
},
)
responses[response["status"]] = {
"description": json.dumps(response.get("content")),
}

openapi_spec["paths"][path][method]["responses"] = responses

return openapi_spec
Expand Down