openapi_parser 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +1 -3
  3. data/CHANGELOG.md +41 -0
  4. data/README.md +44 -1
  5. data/lib/openapi_parser/concerns/media_type_selectable.rb +18 -0
  6. data/lib/openapi_parser/concerns/schema_loader/creator.rb +7 -2
  7. data/lib/openapi_parser/concerns/schema_loader/hash_body_loader.rb +1 -1
  8. data/lib/openapi_parser/config.rb +5 -0
  9. data/lib/openapi_parser/errors.rb +36 -0
  10. data/lib/openapi_parser/schema_validator/all_of_validator.rb +16 -11
  11. data/lib/openapi_parser/schema_validator/any_of_validator.rb +1 -1
  12. data/lib/openapi_parser/schema_validator/base.rb +35 -9
  13. data/lib/openapi_parser/schema_validator/float_validator.rb +4 -0
  14. data/lib/openapi_parser/schema_validator/integer_validator.rb +17 -1
  15. data/lib/openapi_parser/schema_validator/multiple_of.rb +26 -0
  16. data/lib/openapi_parser/schema_validator/nil_validator.rb +4 -0
  17. data/lib/openapi_parser/schema_validator/object_validator.rb +21 -0
  18. data/lib/openapi_parser/schema_validator/one_of_validator.rb +4 -7
  19. data/lib/openapi_parser/schema_validator.rb +95 -18
  20. data/lib/openapi_parser/schemas/components.rb +4 -0
  21. data/lib/openapi_parser/schemas/discriminator.rb +4 -0
  22. data/lib/openapi_parser/schemas/media_type.rb +4 -0
  23. data/lib/openapi_parser/schemas/openapi.rb +36 -3
  24. data/lib/openapi_parser/schemas/path_item.rb +29 -6
  25. data/lib/openapi_parser/schemas/request_body.rb +1 -1
  26. data/lib/openapi_parser/schemas/response.rb +5 -1
  27. data/lib/openapi_parser/schemas/schema.rb +12 -1
  28. data/lib/openapi_parser/spec_validator/rule.rb +24 -3
  29. data/lib/openapi_parser/spec_validator/rules/additional_operations_before_32.rb +26 -0
  30. data/lib/openapi_parser/spec_validator/rules/allow_empty_value_deprecation.rb +26 -0
  31. data/lib/openapi_parser/spec_validator/rules/cookie_style_before_32.rb +26 -0
  32. data/lib/openapi_parser/spec_validator/rules/default_mapping_before_32.rb +29 -0
  33. data/lib/openapi_parser/spec_validator/rules/defs_in_30.rb +25 -0
  34. data/lib/openapi_parser/spec_validator/rules/dependent_required_in_30.rb +25 -0
  35. data/lib/openapi_parser/spec_validator/rules/example_value_fields_before_32.rb +48 -0
  36. data/lib/openapi_parser/spec_validator/rules/media_types_before_32.rb +24 -0
  37. data/lib/openapi_parser/spec_validator/rules/query_method_before_32.rb +26 -0
  38. data/lib/openapi_parser/spec_validator/rules/querystring_before_32.rb +26 -0
  39. data/lib/openapi_parser/spec_validator/rules/response_summary_before_32.rb +25 -0
  40. data/lib/openapi_parser/spec_validator/rules/security_scheme_fields_before_32.rb +41 -0
  41. data/lib/openapi_parser/spec_validator/rules/server_name_before_32.rb +35 -0
  42. data/lib/openapi_parser/spec_validator/rules/streaming_fields_before_32.rb +56 -0
  43. data/lib/openapi_parser/spec_validator/rules/tag_fields_before_32.rb +34 -0
  44. data/lib/openapi_parser/spec_validator/rules/xml_attribute_deprecation.rb +29 -0
  45. data/lib/openapi_parser/spec_validator/rules/xml_node_type_before_32.rb +29 -0
  46. data/lib/openapi_parser/spec_validator/rules/xml_wrapped_deprecation.rb +29 -0
  47. data/lib/openapi_parser/spec_validator.rb +36 -0
  48. data/lib/openapi_parser/version.rb +1 -1
  49. data/lib/openapi_parser.rb +5 -4
  50. data/sig/openapi_parser/config.rbs +1 -0
  51. data/sig/openapi_parser/schema_validator.rbs +2 -0
  52. data/sig/openapi_parser/schema_validators/base.rbs +4 -2
  53. data/sig/openapi_parser/spec_validator.rbs +81 -0
  54. data/sig/openapi_parser.rbs +5 -3
  55. data/sig/wip_types.rbs +6 -0
  56. metadata +20 -1
