From e9a7e87b6d7f35585487c479f09545dc3dbcfb80 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Wed, 2 Apr 2025 16:39:54 +0100 Subject: [PATCH 01/10] update to latest version --- pystapi-validator/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pystapi-validator/pyproject.toml b/pystapi-validator/pyproject.toml index 07436e7..dabaa7d 100644 --- a/pystapi-validator/pyproject.toml +++ b/pystapi-validator/pyproject.toml @@ -9,7 +9,7 @@ license = "MIT" readme = "README.md" requires-python = ">=3.10" dependencies = [ - "schemathesis>=3.37.0", + "schemathesis>=3.39.14", "pytest>=8.3.3", "requests>=2.32.3", "pyyaml>=6.0.2", From 231e75eab5473b54feb1ae8f47c2389c4f52a6bc Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Wed, 2 Apr 2025 16:40:23 +0100 Subject: [PATCH 02/10] fix deprecation warning ignore --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 775d50f..14cee52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ filterwarnings = [ "error", "ignore:The 'app' shortcut is now deprecated.:DeprecationWarning", "ignore:Pydantic serializer warnings:UserWarning", - "ignore:jsonschema.exceptions.RefResolutionError is deprecated:DeprecationWarning", + "ignore:jsonschema.RefResolver is deprecated as of v4.18.0:DeprecationWarning", ] markers = [ "mock_products", From 6ed35f126b5062fc66d2b1a2cf816eff0ed82396 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Wed, 2 Apr 2025 16:41:33 +0100 Subject: [PATCH 03/10] fix validator --- pystapi-validator/tests/validate_api.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/pystapi-validator/tests/validate_api.py b/pystapi-validator/tests/validate_api.py index 6a31d20..74c19a1 100644 --- a/pystapi-validator/tests/validate_api.py +++ b/pystapi-validator/tests/validate_api.py @@ -2,14 +2,6 @@ import pytest import schemathesis -from schemathesis.checks import ( - content_type_conformance, - negative_data_rejection, - not_a_server_error, - response_headers_conformance, - response_schema_conformance, - status_code_conformance, -) schemathesis.experimental.OPEN_API_3_1.enable() @@ -21,19 +13,11 @@ @schema.parametrize() def test_api(case): - response = case.call_and_validate(base_url=BASE_URL) - case.validate_response(response) - - not_a_server_error(response, case) - status_code_conformance(response, case) - content_type_conformance(response, case) - response_schema_conformance(response, case) - response_headers_conformance(response, case) - negative_data_rejection(response, case) + case.call_and_validate(base_url=BASE_URL) def test_openapi_specification(): - assert schema.validate() + schema.validate() @pytest.hookimpl(tryfirst=True, hookwrapper=True) From 2f9d556bfaa7665bcac2c03fa6249ea211b5e38f Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Wed, 2 Apr 2025 16:41:59 +0100 Subject: [PATCH 04/10] update lock --- uv.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv.lock b/uv.lock index 931b6dc..5765033 100644 --- a/uv.lock +++ b/uv.lock @@ -1296,7 +1296,7 @@ requires-dist = [ { name = "pytest-metadata", specifier = ">=3.1.1" }, { name = "pyyaml", specifier = ">=6.0.2" }, { name = "requests", specifier = ">=2.32.3" }, - { name = "schemathesis", specifier = ">=3.37.0" }, + { name = "schemathesis", specifier = ">=3.39.14" }, ] [[package]] From 6d3814c7d1810545433852c00df7aeb6c3b07f7d Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 09:24:47 +0100 Subject: [PATCH 05/10] no error on deprecation warnings --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 14cee52..e3b00dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,8 @@ filterwarnings = [ "error", "ignore:The 'app' shortcut is now deprecated.:DeprecationWarning", "ignore:Pydantic serializer warnings:UserWarning", - "ignore:jsonschema.RefResolver is deprecated as of v4.18.0:DeprecationWarning", + "default:jsonschema.exceptions.RefResolutionError is deprecated:DeprecationWarning", + "default:jsonschema.RefResolver is deprecated as of v4.18.0:DeprecationWarning", ] markers = [ "mock_products", From 65b29ad3fa19d2c5e3f9d8e4b757c10a4f4a05f5 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 10:11:55 +0100 Subject: [PATCH 06/10] run validation in ci --- .github/workflows/ci.yaml | 8 +++++++- scripts/validate-stapi-fastapi | 11 +++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 771b442..6d11ab1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,9 +32,15 @@ jobs: run: uv run pytest - name: Validate test server run: uv run scripts/validate-stapi-fastapi + - name: Upload Validation Report + uses: actions/upload-artifact@v4 + with: + name: validation-report-py${{ matrix.python-version }} + path: validation-report.html - name: Docs run: uv run mkdocs build --strict - - uses: actions/upload-pages-artifact@v3 + - name: Upload Docs + uses: actions/upload-pages-artifact@v3 if: ${{ matrix.python-version == '3.12' }} with: path: site/ diff --git a/scripts/validate-stapi-fastapi b/scripts/validate-stapi-fastapi index 8852fcb..ae5ccbf 100755 --- a/scripts/validate-stapi-fastapi +++ b/scripts/validate-stapi-fastapi @@ -9,13 +9,16 @@ uv run fastapi dev "$root/stapi-fastapi/tests/application.py" >/dev/null 2>&1 & server_pid=$! set +e -"$scripts"/wait-for-it.sh localhost:8000 -- test 0 # TODO update to validate -result=$? +"$scripts"/wait-for-it.sh localhost:8000 -- test 0 +wait_result=$? + +uv run pystapi-validator/tests/validate_api.py --html=validation-report.html --self-contained-html +validation_result=$? set -e kill $(pgrep -P $server_pid) -if [ $result ]; then +if [ $wait_result -eq 0 ] && [ $validation_result -eq 0 ]; then echo "Validated OK!" else - exit $result + exit 1 fi From e2abc33763a355b20b5bcac1d0ebb52cfc566cc9 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 10:30:19 +0100 Subject: [PATCH 07/10] improve script --- scripts/validate-stapi-fastapi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/validate-stapi-fastapi b/scripts/validate-stapi-fastapi index 458aded..46951a0 100755 --- a/scripts/validate-stapi-fastapi +++ b/scripts/validate-stapi-fastapi @@ -5,6 +5,7 @@ set -e scripts="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" root=$(dirname "$scripts") +echo "Starting test server" uv run fastapi dev "$root/stapi-fastapi/tests/application.py" >/dev/null 2>&1 & server_pid=$! @@ -20,14 +21,17 @@ if [ $wait_result -ne 0 ]; then fi set +e +echo "Validating API" uv run pystapi-validator/tests/validate_api.py --html=validation-report.html --self-contained-html validation_result=$? set -e +echo "Stopping test server" kill $(pgrep -P $server_pid) if [ $validation_result -eq 0 ]; then echo "Validated OK!" else + echo "Validation failed!" exit 1 fi From 0a778e3d30cf6b76dcdc56c778d801d4d9aa40f8 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 10:38:25 +0100 Subject: [PATCH 08/10] use pytest --- scripts/validate-stapi-fastapi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/validate-stapi-fastapi b/scripts/validate-stapi-fastapi index 46951a0..819cacc 100755 --- a/scripts/validate-stapi-fastapi +++ b/scripts/validate-stapi-fastapi @@ -22,7 +22,7 @@ fi set +e echo "Validating API" -uv run pystapi-validator/tests/validate_api.py --html=validation-report.html --self-contained-html +uv run pytest "$root/pystapi-validator/tests/validate_api.py" --html=validation-report.html --self-contained-html validation_result=$? set -e From a0ed9446c4cbaafba1cd7534bbc75016ddf23f70 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 10:41:36 +0100 Subject: [PATCH 09/10] continue on validation error --- .github/workflows/ci.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cefda58..5f8eefa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,11 +32,7 @@ jobs: run: uv run pytest - name: Validate test server run: uv run scripts/validate-stapi-fastapi - - name: Upload Validation Report - uses: actions/upload-artifact@v4 - with: - name: validation-report-py${{ matrix.python-version }} - path: validation-report.html + continue-on-error: true - name: Docs run: uv run mkdocs build --strict - name: Upload Docs From ab873a2bd632b0aca726075a8bf7777c9c074156 Mon Sep 17 00:00:00 2001 From: Justin Trautmann Date: Thu, 3 Apr 2025 10:42:14 +0100 Subject: [PATCH 10/10] upload report --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f8eefa..3b28e6a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,11 @@ jobs: - name: Validate test server run: uv run scripts/validate-stapi-fastapi continue-on-error: true + - name: Upload Validation Report + uses: actions/upload-artifact@v4 + with: + name: validation-report-py${{ matrix.python-version }} + path: validation-report.html - name: Docs run: uv run mkdocs build --strict - name: Upload Docs