-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f1579a
commit c4daed2
Showing
8 changed files
with
281 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,9 @@ __pycache__ | |
.idea | ||
|
||
# VENV | ||
venv | ||
venv | ||
node_modules | ||
|
||
# GENEREATE SDK CLIENT | ||
src | ||
openapi.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,7 @@ alembic_downgrade: | |
|
||
format: | ||
black . | ||
|
||
generate_sdk: | ||
python sdk_client_script.py | ||
npm run generate-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"openapi-typescript-codegen": "^0.25.0" | ||
}, | ||
"scripts": { | ||
"generate-client": "openapi --input ./openapi.json --output ./src/client --client axios" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
url = "http://localhost:8000/openapi.json" | ||
destination_file = "openapi.json" | ||
response = requests.get(url) | ||
|
||
if response.status_code == 200: | ||
with open(destination_file, "wb") as file: | ||
file.write(response.content) | ||
else: | ||
raise Exception( | ||
f"Error downloading the file. Response code: {response.status_code}" | ||
) | ||
|
||
file_path = Path("./openapi.json") | ||
openapi_content = json.loads(file_path.read_text()) | ||
|
||
for path_data in openapi_content["paths"].values(): | ||
for operation in path_data.values(): | ||
tag = operation["tags"][0] | ||
operation_id = operation["operationId"] | ||
to_remove = f"{tag}-" | ||
new_operation_id = operation_id[len(to_remove) :] | ||
operation["operationId"] = new_operation_id | ||
|
||
file_path.write_text(json.dumps(openapi_content)) |