openapi_parser 2.4.0 → 2.6.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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +2 -3
  3. data/CHANGELOG.md +43 -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 +31 -0
  10. data/lib/openapi_parser/schema_validator/any_of_validator.rb +1 -1
  11. data/lib/openapi_parser/schema_validator/base.rb +35 -9
  12. data/lib/openapi_parser/schema_validator/float_validator.rb +4 -0
  13. data/lib/openapi_parser/schema_validator/integer_validator.rb +19 -1
  14. data/lib/openapi_parser/schema_validator/multiple_of.rb +26 -0
  15. data/lib/openapi_parser/schema_validator/nil_validator.rb +4 -0
  16. data/lib/openapi_parser/schema_validator/one_of_validator.rb +1 -1
  17. data/lib/openapi_parser/schema_validator.rb +45 -7
  18. data/lib/openapi_parser/schemas/components.rb +4 -0
  19. data/lib/openapi_parser/schemas/discriminator.rb +4 -0
  20. data/lib/openapi_parser/schemas/media_type.rb +4 -0
  21. data/lib/openapi_parser/schemas/openapi.rb +40 -3
  22. data/lib/openapi_parser/schemas/path_item.rb +32 -6
  23. data/lib/openapi_parser/schemas/request_body.rb +1 -1
  24. data/lib/openapi_parser/schemas/response.rb +5 -1
  25. data/lib/openapi_parser/schemas/schema.rb +16 -1
  26. data/lib/openapi_parser/spec_validator/rule.rb +24 -3
  27. data/lib/openapi_parser/spec_validator/rules/additional_operations_before_32.rb +26 -0
  28. data/lib/openapi_parser/spec_validator/rules/allow_empty_value_deprecation.rb +26 -0
  29. data/lib/openapi_parser/spec_validator/rules/boolean_schema_in_30.rb +26 -0
  30. data/lib/openapi_parser/spec_validator/rules/cookie_style_before_32.rb +26 -0
  31. data/lib/openapi_parser/spec_validator/rules/default_mapping_before_32.rb +29 -0
  32. data/lib/openapi_parser/spec_validator/rules/defs_in_30.rb +25 -0
  33. data/lib/openapi_parser/spec_validator/rules/example_value_fields_before_32.rb +48 -0
  34. data/lib/openapi_parser/spec_validator/rules/media_types_before_32.rb +24 -0
  35. data/lib/openapi_parser/spec_validator/rules/query_method_before_32.rb +26 -0
  36. data/lib/openapi_parser/spec_validator/rules/querystring_before_32.rb +26 -0
  37. data/lib/openapi_parser/spec_validator/rules/response_summary_before_32.rb +25 -0
  38. data/lib/openapi_parser/spec_validator/rules/security_scheme_fields_before_32.rb +41 -0
  39. data/lib/openapi_parser/spec_validator/rules/self_before_32.rb +20 -0
  40. data/lib/openapi_parser/spec_validator/rules/server_name_before_32.rb +35 -0
  41. data/lib/openapi_parser/spec_validator/rules/streaming_fields_before_32.rb +56 -0
  42. data/lib/openapi_parser/spec_validator/rules/tag_fields_before_32.rb +34 -0
  43. data/lib/openapi_parser/spec_validator/rules/xml_attribute_deprecation.rb +29 -0
  44. data/lib/openapi_parser/spec_validator/rules/xml_node_type_before_32.rb +29 -0
  45. data/lib/openapi_parser/spec_validator/rules/xml_wrapped_deprecation.rb +29 -0
  46. data/lib/openapi_parser/spec_validator.rb +38 -0
  47. data/lib/openapi_parser/version.rb +1 -1
  48. data/lib/openapi_parser.rb +5 -4
  49. data/sig/openapi_parser/config.rbs +1 -0
  50. data/sig/openapi_parser/schema_validator.rbs +1 -0
  51. data/sig/openapi_parser/schema_validators/base.rbs +4 -2
  52. data/sig/openapi_parser/spec_validator.rbs +85 -0
  53. data/sig/openapi_parser.rbs +5 -3
  54. data/sig/wip_types.rbs +6 -0
  55. metadata +21 -1
@@ -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
@@ -5,6 +5,7 @@ require_relative 'spec_validator/rules/exclusive_maximum'
5
5
  require_relative 'spec_validator/rules/content_encoding_in_30'
6
6
  require_relative 'spec_validator/rules/content_media_type_in_30'
7
7
  require_relative 'spec_validator/rules/prefix_items_in_30'
8
+ require_relative 'spec_validator/rules/boolean_schema_in_30'
8
9
  require_relative 'spec_validator/rules/json_schema_dialect_in_30'
9
10
  require_relative 'spec_validator/rules/type_array_in_30'
10
11
  require_relative 'spec_validator/rules/path_items_in_30'
@@ -16,6 +17,24 @@ require_relative 'spec_validator/rules/const_in_30'
16
17
  require_relative 'spec_validator/rules/dynamic_ref_in_30'
