File tree Expand file tree Collapse file tree
lib/openapi3_parser/node_factory
spec/lib/openapi3_parser/node_factory Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ class Components < NodeFactory::Object
1515 field "securitySchemes" , factory : :security_schemes_factory
1616 field "links" , factory : :links_factory
1717 field "callbacks" , factory : :callbacks_factory
18+ field "pathItems" ,
19+ factory : :path_items_factory ,
20+ allowed : -> ( context ) { context . openapi_version >= "3.1" }
1821
1922 def build_node ( data , node_context )
2023 Node ::Components . new ( data , node_context )
@@ -62,6 +65,10 @@ def callbacks_factory(context)
6265 referenceable_map_factory ( context , NodeFactory ::Callback )
6366 end
6467
68+ def path_items_factory ( context )
69+ referenceable_map_factory ( context , NodeFactory ::PathItem )
70+ end
71+
6572 def referenceable_map_factory ( context , factory )
6673 NodeFactory ::Map . new (
6774 context ,
Original file line number Diff line number Diff line change 131131 expect ( instance ) . to have_validation_error ( "#/responses" )
132132 end
133133 end
134+
135+ describe "pathItems field" do
136+ it "accepts this field for OpenAPI >= 3.1" do
137+ factory_context = create_node_factory_context (
138+ {
139+ "pathItems" => { "key" => { "summary" => "Item summary" } }
140+ } ,
141+ document_input : { "openapi" => "3.1.0" }
142+ )
143+
144+ instance = described_class . new ( factory_context )
145+ expect ( instance ) . to be_valid
146+ end
147+
148+ it "rejects this field for OpenAPI < 3.1" do
149+ factory_context = create_node_factory_context (
150+ {
151+ "pathItems" => { "key" => { "summary" => "Item summary" } }
152+ } ,
153+ document_input : { "openapi" => "3.0.0" }
154+ )
155+
156+ instance = described_class . new ( factory_context )
157+ expect ( instance ) . not_to be_valid
158+ end
159+ end
134160end
You can’t perform that action at this time.
0 commit comments