openapi_parser 2.3.1 → 2.5.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +2 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +40 -0
  5. data/lib/openapi_parser/config.rb +12 -0
  6. data/lib/openapi_parser/errors.rb +7 -0
  7. data/lib/openapi_parser/schema_validator/array_validator.rb +7 -3
  8. data/lib/openapi_parser/schema_validator/integer_validator.rb +2 -0
  9. data/lib/openapi_parser/schema_validator/minimum_maximum.rb +17 -4
  10. data/lib/openapi_parser/schema_validator/nil_validator.rb +4 -0
  11. data/lib/openapi_parser/schema_validator/type_mismatch_validator.rb +11 -0
  12. data/lib/openapi_parser/schema_validator.rb +92 -1
  13. data/lib/openapi_parser/schemas/components.rb +4 -0
  14. data/lib/openapi_parser/schemas/openapi.rb +24 -0
  15. data/lib/openapi_parser/schemas/schema.rb +20 -1
  16. data/lib/openapi_parser/spec_validator/rule.rb +68 -0
  17. data/lib/openapi_parser/spec_validator/rules/boolean_schema_in_30.rb +26 -0
  18. data/lib/openapi_parser/spec_validator/rules/const_in_30.rb +25 -0
  19. data/lib/openapi_parser/spec_validator/rules/content_encoding_in_30.rb +24 -0
  20. data/lib/openapi_parser/spec_validator/rules/content_media_type_in_30.rb +25 -0
  21. data/lib/openapi_parser/spec_validator/rules/content_schema_in_30.rb +25 -0
  22. data/lib/openapi_parser/spec_validator/rules/dynamic_anchor_in_30.rb +25 -0
  23. data/lib/openapi_parser/spec_validator/rules/dynamic_ref_in_30.rb +25 -0
  24. data/lib/openapi_parser/spec_validator/rules/example_singular_deprecation.rb +25 -0
  25. data/lib/openapi_parser/spec_validator/rules/exclusive_maximum.rb +32 -0
  26. data/lib/openapi_parser/spec_validator/rules/exclusive_minimum.rb +32 -0
  27. data/lib/openapi_parser/spec_validator/rules/json_schema_dialect_in_30.rb +19 -0
  28. data/lib/openapi_parser/spec_validator/rules/nullable_deprecation.rb +25 -0
  29. data/lib/openapi_parser/spec_validator/rules/path_items_in_30.rb +25 -0
  30. data/lib/openapi_parser/spec_validator/rules/prefix_items_in_30.rb +25 -0
  31. data/lib/openapi_parser/spec_validator/rules/self_before_32.rb +20 -0
  32. data/lib/openapi_parser/spec_validator/rules/type_array_in_30.rb +25 -0
  33. data/lib/openapi_parser/spec_validator/rules/type_null_in_30.rb +26 -0
  34. data/lib/openapi_parser/spec_validator/rules/webhooks_in_30.rb +18 -0
  35. data/lib/openapi_parser/spec_validator/spec_violation.rb +11 -0
  36. data/lib/openapi_parser/spec_validator.rb +89 -0
  37. data/lib/openapi_parser/version.rb +1 -1
  38. data/lib/openapi_parser.rb +3 -0
  39. data/sig/openapi_parser/config.rbs +2 -0
  40. data/sig/openapi_parser/schema_validator.rbs +3 -0
  41. data/sig/openapi_parser/spec_validator.rbs +117 -0
  42. data/sig/openapi_parser.rbs +2 -0
  43. metadata +25 -2
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `$dynamicRef` is a JSON Schema 2020-12 referencing mechanism that
5
+ # 3.1 adopted. 3.0 does not recognize it. The parse layer keeps the
6
+ # value as raw schema data; this rule reports the version mismatch.
7
+ class DynamicRefIn30 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.1')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ next unless schema.raw_schema.is_a?(Hash) && schema.raw_schema.key?('$dynamicRef')
14
+
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: '`$dynamicRef` is a 3.1 addition (from JSON Schema 2020-12); 3.0 only knows `$ref`',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # In 3.1 the singular `example` keyword on a Schema is deprecated in
5
+ # favor of the JSON Schema `examples` array. The field is still
6
+ # allowed but discouraged, so we report it as a violation.
7
+ class ExampleSingularDeprecation < Rule
8
+ def check(root)
9
+ return [] unless version_at_least?('3.1')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ next unless schema.raw_schema.is_a?(Hash) && schema.raw_schema.key?('example')
14
+
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: 'singular `example` on a Schema is deprecated in 3.1; use the `examples` array',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ class ExclusiveMaximum < Rule
5
+ def check(root)
6
+ return [] if version.nil?
7
+
8
+ violations = []
9
+ each_schema(root) do |schema|
10
+ value = schema.exclusiveMaximum
11
+ next if value.nil?
12
+
13
+ if version_before?('3.1')
14
+ if value.is_a?(Numeric)
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: 'numeric exclusiveMaximum is a 3.1-only form; in 3.0 use a Boolean modifier paired with `maximum`',
18
+ )
19
+ end
20
+ elsif value == true || value == false
21
+ violations << violation(
22
+ path: schema.object_reference,
23
+ message: 'Boolean exclusiveMaximum is a 3.0-only form; in 3.1 use a standalone numeric bound',
24
+ )
25
+ end
26
+ end
27
+ violations
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ class ExclusiveMinimum < Rule
5
+ def check(root)
6
+ return [] if version.nil?
7
+
8
+ violations = []
9
+ each_schema(root) do |schema|
10
+ value = schema.exclusiveMinimum
11
+ next if value.nil?
12
+
13
+ if version_before?('3.1')
14
+ if value.is_a?(Numeric)
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: 'numeric exclusiveMinimum is a 3.1-only form; in 3.0 use a Boolean modifier paired with `minimum`',
18
+ )
19
+ end
20
+ elsif value == true || value == false
21
+ violations << violation(
22
+ path: schema.object_reference,
23
+ message: 'Boolean exclusiveMinimum is a 3.0-only form; in 3.1 use a standalone numeric bound',
24
+ )
25
+ end
26
+ end
27
+ violations
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `jsonSchemaDialect` is a 3.1 root-level addition; 3.0 has no
5
+ # equivalent.
6
+ class JsonSchemaDialectIn30 < Rule
7
+ def check(root)
8
+ return [] unless version_before?('3.1')
9
+ return [] unless root.raw_schema.is_a?(Hash) && root.raw_schema.key?('jsonSchemaDialect')
10
+
11
+ [violation(
12
+ path: '#/jsonSchemaDialect',
13
+ message: '`jsonSchemaDialect` is a 3.1 root-level addition; 3.0 documents have no such field',
14
+ )]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `nullable` is a 3.0 keyword that 3.1 removed in favor of
5
+ # `type: [..., "null"]`. The field's mere presence on a 3.1 document
6
+ # is a spec violation, regardless of true/false.
7
+ class NullableDeprecation < Rule
8
+ def check(root)
9
+ return [] unless version_at_least?('3.1')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ next unless schema.raw_schema.is_a?(Hash) && schema.raw_schema.key?('nullable')
14
+
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: '`nullable` was removed in 3.1; use `type: [..., "null"]` instead',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `components.pathItems` is a 3.1 addition. The parse layer accepts it
5
+ # in 3.0 documents permissively; this rule reports the version
6
+ # mismatch.
7
+ class PathItemsIn30 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.1')
10
+
11
+ components = root.components
12
+ return [] unless components
13
+
14
+ raw = components.raw_schema
15
+ return [] unless raw.is_a?(Hash) && raw.key?('pathItems')
16
+
17
+ [violation(
18
+ path: "#{components.object_reference}/pathItems",
19
+ message: '`components.pathItems` is a 3.1 addition; 3.0 documents should not declare it',
20
+ )]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `prefixItems` is JSON Schema 2020-12's positional tuple keyword.
5
+ # 3.1 adopts it; 3.0 has no equivalent and parsing it is a spec
6
+ # mismatch the validator should report.
7
+ class PrefixItemsIn30 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.1')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ next unless schema.raw_schema.is_a?(Hash) && schema.raw_schema.key?('prefixItems')
14
+
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: '`prefixItems` is a 3.1 addition (from JSON Schema 2020-12); 3.0 has no equivalent',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `$self` is a 3.2 root-level addition declaring the document's own
5
+ # URI for reference resolution. The parse layer accepts it
6
+ # permissively; this rule reports the version mismatch.
7
+ class SelfBefore32 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.2')
10
+ return [] unless root.raw_schema.is_a?(Hash) && root.raw_schema.key?('$self')
11
+
12
+ [violation(
13
+ path: '#/$self',
14
+ message: '`$self` is a 3.2 root-level addition; earlier documents have no such field',
15
+ )]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # 3.1 lets `type` be an Array of primitive type names (e.g.
5
+ # `["string", "null"]`). 3.0 only allowed a single String, so the
6
+ # array form on a 3.0 document is a spec violation.
7
+ class TypeArrayIn30 < Rule
8
+ def check(root)
9
+ return [] unless version_before?('3.1')
10
+
11
+ violations = []
12
+ each_schema(root) do |schema|
13
+ next unless schema.type.is_a?(Array)
14
+
15
+ violations << violation(
16
+ path: schema.object_reference,
17
+ message: '`type` as an Array of primitive names is a 3.1 addition; 3.0 expects a single type String',
18
+ )
19
+ end
20
+ violations
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `type: "null"` was added by 3.1; 3.0 only allowed the original six
5
+ # primitive type names. The parse layer accepts the literal anyway,
6
+ # so we report the mismatch here. Array-form types like
7
+ # `["string", "null"]` are covered by a separate rule.
8
+ class TypeNullIn30 < Rule
9
+ def check(root)
10
+ return [] unless version_before?('3.1')
11
+
12
+ violations = []
13
+ each_schema(root) do |schema|
14
+ next unless schema.type == 'null'
15
+
16
+ violations << violation(
17
+ path: schema.object_reference,
18
+ message: '`type: "null"` is a 3.1 addition; 3.0 documents have no such primitive',
19
+ )
20
+ end
21
+ violations
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ module Rules
4
+ # `webhooks` is a 3.1 root-level addition; 3.0 has no equivalent.
5
+ class WebhooksIn30 < Rule
6
+ def check(root)
7
+ return [] unless version_before?('3.1')
8
+ return [] unless root.raw_schema.is_a?(Hash) && root.raw_schema.key?('webhooks')
9
+
10
+ [violation(
11
+ path: '#/webhooks',
12
+ message: '`webhooks` is a 3.1 root-level addition; 3.0 documents have no such field',
13
+ )]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module OpenAPIParser
2
+ class SpecValidator
3
+ SpecViolation = Struct.new(:message, :path, :rule_name, keyword_init: true) do
4
+ def to_s
5
+ "[#{rule_name}] #{path}: #{message}"
6
+ end
7
+ end
8
+ end
9
+
10
+ SpecViolation = SpecValidator::SpecViolation
11
+ end
@@ -0,0 +1,89 @@
1
+ require_relative 'spec_validator/spec_violation'
2
+ require_relative 'spec_validator/rule'
3
+ require_relative 'spec_validator/rules/exclusive_minimum'
4
+ require_relative 'spec_validator/rules/exclusive_maximum'
5
+ require_relative 'spec_validator/rules/content_encoding_in_30'
6
+ require_relative 'spec_validator/rules/content_media_type_in_30'
7
+ require_relative 'spec_validator/rules/prefix_items_in_30'
8
+ require_relative 'spec_validator/rules/boolean_schema_in_30'
9
+ require_relative 'spec_validator/rules/json_schema_dialect_in_30'
10
+ require_relative 'spec_validator/rules/type_array_in_30'
11
+ require_relative 'spec_validator/rules/path_items_in_30'
12
+ require_relative 'spec_validator/rules/nullable_deprecation'
13
+ require_relative 'spec_validator/rules/example_singular_deprecation'
14
+ require_relative 'spec_validator/rules/type_null_in_30'
15
+ require_relative 'spec_validator/rules/webhooks_in_30'
16
+ require_relative 'spec_validator/rules/const_in_30'
17
+ require_relative 'spec_validator/rules/dynamic_ref_in_30'
18
+ require_relative 'spec_validator/rules/dynamic_anchor_in_30'
19
+ require_relative 'spec_validator/rules/content_schema_in_30'
20
+ require_relative 'spec_validator/rules/self_before_32'
21
+
22
+ module OpenAPIParser
23
+ class SpecViolationError < OpenAPIError
24
+ attr_reader :violations
25
+
26
+ def initialize(violations)
27
+ @violations = violations
28
+ super(nil)
29
+ end
30
+
31
+ def message
32
+ @violations.map(&:to_s).join("\n")
33
+ end
34
+ end
35
+
36
+ class SpecValidator
37
+ def self.run(root)
38
+ new(root).run
39
+ end
40
+
41
+ def self.run!(root, policy:)
42
+ return if policy == :silent
43
+
44
+ violations = run(root)
45
+ return if violations.empty?
46
+
47
+ case policy
48
+ when :warn
49
+ violations.each { |v| warn(v.to_s) }
50
+ when :raise
51
+ raise OpenAPIParser::SpecViolationError.new(violations)
52
+ end
53
+ end
54
+
55
+ def initialize(root)
56
+ @root = root
57
+ @version = root.openapi_version
58
+ end
59
+
60
+ def run
61
+ rules.flat_map { |klass| klass.new(@version).check(@root) }
62
+ end
63
+
64
+ private
65
+
66
+ def rules
67
+ [
68
+ Rules::ExclusiveMinimum,
69
+ Rules::ExclusiveMaximum,
70
+ Rules::ContentEncodingIn30,
71
+ Rules::ContentMediaTypeIn30,
72
+ Rules::PrefixItemsIn30,
73
+ Rules::BooleanSchemaIn30,
74
+ Rules::JsonSchemaDialectIn30,
75
+ Rules::TypeArrayIn30,
76
+ Rules::PathItemsIn30,
77
+ Rules::NullableDeprecation,
78
+ Rules::ExampleSingularDeprecation,
79
+ Rules::TypeNullIn30,
80
+ Rules::WebhooksIn30,
81
+ Rules::ConstIn30,
82
+ Rules::DynamicRefIn30,
83
+ Rules::DynamicAnchorIn30,
84
+ Rules::ContentSchemaIn30,
85
+ Rules::SelfBefore32,
86
+ ]
87
+ end
88
+ end
89
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '2.3.1'.freeze
2
+ VERSION = '2.5.0'.freeze
3
3
  end
