File tree Expand file tree Collapse file tree 4 files changed +48
-5
lines changed
spec/lib/openapi3_parser/node/schema Expand file tree Collapse file tree 4 files changed +48
-5
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ anyOf - non empty array of schemas - in 3.0
7676oneOf - non empty array of schemas - in 3.0
7777not - schema - in 3.0
7878
79- if - single schema
80- then - single schema
81- else - single schema
79+ if - single schema - done
80+ then - single schema - done
81+ else - single schema - done
82+ dependentSchemas - map of schemas - somewhat complex, is it related to dependentRequired ?
8283
83- prefixItems: schema
84- items: schema - in 3.0
84+ prefixItems: array of schema
85+ items: array of schema - in 3.0
8586contains: schema
8687
8788properties: object, each value json schema - in 3.0
Original file line number Diff line number Diff line change @@ -54,6 +54,21 @@ def content_media_type
5454 def content_schema
5555 self [ "contentSchema" ]
5656 end
57+
58+ # @return [Schema, nil]
59+ def if
60+ self [ "if" ]
61+ end
62+
63+ # @return [Schema, nil]
64+ def then
65+ self [ "then" ]
66+ end
67+
68+ # @return [Schema, nil]
69+ def else
70+ self [ "else" ]
71+ end
5772 end
5873 end
5974 end
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ class V3_1 < NodeFactory::Object # rubocop:disable Naming/ClassAndModuleCamelCas
2929 input_type : String ,
3030 validate : Validation ::InputValidator . new ( Validators ::MediaType )
3131 field "contentSchema" , factory : :referenceable_schema
32+ field "if" , factory : :referenceable_schema
33+ field "then" , factory : :referenceable_schema
34+ field "else" , factory : :referenceable_schema
3235
3336 def build_node ( data , node_context )
3437 Node ::Schema ::V3_1 . new ( data , node_context )
Original file line number Diff line number Diff line change 22
33RSpec . describe Openapi3Parser ::Node ::Schema ::V3_1 do
44 it_behaves_like "schema node" , openapi_version : "3.1.0"
5+
6+ %i[ if then else ] . each do |method_name |
7+ describe method_name . to_s do
8+ it "supports a Ruby reserved word as a method name" do
9+ factory_context = create_node_factory_context (
10+ { method_name . to_s => { "type" => "string" } } ,
11+ document_input : {
12+ "openapi" => "3.1.0" ,
13+ "info" => {
14+ "title" => "Minimal Openapi definition" ,
15+ "version" => "1.0.0"
16+ }
17+ }
18+ )
19+
20+ instance = Openapi3Parser ::NodeFactory ::Schema ::V3_1
21+ . new ( factory_context )
22+ . node ( node_factory_context_to_node_context ( factory_context ) )
23+
24+ expect ( instance . public_send ( method_name ) )
25+ . to be_an_instance_of ( described_class )
26+ end
27+ end
28+ end
529end
You can’t perform that action at this time.
0 commit comments