17
18
  require_relative 'spec_validator/rules/dynamic_anchor_in_30'
18
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/allow_empty_value_deprecation'
22
+ require_relative 'spec_validator/rules/xml_node_type_before_32'
23
+ require_relative 'spec_validator/rules/xml_attribute_deprecation'
24
+ require_relative 'spec_validator/rules/xml_wrapped_deprecation'
25
+ require_relative 'spec_validator/rules/media_types_before_32'
26
+ require_relative 'spec_validator/rules/default_mapping_before_32'
27
+ require_relative 'spec_validator/rules/cookie_style_before_32'
28
+ require_relative 'spec_validator/rules/server_name_before_32'
29
+ require_relative 'spec_validator/rules/self_before_32'
30
+ require_relative 'spec_validator/rules/query_method_before_32'
31
+ require_relative 'spec_validator/rules/additional_operations_before_32'
32
+ require_relative 'spec_validator/rules/response_summary_before_32'
33
+ require_relative 'spec_validator/rules/tag_fields_before_32'
34
+ require_relative 'spec_validator/rules/example_value_fields_before_32'
35
+ require_relative 'spec_validator/rules/security_scheme_fields_before_32'
36
+ require_relative 'spec_validator/rules/streaming_fields_before_32'
37
+ require_relative 'spec_validator/rules/querystring_before_32'
19
38
 
20
39
  module OpenAPIParser
21
40
  class SpecViolationError < OpenAPIError
@@ -68,6 +87,7 @@ module OpenAPIParser
68
87
  Rules::ContentEncodingIn30,
69
88
  Rules::ContentMediaTypeIn30,
70
89
  Rules::PrefixItemsIn30,
90
+ Rules::BooleanSchemaIn30,
71
91
  Rules::JsonSchemaDialectIn30,
72
92
  Rules::TypeArrayIn30,
73
93
  Rules::PathItemsIn30,
@@ -79,6 +99,24 @@ module OpenAPIParser
79
99
  Rules::DynamicRefIn30,
80
100
  Rules::DynamicAnchorIn30,
81
101
  Rules::ContentSchemaIn30,
102
+ Rules::DefsIn30,
103
+ Rules::AllowEmptyValueDeprecation,
104
+ Rules::XmlNodeTypeBefore32,
105
+ Rules::XmlAttributeDeprecation,
106
+ Rules::XmlWrappedDeprecation,
107
+ Rules::MediaTypesBefore32,
108
+ Rules::DefaultMappingBefore32,
109
+ Rules::CookieStyleBefore32,
110
+ Rules::ServerNameBefore32,
111
+ Rules::SelfBefore32,
112
+ Rules::QueryMethodBefore32,
113
+ Rules::AdditionalOperationsBefore32,
114
+ Rules::ResponseSummaryBefore32,
115
+ Rules::TagFieldsBefore32,
116
+ Rules::ExampleValueFieldsBefore32,
117
+ Rules::SecuritySchemeFieldsBefore32,
118
+ Rules::StreamingFieldsBefore32,
119
+ Rules::QuerystringBefore32,
82
120
  ]
83
121
  end
84
122
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '2.4.0'.freeze
2
+ VERSION = '2.6.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
@@ -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
 
@@ -59,6 +62,10 @@ module OpenAPIParser
59
62
  def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
60
63
  end
61
64
 
65
+ class BooleanSchemaIn30 < Rule
66
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
67
+ end
68
+
62
69
  class JsonSchemaDialectIn30 < Rule
63
70
  def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
64
71
  end
@@ -102,6 +109,84 @@ module OpenAPIParser
102
109
  class ContentSchemaIn30 < Rule
103
110
  def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
104
111
  end
112
+
113
+ class DefsIn30 < Rule
114
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
115
+ end
116
+
117
+ class AllowEmptyValueDeprecation < Rule
118
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
119
+ end
120
+
121
+ class XmlNodeTypeBefore32 < Rule
122
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
123
+ end
124
+
125
+ class XmlAttributeDeprecation < Rule
126
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
127
+ end
128
+
129
+ class XmlWrappedDeprecation < Rule
130
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
131
+ end
132
+
133
+ class MediaTypesBefore32 < Rule
134
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
135
+ end
136
+
137
+ class DefaultMappingBefore32 < Rule
138
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
139
+ end
140
+
141
+ class CookieStyleBefore32 < Rule
142
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
143
+ end
144
+
145
+ class ServerNameBefore32 < Rule
146
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
147
+ end
148
+
149
+ class SelfBefore32 < Rule
150
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
151
+ end
152
+
153
+ class QueryMethodBefore32 < Rule
154
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
155
+ end
156
+
157
+ class AdditionalOperationsBefore32 < Rule
158
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
159
+ end
160
+
161
+ class ResponseSummaryBefore32 < Rule
162
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
163
+ end
164
+
165
+ class TagFieldsBefore32 < Rule
166
+ NEW_FIELDS: Array[String]
167
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
168
+ end
169
+
170
+ class ExampleValueFieldsBefore32 < Rule
171
+ NEW_FIELDS: Array[String]
172
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
173
+ end
174
+
175
+ class SecuritySchemeFieldsBefore32 < Rule
176
+ NEW_FIELDS: Array[String]
177
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
178
+ end
179
+
180
+ class StreamingFieldsBefore32 < Rule
181
+ NEW_FIELDS: Array[String]
182
+ NEW_ENCODING_FIELDS: Array[String]
183
+ private def encoding_violations: (untyped node, untyped encodings) -> Array[SpecValidator::SpecViolation]
184
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
185
+ end
186
+
187
+ class QuerystringBefore32 < Rule
188
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
189
+ end
105
190
  end