@@ -15,6 +15,7 @@ require 'openapi_parser/request_operation'
15
15
  require 'openapi_parser/schema_validator'
16
16
  require 'openapi_parser/parameter_validator'
17
17
  require 'openapi_parser/reference_expander'
18
+ require 'openapi_parser/spec_validator'
18
19
 
19
20
  module OpenAPIParser
20
21
  class << self
@@ -99,6 +100,8 @@ module OpenAPIParser
99
100
  path_item.set_path_item_to_operation
100
101
  end
101
102
 
103
+ OpenAPIParser::SpecValidator.run!(root, policy: config.strict_specification_version)
104
+
102
105
  root
103
106
  end
104
107
  end
@@ -15,6 +15,8 @@ module OpenAPIParser
15
15
  def expand_reference: -> bool
16
16
  def strict_response_validation: -> bool
17
17
  def strict_reference_validation: -> bool
18
+ KNOWN_STRICT_SPECIFICATION_VERSION_VALUES: Array[Symbol]
19
+ def strict_specification_version: -> (:silent | :warn | :raise)
18
20
  def validate_header: -> bool
19
21
  def request_validator_options: -> OpenAPIParser::SchemaValidator::Options
20
22
  def response_validate_options: -> OpenAPIParser::SchemaValidator::ResponseValidateOptions
