-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
22 changed files
with
479 additions
and
22 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
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Changelog | ||
|
||
## v0.5.0 (2024-10-14) | ||
|
||
- Add spec generator [#2](https://github.com/vedro-universe/vedro-httpx/pull/2) | ||
|
||
## v0.4.0 (2024-04-07) | ||
|
||
- Add request recording [#1](https://github.com/vedro-universe/vedro-httpx/pull/1) | ||
- Add request recording feature [#1](https://github.com/vedro-universe/vedro-httpx/pull/1) | ||
|
||
## v0.3.0 (2023-07-28) | ||
|
||
- Add render width [#a56356b](https://github.com/vedro-universe/vedro-httpx/commit/a56356b089522f6381018bad9ead0f9f5226d939) | ||
- Added functionality to control the rendering width of HTTP responses [#a56356b](https://github.com/vedro-universe/vedro-httpx/commit/a56356b089522f6381018bad9ead0f9f5226d939) |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ coverage: | |
status: | ||
project: | ||
default: | ||
threshold: 5% | ||
threshold: 15% | ||
patch: | ||
default: | ||
threshold: 100% | ||
|
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
baby-steps==1.3.0 | ||
baby-steps==1.3.1 | ||
bump2version==1.0.1 | ||
codecov==2.1.13 | ||
coverage==7.4.4 | ||
flake8==7.0.0 | ||
coverage==7.6.1 | ||
flake8==7.1.1 | ||
isort==5.13.2 | ||
mypy==1.9.0 | ||
pytest==8.1.1 | ||
pytest-asyncio==0.23.6 | ||
mypy==1.12.0 | ||
pytest==8.3.3 | ||
pytest-asyncio==0.24.0 | ||
pytest-clarity==1.0.1 | ||
pytest-cov==5.0.0 | ||
types-Pygments==2.17.0.20240310 | ||
types-Pygments==2.18.0.20240506 | ||
types-PyYAML==6.0.12.20240917 | ||
respx==0.21.1 |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
httpx>=0.24,<1.0 | ||
vedro>=1.7,<2.0 | ||
PyYAML>6.0,<7.0 |
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
Empty file.
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,30 @@ | ||
import pytest | ||
from baby_steps import given, then, when | ||
|
||
from vedro_httpx.spec_generator._utils import humanize_identifier | ||
|
||
|
||
@pytest.mark.parametrize(("name", "expected"), [ | ||
("", ""), | ||
("client id", "Client id"), | ||
("client_id", "Client id"), | ||
("_client_id_", "Client id"), | ||
("clientId", "Client id"), | ||
("ClientName", "Client name"), | ||
("clientHTTPStatus", "Client http status"), | ||
("HTTPResponse", "Http response"), | ||
("StatusOK", "Status ok"), | ||
("version2Name", "Version2 name"), | ||
("CLIENT_ID", "Client id"), | ||
("singleA", "Single a"), | ||
("X-Client-ID", "X client id"), | ||
]) | ||
def test_humanize_identifier(name: str, expected: str): | ||
with given: | ||
name = name | ||
|
||
with when: | ||
result = humanize_identifier(name) | ||
|
||
with then: | ||
assert result == expected |
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,46 @@ | ||
import sys | ||
|
||
from vedro_httpx.spec_generator import APISpecBuilder, HARReader, OpenAPISpecGenerator | ||
|
||
|
||
def generate_spec(har_directory: str) -> str: | ||
""" | ||
Generate an OpenAPI specification from HAR files in a specified directory. | ||
This function reads all HAR files from the provided directory, extracts | ||
HTTP request and response data, builds an API specification, and converts | ||
it into an OpenAPI specification format. | ||
:param har_directory: The directory path where HAR files are located. | ||
:return: The generated OpenAPI specification as a YAML string. | ||
""" | ||
har_reader = HARReader(har_directory) | ||
entries = har_reader.get_entries() | ||
|
||
api_spec_builder = APISpecBuilder() | ||
api_spec = api_spec_builder.build_spec(entries) | ||
|
||
open_api_spec_generator = OpenAPISpecGenerator() | ||
open_api_spec = open_api_spec_generator.generate_spec(api_spec) | ||
|
||
return open_api_spec | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Main entry point of the script. | ||
This function checks for the correct usage of the script by verifying | ||
the command-line arguments, generates an OpenAPI specification from the | ||
HAR directory provided as input, and prints the result. | ||
""" | ||
if len(sys.argv) != 2: | ||
print("Usage: vedro-httpx <har_directory>") | ||
sys.exit(1) | ||
|
||
open_api_spec = generate_spec(sys.argv[1]) | ||
print(open_api_spec) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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
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
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,5 @@ | ||
from ._api_spec_builder import APISpecBuilder | ||
from ._har_reader import HARReader | ||
from ._open_api_spec_generator import OpenAPISpecGenerator | ||
|
||
__all__ = ("OpenAPISpecGenerator", "APISpecBuilder", "HARReader",) |
Oops, something went wrong.