-
Notifications
You must be signed in to change notification settings - Fork 30
♻️Storage API specs are now autogenerated 🚨 #4413
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
Merged
GitHK
merged 24 commits into
ITISFoundation:master
from
GitHK:update-storage-opeanapi-specs
Jun 26, 2023
Merged
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
50bda34
updated storage specs
45b6b47
regenerated
400bba5
refactor models
51ff30a
regen specs
2058891
fixed tests
199a292
fix test
531271f
fixed tests
510ad0d
Merge remote-tracking branch 'upstream/master' into update-storage-op…
6aa221c
remove link that does not work
e08148b
Merge remote-tracking branch 'upstream/master' into update-storage-op…
575b242
fix tests
ded4a64
Merge remote-tracking branch 'upstream/master' into update-storage-op…
23f80c8
touched files
e1c5818
refactor
718840f
manually patch openapi specs
9e1c582
refactor test
7103e64
revert
d7078ba
fix pylint
d7a8249
removed unused
5b7a29f
updates specs
55544d2
remove itertools
3789ef7
fixed specs
d33efe7
refactor
3b2ae22
fixes to openapi no user in storage webserver fe
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,18 @@ | ||
|
||
.PHONY: _check_venv_active | ||
_check_venv_active: | ||
# Checking whether virtual environment was activated | ||
@python3 -c "import sys; assert sys.base_prefix!=sys.prefix" | ||
|
||
|
||
.PHONY: install | ||
install: _check_venv_active | ||
@cd ./../../../../services/storage && make install-dev && cd - | ||
pip install -r requirements.txt | ||
|
||
|
||
.PHONY: all | ||
all: _check_venv_active | ||
@for file in *.py; do \ | ||
python $$file; \ | ||
done |
This file contains hidden or 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,38 @@ | ||
""" Common utils for OAS script generators | ||
""" | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
import yaml | ||
from fastapi import FastAPI | ||
from servicelib.fastapi.openapi import override_fastapi_openapi_method | ||
|
||
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent | ||
|
||
|
||
def create_openapi_specs( | ||
app: FastAPI, file_path: Path, *, drop_fastapi_default_422: bool = True | ||
): | ||
override_fastapi_openapi_method(app) | ||
openapi = app.openapi() | ||
|
||
schemas = openapi["components"]["schemas"] | ||
for section in ("HTTPValidationError", "ValidationError"): | ||
schemas.pop(section) | ||
|
||
# Removes default response 422 | ||
if drop_fastapi_default_422: | ||
for _, method_item in openapi.get("paths", {}).items(): | ||
for _, param in method_item.items(): | ||
# NOTE: If description is like this, | ||
# it assumes it is the default HTTPValidationError from fastapi | ||
if (e422 := param.get("responses", {}).get("422", None)) and e422.get( | ||
"description" | ||
) == "Validation Error": | ||
param.get("responses", {}).pop("422", None) | ||
|
||
with file_path.open("wt") as fh: | ||
yaml.safe_dump(openapi, fh, indent=1, sort_keys=False) | ||
|
||
print("Saved OAS to", file_path) |
This file contains hidden or 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,4 @@ | ||
# Extra reqs, besides webserver's | ||
|
||
fastapi | ||
jsonref | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.