106
191
  end
107
192
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
@@ -182,6 +182,7 @@ files:
182
182
  - lib/openapi_parser/schema_validator/float_validator.rb
183
183
  - lib/openapi_parser/schema_validator/integer_validator.rb
184
184
  - lib/openapi_parser/schema_validator/minimum_maximum.rb
185
+ - lib/openapi_parser/schema_validator/multiple_of.rb
185
186
  - lib/openapi_parser/schema_validator/nil_validator.rb
186
187
  - lib/openapi_parser/schema_validator/object_validator.rb
187
188
  - lib/openapi_parser/schema_validator/one_of_validator.rb
@@ -210,22 +211,41 @@ files:
210
211
  - lib/openapi_parser/schemas/schema.rb
211
212
  - lib/openapi_parser/spec_validator.rb
212
213
  - lib/openapi_parser/spec_validator/rule.rb
214
+ - lib/openapi_parser/spec_validator/rules/additional_operations_before_32.rb
215
+ - lib/openapi_parser/spec_validator/rules/allow_empty_value_deprecation.rb
216
+ - lib/openapi_parser/spec_validator/rules/boolean_schema_in_30.rb
213
217
  - lib/openapi_parser/spec_validator/rules/const_in_30.rb
214
218
  - lib/openapi_parser/spec_validator/rules/content_encoding_in_30.rb
215
219
  - lib/openapi_parser/spec_validator/rules/content_media_type_in_30.rb
216
220
  - lib/openapi_parser/spec_validator/rules/content_schema_in_30.rb
221
+ - lib/openapi_parser/spec_validator/rules/cookie_style_before_32.rb
222
+ - lib/openapi_parser/spec_validator/rules/default_mapping_before_32.rb
223
+ - lib/openapi_parser/spec_validator/rules/defs_in_30.rb
217
224
  - lib/openapi_parser/spec_validator/rules/dynamic_anchor_in_30.rb
218
225
  - lib/openapi_parser/spec_validator/rules/dynamic_ref_in_30.rb
219
226
  - lib/openapi_parser/spec_validator/rules/example_singular_deprecation.rb
227
+ - lib/openapi_parser/spec_validator/rules/example_value_fields_before_32.rb
220
228
  - lib/openapi_parser/spec_validator/rules/exclusive_maximum.rb
221
229
  - lib/openapi_parser/spec_validator/rules/exclusive_minimum.rb
222
230
  - lib/openapi_parser/spec_validator/rules/json_schema_dialect_in_30.rb
231
+ - lib/openapi_parser/spec_validator/rules/media_types_before_32.rb
223
232
  - lib/openapi_parser/spec_validator/rules/nullable_deprecation.rb
224
233
  - lib/openapi_parser/spec_validator/rules/path_items_in_30.rb
225
234
  - lib/openapi_parser/spec_validator/rules/prefix_items_in_30.rb
235
+ - lib/openapi_parser/spec_validator/rules/query_method_before_32.rb
236
+ - lib/openapi_parser/spec_validator/rules/querystring_before_32.rb
237
+ - lib/openapi_parser/spec_validator/rules/response_summary_before_32.rb
238
+ - lib/openapi_parser/spec_validator/rules/security_scheme_fields_before_32.rb
239
+ - lib/openapi_parser/spec_validator/rules/self_before_32.rb
240
+ - lib/openapi_parser/spec_validator/rules/server_name_before_32.rb
241
+ - lib/openapi_parser/spec_validator/rules/streaming_fields_before_32.rb
242
+ - lib/openapi_parser/spec_validator/rules/tag_fields_before_32.rb
226
243
  - lib/openapi_parser/spec_validator/rules/type_array_in_30.rb
227
244
  - lib/openapi_parser/spec_validator/rules/type_null_in_30.rb
228
245
  - lib/openapi_parser/spec_validator/rules/webhooks_in_30.rb
246
+ - lib/openapi_parser/spec_validator/rules/xml_attribute_deprecation.rb
247
+ - lib/openapi_parser/spec_validator/rules/xml_node_type_before_32.rb
248
+ - lib/openapi_parser/spec_validator/rules/xml_wrapped_deprecation.rb
229
249
  - lib/openapi_parser/spec_validator/spec_violation.rb
230
250
  - lib/openapi_parser/version.rb
231
251
  - openapi_parser.gemspec