@@ -0,0 +1,24 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `components.mediaTypes` is a 3.2 addition. The parse layer accepts
5
+ # it permissively; this rule reports the version mismatch.
6
+ class MediaTypesBefore32 < Rule
7
+ def check(root)
8
+ return [] unless version_before?('3.2')
9
+
10
+ components = root.components
11
+ return [] unless components
12
+
13
+ raw = components.raw_schema
14
+ return [] unless raw.is_a?(Hash) && raw.key?('mediaTypes')
15
+
16
+ [violation(
17
+ path: "#{components.object_reference}/mediaTypes",
18
+ message: '`components.mediaTypes` is a 3.2 addition; earlier documents should not declare it',
19
+ )]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `query` is a 3.2 Path Item addition for the HTTP QUERY method. The
5
+ # parse layer accepts it permissively; this rule reports the version
6
+ # mismatch.
7
+ class QueryMethodBefore32 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.2')
10
+
11
+ violations = []
12
+ each_node(root, OpenAPIParser::Schemas::PathItem) do |node|
13
+ raw = node.raw_schema
14
+ next unless raw.is_a?(Hash) && raw.key?('query')
15
+
16
+ violations << violation(
17
+ path: "#{node.object_reference}/query",
18
+ message: 'the `query` operation is a 3.2 Path Item addition; earlier documents have no such field',
19
+ )
20
+ end
21
+ violations
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `in: querystring` is a 3.2 Parameter location that treats the whole
5
+ # query string as one value described by `content`. Runtime validation
6
+ # does not support it yet; this rule reports the version mismatch.
7
+ class QuerystringBefore32 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.2')
10
+
11
+ violations = []
12
+ each_node(root, OpenAPIParser::Schemas::Parameter) do |node|
13
+ raw = node.raw_schema
14
+ next unless raw.is_a?(Hash) && raw['in'] == 'querystring'
15
+
16
+ violations << violation(
17
+ path: "#{node.object_reference}/in",
18
+ message: '`in: querystring` is a 3.2 Parameter location; earlier documents have no such location',
19
+ )
20
+ end
21
+ violations
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `summary` to the Response Object. The parse layer accepts it
5
+ # permissively; this rule reports the version mismatch.
6
+ class ResponseSummaryBefore32 < Rule
7
+ def check(root)
8
+ return [] unless version_before?('3.2')
9
+
10
+ violations = []
11
+ each_node(root, OpenAPIParser::Schemas::Response) do |node|
12
+ raw = node.raw_schema
13
+ next unless raw.is_a?(Hash) && raw.key?('summary')
14
+
15
+ violations << violation(
16
+ path: "#{node.object_reference}/summary",
17
+ message: '`summary` on a Response Object is a 3.2 addition; earlier documents have no such field',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,41 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `deprecated` and `oauth2MetadataUrl` to the Security Scheme
5
+ # Object and the `deviceAuthorization` OAuth flow. Security schemes are
6
+ # not modeled by the parse layer, so this rule inspects the raw
7
+ # `components.securitySchemes` map; schemes given as a `$ref` are not
8
+ # followed.
9
+ class SecuritySchemeFieldsBefore32 < Rule
10
+ NEW_FIELDS = %w[deprecated oauth2MetadataUrl].freeze
11
+
12
+ def check(root)
13
+ return [] unless version_before?('3.2')
14
+
15
+ violations = []
16
+ each_security_scheme(root) do |name, scheme|
17
+ base = "#/components/securitySchemes/#{escape_reference(name)}"
18
+
19
+ NEW_FIELDS.each do |field|
20
+ next unless scheme.key?(field)
21
+
22
+ violations << violation(
23
+ path: "#{base}/#{field}",
24
+ message: "`#{field}` on a Security Scheme Object is a 3.2 addition; earlier documents have no such field",
25
+ )
26
+ end
27
+
28
+ flows = scheme['flows']
29
+ next unless flows.is_a?(Hash) && flows.key?('deviceAuthorization')
30
+
31
+ violations << violation(
32
+ path: "#{base}/flows/deviceAuthorization",
33
+ message: 'the `deviceAuthorization` OAuth flow is a 3.2 addition; earlier documents have no such flow',
34
+ )
35
+ end
36
+ violations
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `name` to the Server Object. Servers are not modeled by
5
+ # the parse layer, so this rule inspects the raw `servers` arrays on
6
+ # the root, Path Item, and Operation objects. Servers under callbacks
7
+ # and Link Objects are not reached.
8
+ class ServerNameBefore32 < Rule
9
+ def check(root)
10
+ return [] unless version_before?('3.2')
11
+
12
+ violations = []
13
+ node_classes = [OpenAPIParser::Schemas::OpenAPI, OpenAPIParser::Schemas::PathItem, OpenAPIParser::Schemas::Operation]
14
+ each_node(root, *node_classes) do |node|
15
+ raw = node.raw_schema
16
+ next unless raw.is_a?(Hash)
17
+
18
+ servers = raw['servers']
19
+ next unless servers.is_a?(Array)
20
+
21
+ servers.each_with_index do |server, index|
22
+ next unless server.is_a?(Hash) && server.key?('name')
23
+
24
+ violations << violation(
25
+ path: "#{node.object_reference}/servers/#{index}/name",
26
+ message: '`name` on a Server Object is a 3.2 addition; earlier documents have no such field',
27
+ )
28
+ end
29
+ end
30
+ violations
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,56 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `itemSchema`, `itemEncoding`, and `prefixEncoding` to the
5
+ # Media Type Object for sequential media types (SSE, JSON Lines,
6
+ # JSON Sequences), and lets an Encoding Object nest `encoding`,
7
+ # `itemEncoding`, and `prefixEncoding`. The parse layer accepts
8
+ # `itemSchema` permissively; this rule reports the version mismatch.
9
+ # Media Types under a Parameter or Header `content` are not modeled,
10
+ # so fields there are not reached.
11
+ class StreamingFieldsBefore32 < Rule
12
+ NEW_FIELDS = %w[itemSchema itemEncoding prefixEncoding].freeze
13
+ NEW_ENCODING_FIELDS = %w[encoding itemEncoding prefixEncoding].freeze
14
+
15
+ def check(root)
16
+ return [] unless version_before?('3.2')
17
+
18
+ violations = []
19
+ each_node(root, OpenAPIParser::Schemas::MediaType) do |node|
20
+ raw = node.raw_schema
21
+ next unless raw.is_a?(Hash)
22
+
23
+ NEW_FIELDS.each do |field|
24
+ next unless raw.key?(field)
25
+
26
+ violations << violation(
27
+ path: "#{node.object_reference}/#{field}",
28
+ message: "`#{field}` on a Media Type Object is a 3.2 addition; earlier documents have no such field",
29
+ )
30
+ end
31
+
32
+ violations.concat(encoding_violations(node, raw['encoding']))
33
+ end
34
+ violations
35
+ end
36
+
37
+ private
38
+
39
+ def encoding_violations(node, encodings)
40
+ return [] unless encodings.is_a?(Hash)
41
+
42
+ encodings.flat_map do |property, encoding|
43
+ next [] unless encoding.is_a?(Hash)
44
+
45
+ NEW_ENCODING_FIELDS.select { |field| encoding.key?(field) }.map do |field|
46
+ violation(
47
+ path: "#{node.object_reference}/encoding/#{escape_reference(property)}/#{field}",
48
+ message: "`#{field}` on an Encoding Object is a 3.2 addition; earlier documents have no such field",
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,34 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `summary`, `parent`, and `kind` to the Tag Object.
5
+ # Tags are not modeled by the parse layer, so this rule inspects the
6
+ # raw root-level `tags` array.
7
+ class TagFieldsBefore32 < Rule
8
+ NEW_FIELDS = %w[summary parent kind].freeze
9
+
10
+ def check(root)
11
+ return [] unless version_before?('3.2')
12
+
13
+ tags = root.raw_schema.is_a?(Hash) ? root.raw_schema['tags'] : nil
14
+ return [] unless tags.is_a?(Array)
15
+
16
+ violations = []
17
+ tags.each_with_index do |tag, index|
18
+ next unless tag.is_a?(Hash)
19
+
20
+ NEW_FIELDS.each do |field|
21
+ next unless tag.key?(field)
22
+
23
+ violations << violation(
24
+ path: "#/tags/#{index}/#{field}",
25
+ message: "`#{field}` on a Tag Object is a 3.2 addition; earlier documents have no such field",
26
+ )
27
+ end
28
+ end
29
+ violations
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 deprecates `attribute: true` on the XML Object in favor of
5
+ # `nodeType: attribute`. The field is still allowed but discouraged,
6
+ # so we report it as a violation on 3.2 documents.
7
+ class XmlAttributeDeprecation < Rule
8
+ def check(root)
9
+ return [] unless version_at_least?('3.2')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ raw = schema.raw_schema
14
+ next unless raw.is_a?(Hash)
15
+
16
+ xml = raw['xml']
17
+ next unless xml.is_a?(Hash) && xml['attribute'] == true
18
+
19
+ violations << violation(
20
+ path: schema.object_reference,
21
+ message: '`attribute` on an XML Object is deprecated in 3.2; use `nodeType: attribute`',
22
+ )
23
+ end
24
+ violations
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 adds `nodeType` to the XML Object (replacing `attribute` and
5
+ # `wrapped`). XML Objects are not modeled by the parse layer, so this
6
+ # rule inspects the raw `xml` field on schemas.
7
+ class XmlNodeTypeBefore32 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.2')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ raw = schema.raw_schema
14
+ next unless raw.is_a?(Hash)
15
+
16
+ xml = raw['xml']
17
+ next unless xml.is_a?(Hash) && xml.key?('nodeType')
18
+
19
+ violations << violation(
20
+ path: schema.object_reference,
21
+ message: '`nodeType` on an XML Object is a 3.2 addition; earlier documents have no such field',
22
+ )
23
+ end
24
+ violations
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.2 deprecates `wrapped: true` on the XML Object in favor of
5
+ # `nodeType: element`. The field is still allowed but discouraged,
6
+ # so we report it as a violation on 3.2 documents.
7
+ class XmlWrappedDeprecation < Rule
8
+ def check(root)
9
+ return [] unless version_at_least?('3.2')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ raw = schema.raw_schema
14
+ next unless raw.is_a?(Hash)
15
+
16
+ xml = raw['xml']
17
+ next unless xml.is_a?(Hash) && xml['wrapped'] == true
18
+
19
+ violations << violation(
20
+ path: schema.object_reference,
21
+ message: '`wrapped` on an XML Object is deprecated in 3.2; use `nodeType: element`',
22
+ )
23
+ end
24
+ violations
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -17,7 +17,25 @@ require_relative 'spec_validator/rules/const_in_30'
17
17
  require_relative 'spec_validator/rules/dynamic_ref_in_30'
18
18
  require_relative 'spec_validator/rules/dynamic_anchor_in_30'
19
19
  require_relative 'spec_validator/rules/content_schema_in_30'
20
+ require_relative 'spec_validator/rules/defs_in_30'
21
+ require_relative 'spec_validator/rules/dependent_required_in_30'
22
+ require_relative 'spec_validator/rules/allow_empty_value_deprecation'
23
+ require_relative 'spec_validator/rules/xml_node_type_before_32'
24
+ require_relative 'spec_validator/rules/xml_attribute_deprecation'
25
+ require_relative 'spec_validator/rules/xml_wrapped_deprecation'
26
+ require_relative 'spec_validator/rules/media_types_before_32'
27
+ require_relative 'spec_validator/rules/default_mapping_before_32'
28
+ require_relative 'spec_validator/rules/cookie_style_before_32'
29
+ require_relative 'spec_validator/rules/server_name_before_32'
20
30
  require_relative 'spec_validator/rules/self_before_32'
31
+ require_relative 'spec_validator/rules/query_method_before_32'
32
+ require_relative 'spec_validator/rules/additional_operations_before_32'
33
+ require_relative 'spec_validator/rules/response_summary_before_32'
34
+ require_relative 'spec_validator/rules/tag_fields_before_32'
35
+ require_relative 'spec_validator/rules/example_value_fields_before_32'
36
+ require_relative 'spec_validator/rules/security_scheme_fields_before_32'
37
+ require_relative 'spec_validator/rules/streaming_fields_before_32'
38
+ require_relative 'spec_validator/rules/querystring_before_32'
21
39
 
22
40
  module OpenAPIParser
23
41
  class SpecViolationError < OpenAPIError
@@ -82,7 +100,25 @@ module OpenAPIParser
82
100
  Rules::DynamicRefIn30,
83
101
  Rules::DynamicAnchorIn30,
84
102
  Rules::ContentSchemaIn30,
103
+ Rules::DefsIn30,
104
+ Rules::DependentRequiredIn30,
105
+ Rules::AllowEmptyValueDeprecation,
106
+ Rules::XmlNodeTypeBefore32,
107
+ Rules::XmlAttributeDeprecation,
108
+ Rules::XmlWrappedDeprecation,
109
+ Rules::MediaTypesBefore32,
110
+ Rules::DefaultMappingBefore32,
111
+ Rules::CookieStyleBefore32,
112
+ Rules::ServerNameBefore32,
85
113
  Rules::SelfBefore32,
114
+ Rules::QueryMethodBefore32,
115
+ Rules::AdditionalOperationsBefore32,
116
+ Rules::ResponseSummaryBefore32,
117
+ Rules::TagFieldsBefore32,
118
+ Rules::ExampleValueFieldsBefore32,
119
+ Rules::SecuritySchemeFieldsBefore32,
120
+ Rules::StreamingFieldsBefore32,
121
+ Rules::QuerystringBefore32,
86
122
  ]
87
123
  end
88
124
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '2.5.0'.freeze
2
+ VERSION = '2.7.0'.freeze
3
3
  end
@@ -40,8 +40,9 @@ module OpenAPIParser
40
40
  end
41
41
 
42
42
  # Load schema located by the passed uri. Uri must be absolute.
43
+ # @param [OpenAPIParser::Schemas::OpenAPI, nil] referrer the document whose $ref loads this one
43
44
  # @return [OpenAPIParser::Schemas::OpenAPI]
44
- def load_uri(uri, config:, schema_registry:)
45
+ def load_uri(uri, config:, schema_registry:, referrer: nil)
45
46
  # Open-uri doesn't open file scheme uri, so we try to open file path directly
46
47
  # File scheme uri which points to a remote file is not supported.
47
48
  uri_path = uri.path
@@ -54,7 +55,7 @@ module OpenAPIParser
54
55
  end
55
56
 
56
57
  extension = Pathname.new(uri_path).extname
57
- load_hash(parse_file(content, extension), config: config, uri: uri, schema_registry: schema_registry)
58
+ load_hash(parse_file(content, extension), config: config, uri: uri, schema_registry: schema_registry, referrer: referrer)
58
59
  end
59
60
 
60
61
  private
@@ -90,8 +91,8 @@ module OpenAPIParser
90
91
  JSON.parse(content)
91
92
  end
92
93
 
93
- def load_hash(hash, config:, uri:, schema_registry:)
94
- root = Schemas::OpenAPI.new(hash, config, uri: uri, schema_registry: schema_registry)
94
+ def load_hash(hash, config:, uri:, schema_registry:, referrer: nil)
95
+ root = Schemas::OpenAPI.new(hash, config, uri: uri, schema_registry: schema_registry, referrer: referrer)
95
96
 
96
97
  OpenAPIParser::ReferenceExpander.expand(root, config.strict_reference_validation) if config.expand_reference
97
98
 
@@ -9,6 +9,7 @@ module OpenAPIParser
9
9
 
10
10
  def initialize: (untyped config) -> untyped
11
11
  def allow_empty_date_and_datetime: -> bool
12
+ def allow_3_2_features: -> bool
12
13
  def date_coerce_class: -> (singleton(Object) | nil)
13
14
  def datetime_coerce_class: -> (singleton(Object) | nil)
14
15
  def coerce_value: -> bool
@@ -2,6 +2,7 @@
2
2
  module OpenAPIParser
3
3
  class SchemaValidator
4
4
  include Validatable
5
+ VALUE_TYPES: Array[String]
5
6
  @value: Hash[bot, bot]
6
7
  @schema: OpenAPIParser::Schemas::Schema
7
8
  @coerce_value: bool | nil
@@ -24,6 +25,7 @@ module OpenAPIParser
24
25
  def validate_data: -> Object
25
26
  def validate_schema: (Object value, OpenAPIParser::Schemas::Schema schema, **bot) -> [Object, OpenAPIParser::validate_error]
26
27
  def validate_integer: (Object value, OpenAPIParser::Schemas::Schema schema) -> [Object, OpenAPIParser::validate_error]
28
+ def validate_in_order: (Object value, Array[untyped] steps) -> [Object, OpenAPIParser::validate_error]
27
29
 
28
30
  private
29
31
  def validator: (Object value, OpenAPIParser::Schemas::Schema schema) -> [OpenAPIParser::SchemaValidator::Base, OpenAPIParser::validate_error]
@@ -10,9 +10,11 @@ module OpenAPIParser
10
10
  def coerce_and_validate: (Object _value, OpenAPIParser::Schemas::Schema _schema, **untyped) -> [untyped, (ValidateError | NotExistDiscriminatorMappedSchema | nil)]
11
11
  def validate_discriminator_schema: (
12
12
  OpenAPIParser::Schemas::Discriminator discriminator,
13
- Hash[String, bot] value,
13
+ Hash[String, untyped] value,
14
+ ?candidate_schemas: Array[OpenAPIParser::Schemas::Schema] | nil,
14
15
  ?parent_discriminator_schemas: Array[OpenAPIParser::Schemas::Schema]
15
- ) -> [Object | nil, OpenAPIParser::OpenAPIError]
16
+ ) -> [Object | nil, OpenAPIParser::OpenAPIError | nil]
17
+ private def default_mapping_target: (OpenAPIParser::Schemas::Discriminator discriminator) -> (String | nil)
16
18
  end
17
19
  end
18
20
  end
@@ -35,6 +35,9 @@ module OpenAPIParser
35
35
  def version_at_least?: (String boundary) -> bool
36
36
  private def violation: (path: String, message: String) -> SpecViolation
37
37
  private def each_schema: (untyped root) ?{ (untyped) -> void } -> untyped
38
+ private def each_node: (untyped root, *Class klasses) { (untyped) -> void } -> void
39
+ private def each_security_scheme: (untyped root) { (String, Hash[untyped, untyped]) -> void } -> void
40
+ private def escape_reference: (untyped key) -> String
38
41
  private def walk: (untyped node, Hash[Integer, bool] visited) { (untyped) -> void } -> void
39
42
  end
40
43
 
@@ -107,9 +110,87 @@ module OpenAPIParser
107
110
  def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
108
111
  end
109
112
 
113
+ class DefsIn30 < Rule
114
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
115
+ end
116
+
117
+ class DependentRequiredIn30 < Rule
118
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
119
+ end
120
+
121
+ class AllowEmptyValueDeprecation < Rule
122
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
123
+ end
124
+
125
+ class XmlNodeTypeBefore32 < Rule
126
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
127
+ end
128
+
129
+ class XmlAttributeDeprecation < Rule
130
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
131
+ end
132
+
133
+ class XmlWrappedDeprecation < Rule
134
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
135
+ end
136
+
137
+ class MediaTypesBefore32 < Rule
138
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
139
+ end
140
+
141
+ class DefaultMappingBefore32 < Rule
142
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
143
+ end
144
+
145
+ class CookieStyleBefore32 < Rule
146
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
147
+ end
148
+
149
+ class ServerNameBefore32 < Rule
150
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
151
+ end
152
+
110
153
  class SelfBefore32 < Rule
111
154
  def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
112
155
  end
156
+
157
+ class QueryMethodBefore32 < Rule
158
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
159
+ end
160
+
161
+ class AdditionalOperationsBefore32 < Rule
162
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
163
+ end
164
+
165
+ class ResponseSummaryBefore32 < Rule
166
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
167
+ end
168
+
169
+ class TagFieldsBefore32 < Rule
170
+ NEW_FIELDS: Array[String]
171
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
172
+ end
173
+
174
+ class ExampleValueFieldsBefore32 < Rule
175
+ NEW_FIELDS: Array[String]
176
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
177
+ end
178
+
179
+ class SecuritySchemeFieldsBefore32 < Rule
180
+ NEW_FIELDS: Array[String]
181
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
182
+ end
183
+
184
+ class StreamingFieldsBefore32 < Rule
185
+ NEW_FIELDS: Array[String]
186
+ NEW_ENCODING_FIELDS: Array[String]
187
+ private def encoding_violations: (untyped node, untyped encodings) -> Array[SpecValidator::SpecViolation]
188
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
189
+ end
190
+
191
+ class QuerystringBefore32 < Rule
192
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
193
+ end
113
194
  end
114
195
  end
115
196
 
@@ -2,20 +2,22 @@ module OpenAPIParser
2
2
  def self.parse: (Hash[bot, bot] schema, ?Hash[bot, bot] config) -> OpenAPIParser::Schemas::OpenAPI
3
3
  def self.parse_with_filepath: (Hash[bot, bot] schema, String filepath, ?Hash[bot, bot] config) -> OpenAPIParser::Schemas::OpenAPI
4
4
  def self.load: (String filepath, ?Hash[bot, bot] config) -> OpenAPIParser::Schemas::OpenAPI
5
- def self.load_uri: (OpenAPIParser::readable_uri uri, config: untyped, schema_registry: Hash[bot, bot]) -> OpenAPIParser::Schemas::OpenAPI
5
+ def self.load_uri: (OpenAPIParser::readable_uri uri, config: untyped, schema_registry: Hash[bot, bot], ?referrer: OpenAPIParser::Schemas::OpenAPI?) -> OpenAPIParser::Schemas::OpenAPI
6
6
  def self.file_uri: (String filepath) -> URI::Generic
7
7
  def self.parse_file: (String? content, String ext) -> Hash[bot, bot]
8
8
  def self.parse_yaml: (String? content) -> Hash[bot, bot]
9
9
  def self.parse_json: (String? content) -> Hash[bot, bot]
10
- def self.load_hash: (Hash[bot, bot] hash, config: untyped, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot]) -> OpenAPIParser::Schemas::OpenAPI
10
+ def self.load_hash: (Hash[bot, bot] hash, config: untyped, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot], ?referrer: OpenAPIParser::Schemas::OpenAPI?) -> OpenAPIParser::Schemas::OpenAPI
11
11
  end