@@ -27,6 +27,9 @@ module OpenAPIParser
27
27
 
28
28
  private
29
29
  def validator: (Object value, OpenAPIParser::Schemas::Schema schema) -> [OpenAPIParser::SchemaValidator::Base, OpenAPIParser::validate_error]
30
+ def validator_for_type: (String? type) -> OpenAPIParser::SchemaValidator::Base
31
+ def coerce_into_type_array?: (Object value, OpenAPIParser::Schemas::Schema schema) -> bool
32
+ def coerce_into_type_array: (Object value, OpenAPIParser::Schemas::Schema schema, **untyped) -> [Object, OpenAPIParser::validate_error]
30
33
  def string_validator: -> OpenAPIParser::SchemaValidator::StringValidator
31
34
  def integer_validator: -> OpenAPIParser::SchemaValidator::IntegerValidator
32
35
  def float_validator: -> OpenAPIParser::SchemaValidator::FloatValidator
@@ -0,0 +1,117 @@
1
+ module OpenAPIParser
2
+ class SpecViolationError < OpenAPIError
3
+ @violations: Array[OpenAPIParser::SpecValidator::SpecViolation]
4
+ attr_reader violations: Array[OpenAPIParser::SpecValidator::SpecViolation]
5
+
6
+ def initialize: (Array[OpenAPIParser::SpecValidator::SpecViolation] violations) -> void
7
+ def message: () -> String
8
+ end
9
+
10
+ class SpecValidator
11
+ @root: OpenAPIParser::Schemas::OpenAPI
12
+ @version: Gem::Version?
13
+
14
+ def self.run: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecViolation]
15
+ def self.run!: (OpenAPIParser::Schemas::OpenAPI root, policy: (:silent | :warn | :raise)) -> void
16
+ def initialize: (OpenAPIParser::Schemas::OpenAPI root) -> void
17
+ def run: () -> Array[SpecViolation]
18
+ private def rules: () -> Array[singleton(Rule)]
19
+
20
+ class SpecViolation < ::Struct[untyped]
21
+ attr_accessor message: String
22
+ attr_accessor path: String
23
+ attr_accessor rule_name: Symbol
24
+ def to_s: () -> String
25
+ end
26
+
27
+ class Rule
28
+ @version: Gem::Version?
29
+ attr_reader version: Gem::Version?
30
+
31
+ def self.rule_name: () -> Symbol
32
+ def initialize: (Gem::Version? version) -> void
33
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecViolation]
34
+ def version_before?: (String boundary) -> bool
35
+ def version_at_least?: (String boundary) -> bool
36
+ private def violation: (path: String, message: String) -> SpecViolation
37
+ private def each_schema: (untyped root) ?{ (untyped) -> void } -> untyped
38
+ private def walk: (untyped node, Hash[Integer, bool] visited) { (untyped) -> void } -> void
39
+ end
40
+
41
+ module Rules
42
+ class ExclusiveMinimum < Rule
43
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
44
+ end
45
+
46
+ class ExclusiveMaximum < Rule
47
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
48
+ end
49
+
50
+ class ContentEncodingIn30 < Rule
51
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
52
+ end
53
+
54
+ class ContentMediaTypeIn30 < Rule
55
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
56
+ end
57
+
58
+ class PrefixItemsIn30 < Rule
59
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
60
+ end
61
+
62
+ class BooleanSchemaIn30 < Rule
63
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
64
+ end
65
+
66
+ class JsonSchemaDialectIn30 < Rule
67
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
68
+ end
69
+
70
+ class TypeArrayIn30 < Rule
71
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
72
+ end
73
+
74
+ class PathItemsIn30 < Rule
75
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
76
+ end
77
+
78
+ class NullableDeprecation < Rule
79
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
80
+ end
81
+
82
+ class ExampleSingularDeprecation < Rule
83
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
84
+ end
85
+
86
+ class TypeNullIn30 < Rule
87
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
88
+ end
89
+
90
+ class WebhooksIn30 < Rule
91
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
92
+ end
93
+
94
+ class ConstIn30 < Rule
95
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
96
+ end
97
+
98
+ class DynamicRefIn30 < Rule
99
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
100
+ end
101
+
102
+ class DynamicAnchorIn30 < Rule
103
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
104
+ end
105
+
106
+ class ContentSchemaIn30 < Rule
107
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
108
+ end
109
+
110
+ class SelfBefore32 < Rule
111
+ def check: (OpenAPIParser::Schemas::OpenAPI root) -> Array[SpecValidator::SpecViolation]
112
+ end
113
+ end
114
+ end
115
+
116
+ SpecViolation: singleton(SpecValidator::SpecViolation)
117
+ end
@@ -14,6 +14,8 @@ module OpenAPIParser
14
14
  module Schemas
