[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Start with the OpenAPI.from_dict and MockRequest reproduction, then trace iter_request_errors through query-parameter enum validation. Add a regression test covering status= when the enum includes an empty string, and confirm the request is accepted without a ParameterValidationError.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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 https://github.com/OAI/OpenAPI-Specification/discussions/5411
- Vorherrschende Sprache
- Python
- Sterne
- 368
- Forks
- 140
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-openapi/openapi-core
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python-openapi/openapi-core#1188 · 2 Kommentare ·
-
kind/bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
python-openapi/openapi-core#1225 · 2 Kommentare ·
-
kind/bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
python-openapi/openapi-core#1212 ·
-
kind/bug kind/bug/confirmed
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
python-openapi/openapi-core#1180 · 3 Kommentare ·
-
kind/enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 32/100
python-openapi/openapi-core#1142 ·
Alle Issues in python-openapi/openapi-core
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
use-agent-os/agent-os#3314 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
BasedHardware/omi#15662 · 1 Kommentar ·
-
documentation help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
AiursoftWeb/AnduinOS-2#19 ·