12
12
 
13
13
  module OpenAPIParser
14
14
  module Schemas
15
15
  class OpenAPI
16
- def initialize: (Hash[bot, bot] hash, untyped config, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot]) -> OpenAPIParser::Schemas::OpenAPI
16
+ def initialize: (Hash[bot, bot] hash, untyped config, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot], ?referrer: OpenAPIParser::Schemas::OpenAPI?) -> OpenAPIParser::Schemas::OpenAPI
17
17
  def openapi: () -> String?
18
18
  def openapi_version: () -> Gem::Version?
19
+ def use_3_1_features?: () -> bool
20
+ def use_3_2_features?: () -> bool
19
21
  end
20
22
  end
21
23
  end
data/sig/wip_types.rbs CHANGED
@@ -48,6 +48,11 @@ end
48
48
 
49
49
  class OpenAPIParser::Schemas::OpenAPI < OpenAPIParser::Schemas::Base
50
50
  attr_reader paths: untyped
51
+ attr_reader components: OpenAPIParser::Schemas::Components | nil
52
+ end
53
+
54
+ class OpenAPIParser::Schemas::Components < OpenAPIParser::Schemas::Base
55
+ attr_reader schemas: Hash[String, OpenAPIParser::Schemas::Schema] | nil
51
56
  end
52
57
 
53
58
  module OpenAPIParser::Expandable
@@ -61,4 +66,5 @@ end
61
66
  class OpenAPIParser::Schemas::Discriminator < OpenAPIParser::Schemas::Base
62
67
  attr_reader property_name: (String | nil)
63
68
  attr_reader mapping: Hash[String, String]
69
+ attr_reader default_mapping: (String | nil)
64
70
  end