15
15
  class OpenAPI
16
16
  def initialize: (Hash[bot, bot] hash, untyped config, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot]) -> OpenAPIParser::Schemas::OpenAPI
17
+ def openapi: () -> String?
18
+ def openapi_version: () -> Gem::Version?
17
19
  end
18
20
  end
19
21
  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.3.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
@@ -188,6 +188,7 @@ files:
188
188
  - lib/openapi_parser/schema_validator/options.rb
189
189
  - lib/openapi_parser/schema_validator/properties_number.rb
190
190
  - lib/openapi_parser/schema_validator/string_validator.rb
191
+ - lib/openapi_parser/schema_validator/type_mismatch_validator.rb
191
192
  - lib/openapi_parser/schema_validator/unspecified_type_validator.rb
192
193
  - lib/openapi_parser/schemas.rb
193
194
  - lib/openapi_parser/schemas/base.rb
@@ -207,6 +208,27 @@ files:
207
208
  - lib/openapi_parser/schemas/response.rb
208
209
  - lib/openapi_parser/schemas/responses.rb
209
210
  - lib/openapi_parser/schemas/schema.rb
211
+ - lib/openapi_parser/spec_validator.rb
212
+ - lib/openapi_parser/spec_validator/rule.rb
213
+ - lib/openapi_parser/spec_validator/rules/boolean_schema_in_30.rb
214
+ - lib/openapi_parser/spec_validator/rules/const_in_30.rb
215
+ - lib/openapi_parser/spec_validator/rules/content_encoding_in_30.rb
216
+ - lib/openapi_parser/spec_validator/rules/content_media_type_in_30.rb
217
+ - lib/openapi_parser/spec_validator/rules/content_schema_in_30.rb
218
+ - lib/openapi_parser/spec_validator/rules/dynamic_anchor_in_30.rb
219
+ - lib/openapi_parser/spec_validator/rules/dynamic_ref_in_30.rb
220
+ - lib/openapi_parser/spec_validator/rules/example_singular_deprecation.rb
221
+ - lib/openapi_parser/spec_validator/rules/exclusive_maximum.rb
222
+ - lib/openapi_parser/spec_validator/rules/exclusive_minimum.rb
223
+ - lib/openapi_parser/spec_validator/rules/json_schema_dialect_in_30.rb
224
+ - lib/openapi_parser/spec_validator/rules/nullable_deprecation.rb
225
+ - lib/openapi_parser/spec_validator/rules/path_items_in_30.rb
226
+ - lib/openapi_parser/spec_validator/rules/prefix_items_in_30.rb
227
+ - lib/openapi_parser/spec_validator/rules/self_before_32.rb
228
+ - lib/openapi_parser/spec_validator/rules/type_array_in_30.rb
229
+ - lib/openapi_parser/spec_validator/rules/type_null_in_30.rb
230
+ - lib/openapi_parser/spec_validator/rules/webhooks_in_30.rb
231
+ - lib/openapi_parser/spec_validator/spec_violation.rb
210
232
  - lib/openapi_parser/version.rb
211
233
  - openapi_parser.gemspec
212
234
  - sig/openapi_parser.rbs
@@ -217,6 +239,7 @@ files:
217
239
  - sig/openapi_parser/schema_validators/base.rbs
218
240
  - sig/openapi_parser/schema_validators/options.rbs
219
241
  - sig/openapi_parser/schemas/base.rbs
242
+ - sig/openapi_parser/spec_validator.rbs
220
243
  - sig/openapi_parser/version.rbs
221
244
  - sig/types.rbs
222
245
  - sig/wip_types.rbs
@@ -238,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
261
  - !ruby/object:Gem::Version
239
262
  version: '0'
240
263
  requirements: []
241
- rubygems_version: 3.6.9
264
+ rubygems_version: 4.0.3
242
265
  specification_version: 4
243
266
  summary: OpenAPI3 parser
244
267
  test_files: []