File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed
data/v3.0/parent-reference Expand file tree Collapse file tree 4 files changed +55
-0
lines changed 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