File tree 5 files changed +58
-4
lines changed
openapi_core/validation/schemas
data/v3.0/parent-reference
5 files changed +58
-4
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,10 @@ def create(
57
57
format_checker = self .get_format_checker (
58
58
format_validators , extra_format_validators
59
59
)
60
- resolver = schema .accessor .resolver # type: ignore
61
- with schema .open () as schema_dict :
60
+ with schema .resolve () as resolved :
62
61
jsonschema_validator = self .schema_validator_class (
63
- schema_dict ,
64
- _resolver = resolver ,
62
+ resolved . contents ,
63
+ _resolver = resolved . resolver ,
65
64
format_checker = format_checker ,
66
65
)
67
66
Original file line number Diff line number Diff line change
1
+ openapi : " 3.0.0"
2
+ info :
3
+ title : sample
4
+ version : " 0.1"
5
+ paths :
6
+ /books :
7
+ $ref : " ./paths/books.yaml"
Original file line number Diff line number Diff line change
1
+ get :
2
+ responses :
3
+ " 200 " :
4
+ description : OK
5
+ content :
6
+ application/json :
7
+ schema :
8
+ type : array
9
+ items :
10
+ $ref : " ../schemas/book.yaml#/Book"
Original file line number Diff line number Diff line change
1
+ Book :
2
+ type : object
3
+ properties :
4
+ id :
5
+ $ref : " #/BookId"
6
+ title :
7
+ type : string
8
+ BookId :
9
+ type : string
Original file line number Diff line number Diff line change
1
+ import json
2
+
3
+ import pytest
4
+ from jsonschema_path import SchemaPath
5
+
6
+ from openapi_core import Config
7
+ from openapi_core import OpenAPI
8
+ from openapi_core .testing import MockRequest
9
+ from openapi_core .testing import MockResponse
10
+
11
+
12
+ class TestParentReference :
13
+
14
+ spec_path = "data/v3.0/parent-reference/openapi.yaml"
15
+
16
+ @pytest .fixture
17
+ def openapi (self , content_factory ):
18
+ content , base_uri = content_factory .from_file (self .spec_path )
19
+ spec = SchemaPath .from_dict (content , base_uri = base_uri )
20
+ config = Config (spec_base_uri = base_uri )
21
+ return OpenAPI (spec , config = config )
22
+
23
+ def test_valid (self , openapi ):
24
+ request = MockRequest (host_url = "" , method = "GET" , path = "/books" )
25
+ response = MockResponse (
26
+ data = json .dumps ([{"id" : "BOOK:01" , "title" : "Test Book" }]).encode ()
27
+ )
28
+
29
+ openapi .validate_response (request , response )
You can’t perform that action at this time.
0 commit comments