Closed
Description
As of commit c2e166e (#422), trying to validate {"0": "a"}
against schema {"type": "object"}
raises TypeError: Field names must be valid identifiers
. This is a valid object, so no error should be raised.
This is likely to come up whenever an object is being used as an associative array rather than as a record with a fixed set of fields.
Test case:
from openapi_core import Spec
from openapi_core.testing import MockRequest
from openapi_core.validation.request import openapi_request_validator
spec = Spec.create(
{
"openapi": "3.0.3",
"info": {"title": "test", "version": "0"},
"paths": {
"/url": {
"post": {
"parameters": [
{
"name": "data",
"in": "query",
"content": {
"application/json": {
"schema": {"type": "object"}
}
},
}
],
"responses": {"200": {"description": "Success."}},
}
}
},
},
)
request = MockRequest(
"http://localhost:9991/", "post", "/url", args={"data": '{"0": "a"}'}
)
result = openapi_request_validator.validate(spec, request)
print(result)
result.raise_for_errors()
Metadata
Metadata
Assignees
Labels
No labels