Closed
Description
Actual Behavior
V30ResponseUnmarshaller.unmarshal raises jsonschema.exceptions._WrappedReferencingError when the response schema defined in a different file includes $ref that refers to a schema in another file.
Expected Behavior
The unmarshaller should not raise the error for $ref.
Steps to Reproduce
openapi.yaml
openapi: "3.0.0"
info:
title: sample
version: "0.1"
paths:
/books:
$ref: "./paths/books.yaml"
paths/books.yaml
get:
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "../schemas/book.yaml#/Book"
schemas/book.yaml
Book:
type: object
properties:
id:
$ref: "#/BookId"
title:
type: string
BookId:
type: string
validate.py
import json
import os
import openapi_core
import openapi_core.testing
from openapi_core import V30ResponseUnmarshaller
SPEC_PATH = os.path.join(os.path.dirname(__file__), "openapi.yaml")
content, base_uri = content_factory.from_file(SPEC_PATH)
return V30ResponseUnmarshaller(
spec=SchemaPath.from_dict(content, base_uri=base_uri)
)
request = openapi_core.testing.MockRequest(
host_url="", method="GET", path="/books"
)
response = openapi_core.testing.MockResponse(
data=json.dumps([{"id": "BOOK:01", "title": "Test Book"}]).encode()
)
unmarshaller.unmarshal(request, response) # raises error
OpenAPI Core Version
0.19.3
OpenAPI Core Integration
NA
Affected Area(s)
unmarshalling, schema
References
Almost a full copy of the previous issue.
#852
Anything else we need to know?
Similar fix to be done here:
openapi-core/openapi_core/validation/schemas/validators.py
Lines 38 to 42 in 2e98965
Would you like to implement a fix?
Yes