Skip to content

Commit 2f11358

Browse files
committed
1 parent 3ed1a7d commit 2f11358

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

json-schema-for-3.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ not - schema - in 3.0
7979
if - single schema - done
8080
then - single schema - done
8181
else - single schema - done
82-
dependentSchemas - map of schemas - somewhat complex, is it related to dependentRequired ?
82+
dependentSchemas - map of schemas - done
8383

8484
prefixItems: array of schema - done
8585
items: array of schema - in 3.0

lib/openapi3_parser/node/schema/v3_1.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def else
8585
self["else"]
8686
end
8787

88+
# @return [Node::Map<String, Schema>]
89+
def dependent_schemas
90+
self["dependentSchemas"]
91+
end
92+
8893
# @return [Node::Array<Schema>]
8994
def prefix_items
9095
self["prefixItems"]

lib/openapi3_parser/node_factory/schema/common.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def self.included(base)
3232
base.field "anyOf", factory: :referenceable_schema_array
3333
base.field "not", factory: :referenceable_schema
3434
base.field "items", factory: :referenceable_schema
35-
base.field "properties", factory: :properties_factory
35+
base.field "properties", factory: :schema_map_factory
3636
base.field "additionalProperties",
3737
validate: :additional_properties_input_type,
3838
factory: :additional_properties_factory,
@@ -88,7 +88,7 @@ def external_docs_factory(context)
8888
NodeFactory::ExternalDocumentation.new(context)
8989
end
9090

91-
def properties_factory(context)
91+
def schema_map_factory(context)
9292
NodeFactory::Map.new(
9393
context,
9494
value_factory: NodeFactory::Schema.factory(context)

lib/openapi3_parser/node_factory/schema/v3_1.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class V3_1 < NodeFactory::Object # rubocop:disable Naming/ClassAndModuleCamelCas
3434
field "if", factory: :referenceable_schema
3535
field "then", factory: :referenceable_schema
3636
field "else", factory: :referenceable_schema
37+
field "dependentSchemas", factory: :schema_map_factory
3738
field "prefixItems", factory: :prefix_items_factory
3839
field "contains", factory: :referenceable_schema
39-
field "patternProperties", factory: :pattern_properties_factory
40+
field "patternProperties", factory: :schema_map_factory
4041

4142
def build_node(data, node_context)
4243
Node::Schema::V3_1.new(data, node_context)
@@ -100,13 +101,6 @@ def prefix_items_factory(context)
100101
value_factory: NodeFactory::Schema.factory(context)
101102
)
102103
end
103-
104-
def pattern_properties_factory(context)
105-
NodeFactory::Map.new(
106-
context,
107-
value_factory: NodeFactory::Schema.factory(context)
108-
)
109-
end
110104
end
111105
end
112106
end

spec/support/examples/v3.1/changes.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ components:
9393
dependentRequired:
9494
credit_card:
9595
- billing_address
96+
DependentSchemas:
97+
type: object
98+
properties:
99+
name:
100+
type: string
101+
credit_card:
102+
type: number
103+
required:
104+
- name
105+
dependentSchemas:
106+
credit_card:
107+
properties:
108+
billing_address:
109+
type: string
110+
required:
111+
- billing_address
96112
Number:
97113
type: integer
98114
multipleOf: 5

0 commit comments

Comments
 (0)