diff --git a/README.rst b/README.rst index 62a5e34..cf30bef 100644 --- a/README.rst +++ b/README.rst @@ -260,9 +260,9 @@ For Falcon you can use FalconOpenAPIRequest a Falcon request factory: .. code-block:: python from openapi_core.validation.request.validators import RequestValidator - from openapi_core.contrib.falcon import FalconOpenAPIRequest + from openapi_core.contrib.falcon import FalconOpenAPIRequestFactory - openapi_request = FalconOpenAPIRequest(falcon_request) + openapi_request = FalconOpenAPIRequestFactory.create(falcon_request) validator = RequestValidator(spec) result = validator.validate(openapi_request) @@ -271,9 +271,9 @@ You can use FalconOpenAPIResponse as a Falcon response factory: .. code-block:: python from openapi_core.validation.response.validators import ResponseValidator - from openapi_core.contrib.falcon import FalconOpenAPIResponse + from openapi_core.contrib.falcon import FalconOpenAPIResponseFactory - openapi_response = FalconOpenAPIResponse(falcon_response) + openapi_response = FalconOpenAPIResponseFactory.create(falcon_response) validator = ResponseValidator(spec) result = validator.validate(openapi_request, openapi_response) diff --git a/openapi_core/contrib/falcon/requests.py b/openapi_core/contrib/falcon/requests.py index 6652bdc..e48b4fa 100644 --- a/openapi_core/contrib/falcon/requests.py +++ b/openapi_core/contrib/falcon/requests.py @@ -23,7 +23,7 @@ class FalconOpenAPIRequestFactory: # Support falcon-jsonify. body = ( dumps(request.json) if getattr(request, "json", None) - else request.bounded_stream.read() + else dumps(request.media) ) mimetype = request.options.default_media_type if request.content_type: @@ -36,8 +36,9 @@ class FalconOpenAPIRequestFactory: cookie=request.cookies, path=path, ) + url_pattern = request.prefix + request.path return OpenAPIRequest( - full_url_pattern=request.url, + full_url_pattern=url_pattern, method=method, parameters=parameters, body=body, diff --git a/tests/integration/contrib/falcon/data/v3.0/falcon_factory.yaml b/tests/integration/contrib/falcon/data/v3.0/falcon_factory.yaml index 534e7fc..d6b5e4b 100644 --- a/tests/integration/contrib/falcon/data/v3.0/falcon_factory.yaml +++ b/tests/integration/contrib/falcon/data/v3.0/falcon_factory.yaml @@ -13,12 +13,18 @@ paths: description: the ID of the resource to retrieve schema: type: integer + - name: detail_level + in: query + required: false + description: optional level of detail to provide + schema: + type: integer get: responses: 200: description: Return the resource. content: - application/json: + application/json: schema: type: object required: diff --git a/tests/integration/contrib/falcon/test_falcon_validation.py b/tests/integration/contrib/falcon/test_falcon_validation.py index d93e4fb..9e5466c 100644 --- a/tests/integration/contrib/falcon/test_falcon_validation.py +++ b/tests/integration/contrib/falcon/test_falcon_validation.py @@ -32,3 +32,12 @@ class TestFalconOpenAPIValidation(object): openapi_request = FalconOpenAPIRequestFactory.create(request) result = validator.validate(openapi_request) assert not result.errors + + def test_request_validator_with_query(self, spec, request_factory): + validator = RequestValidator(spec) + request = request_factory('GET', '/browse/12', + query_string='detail_level=2', + subdomain='kb') + openapi_request = FalconOpenAPIRequestFactory.create(request) + result = validator.validate(openapi_request) + assert not result.errors