Actual Behavior
Run the following code:
from openapi_core import OpenAPI
from openapi_core.testing import MockRequest
SPEC = {
"openapi": "3.2.0",
"info": {"title": "Sample", "version": "1.0.0"},
"paths": {
"/api": {
"get": {
"tags": ["Sample"],
"parameters": [
{
"name": "status",
"in": "query",
"schema": {"enum": ["Active", "Inactive", "Pending", ""]},
}
]
}
}
},
"tags": [{"name": "Sample"}],
}
openapi = OpenAPI.from_dict(SPEC)
# Empty query parameter: status=
request = MockRequest(
host_url="http://localhost",
method="get",
path="/api",
args={"status": ""},
)
if hasattr(openapi, "iter_request_errors"):
errors = list(openapi.iter_request_errors(request))
if errors:
print("INVALID")
for e in errors:
print(f" {type(e).__name__}: {e}")
else:
print("VALID")
else:
try:
openapi.validate_request(request)
print("VALID")
except Exception as exc:
print("INVALID")
print(f" {type(exc).__name__}: {exc}")
It prints:
INVALID
ParameterValidationError: Query parameter error: status
Expected Behavior
It should print VALID.
OpenAPI Core Version
0.23.1
See OAI/OpenAPI-Specification#5411
Actual Behavior
Run the following code:
It prints:
Expected Behavior
It should print VALID.
OpenAPI Core Version
0.23.1
See OAI/OpenAPI-Specification#5411