Skip to content

Commit 20b510d

Browse files
committed
WIP - write tests for the new methods
1 parent f43d88e commit 20b510d

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

json-schema-for-3.1.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ else - single schema - done
8282
dependentSchemas - map of schemas - done
8383

8484
prefixItems: array of schema - done
85-
items: array of schema - in 3.0
85+
items: schema - in 3.0
8686
contains: schema - done
8787

8888
properties: object, each value json schema - in 3.0
8989
patternProperties: object each value JSON schema key regex - done
90-
additionalProperties: single json schema (works with the boolean schema value that we don't support)
90+
additionalProperties: single json schema - done
9191

92-
unevaluatedItems - single schema - somewhat complex because of booleanSchemas
93-
unevaluatedProperties: single schema - as above
92+
unevaluatedItems - single schema - done
93+
unevaluatedProperties: single schema - done
9494

9595

9696
## Returning to this in 2025
@@ -112,9 +112,6 @@ Little things:
112112
- probably want a quick way to get coverage of the methods on nodes
113113
- could validate that pattern and patternProperties contain regexs
114114

115-
Bigger things:
116-
- OpenAPI 3.1 supports boolean schemas that are just a true or false value, this code doesn't.
117-
118115
JSON Schema specs:
119116

120117
meta: https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00

lib/openapi3_parser/node/schema/v3_1.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,36 @@ def contains
140140
def pattern_properties
141141
self["patternProperties"]
142142
end
143+
144+
# @return [Schema, nil]
145+
def additional_properties
146+
self["additionalProperties"]
147+
end
148+
149+
# @return [Boolean]
150+
def additional_properties?
151+
!additional_properties.false?
152+
end
153+
154+
# @return [Schema, nil]
155+
def unevaluated_items
156+
self["unevaluatedItems"]
157+
end
158+
159+
# @return [Boolean]
160+
def unevaluated_items?
161+
!unevaluated_items.false?
162+
end
163+
164+
# @return [Schema, nil]
165+
def unevaluated_properties
166+
self["unevaluatedProperties"]
167+
end
168+
169+
# @return [Boolean]
170+
def unevaluated_properties?
171+
!unevaluated_properties.false?
172+
end
143173
end
144174
end
145175
end

lib/openapi3_parser/node_factory/schema/v3_1.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class V3_1 < NodeFactory::Object # rubocop:disable Naming/ClassAndModuleCamelCas
3939
field "prefixItems", factory: :prefix_items_factory
4040
field "contains", factory: :referenceable_schema
4141
field "patternProperties", factory: :schema_map_factory
42+
field "additionalProperties", factory: :referenceable_schema
43+
field "unevaluatedItems", factory: :referenceable_schema
44+
field "unevaluatedProperties", factory: :referenceable_schema
4245

4346
def boolean_input?
4447
[true, false].include?(resolved_input)

0 commit comments

Comments
 (0)