Skip to content

[0.16.2 regression] {"key": null} fails to validate as {"type": "object"} #442

Closed
@andersk

Description

@andersk

In 0.16.1, {"key": null} validated successfully against {"type": "object"}—an object that includes a null value is still an object. But in 0.16.2 this incorrectly raises openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue: Value None not valid for schema of type any: (<ValidationError: 'None for not nullable'>,).

This regression was introduced by commit 692a915 (#434).

Full reproducible example:

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": {
            "/test": {
                "post": {
                    "parameters": [
                        {
                            "name": "obj",
                            "in": "query",
                            "content": {
                                "application/json": {
                                    "schema": {"type": "object"},
                                }
                            },
                        },
                    ],
                    "responses": {"200": {"description": ""}},
                },
            },
        },
    },
)
request = MockRequest(
    "http://localhost/", "post", "/test", args={"obj": '{"key": null}'}
)
result = openapi_request_validator.validate(spec, request)
print(result)
result.raise_for_errors()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy