openapi_parser 0.15.0 → 1.0.0.beta1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +1 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +27 -0
- data/Rakefile +5 -1
- data/Steepfile +11 -0
- data/lib/openapi_parser/concerns/expandable.rb +19 -16
- data/lib/openapi_parser/config.rb +14 -0
- data/lib/openapi_parser/errors.rb +6 -0
- data/lib/openapi_parser/reference_expander.rb +2 -2
- data/lib/openapi_parser/schema_validators/base.rb +3 -8
- data/lib/openapi_parser/version.rb +1 -1
- data/lib/openapi_parser.rb +6 -6
- data/openapi_parser.gemspec +2 -0
- data/sig/openapi_parser/config.rbs +17 -0
- data/sig/openapi_parser/schema_validator.rbs +46 -0
- data/sig/openapi_parser/schema_validators/base.rbs +17 -0
- data/sig/openapi_parser/schema_validators/options.rbs +17 -0
- data/sig/openapi_parser/schemas/base.rbs +17 -0
- data/sig/openapi_parser/version.rbs +3 -0
- data/sig/openapi_parser.rbs +19 -0
- data/sig/types.rbs +8 -0
- data/sig/wip_types.rbs +67 -0
- metadata +31 -7
- data/TAGS +0 -1352
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e383e6ff9f0d2a6ac67fda1ac8663b82c249449a7c1cff616a72fb608344a816
|
4
|
+
data.tar.gz: 53c6a442a5f170f5190197aa17a805a707fd586d7b4d0fc4c259ed8af46dc2bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cd78f54ac0bb0bca68e9538f3f33968b7815b76d88c39908735da2f18936118ecc66ec57a97ac491f2b0fdc7fd4985e312b8b32a4051d22a2242ed8ea55608f
|
7
|
+
data.tar.gz: 22fcb549a4c134350274be73bc59114309d612f096b70dfd5633fe049b9b2111c176809575b2ce89fc30a2db3a8cda633c5ce18b82a58a418cd95d76ce23791a
|
data/.github/workflows/ci.yaml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,33 @@ We support additional type validation.
|
|
62
62
|
|---|---|---|
|
63
63
|
|string|uuid|validate uuid string. But we don't check uuid layout|
|
64
64
|
|
65
|
+
### Reference Validation on Schema Load
|
66
|
+
Invalid references (missing definitions, typos, etc.) can cause validation to fail in runtime,
|
67
|
+
and these errors can be difficult to debug (see: https://github.com/ota42y/openapi_parser/issues/29).
|
68
|
+
|
69
|
+
Pass the `strict_reference_validation: true` option to detect invalid references.
|
70
|
+
An `OpenAPIError::MissingReferenceError` exception will be raised when a reference cannot be resolved.
|
71
|
+
|
72
|
+
If the `expand_reference` configuration is explicitly `false` (default is `true`), then
|
73
|
+
this configuration has no effect.
|
74
|
+
|
75
|
+
DEPRECATION NOTICE: To maintain compatibility with the previous behavior, this version sets `false` as a default.
|
76
|
+
This behavior will be changed to `true` in a later version, so you should explicitly pass `strict_reference_validation: false`
|
77
|
+
if you wish to keep the old behavior (and please let the maintainers know your use-case for this configuration!).
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
yaml_file = YAML.load_file('open_api_3/schema_with_broken_references.yml')
|
81
|
+
options = {
|
82
|
+
coerce_value: true,
|
83
|
+
datetime_coerce_class: DateTime,
|
84
|
+
# This defaults to false (for now) - passing `true` provides load-time validation of refs
|
85
|
+
strict_reference_validation: true
|
86
|
+
}
|
87
|
+
|
88
|
+
# Will raise with OpenAPIParser::MissingReferenceError
|
89
|
+
OpenAPIParser.parse(yaml_file, options)
|
90
|
+
```
|
91
|
+
|
65
92
|
## ToDo
|
66
93
|
- correct schema checker
|
67
94
|
- more detailed validator
|
data/Rakefile
CHANGED
data/Steepfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
target :lib do
|
2
|
+
signature "sig"
|
3
|
+
#check "lib"
|
4
|
+
|
5
|
+
check "lib/openapi_parser.rb"
|
6
|
+
check "lib/openapi_parser/config.rb"
|
7
|
+
check "lib/openapi_parser/schema_validators/options.rb"
|
8
|
+
check "lib/openapi_parser/schema_validators/base.rb"
|
9
|
+
|
10
|
+
library 'uri'
|
11
|
+
end
|
@@ -2,28 +2,28 @@ module OpenAPIParser::Expandable
|
|
2
2
|
# expand refs
|
3
3
|
# @param [OpenAPIParser::Schemas::Base] root
|
4
4
|
# @return nil
|
5
|
-
def expand_reference(root)
|
6
|
-
expand_list_objects(root, self.class._openapi_attr_list_objects.keys)
|
7
|
-
expand_objects(root, self.class._openapi_attr_objects.keys)
|
8
|
-
expand_hash_objects(root, self.class._openapi_attr_hash_objects.keys)
|
9
|
-
expand_hash_objects(root, self.class._openapi_attr_hash_body_objects.keys)
|
5
|
+
def expand_reference(root, validate_references)
|
6
|
+
expand_list_objects(root, self.class._openapi_attr_list_objects.keys, validate_references)
|
7
|
+
expand_objects(root, self.class._openapi_attr_objects.keys, validate_references)
|
8
|
+
expand_hash_objects(root, self.class._openapi_attr_hash_objects.keys, validate_references)
|
9
|
+
expand_hash_objects(root, self.class._openapi_attr_hash_body_objects.keys, validate_references)
|
10
10
|
nil
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def expand_hash_objects(root, attribute_names)
|
15
|
+
def expand_hash_objects(root, attribute_names, validate_references)
|
16
16
|
return unless attribute_names
|
17
17
|
|
18
|
-
attribute_names.each { |name| expand_hash_attribute(root, name) }
|
18
|
+
attribute_names.each { |name| expand_hash_attribute(root, name, validate_references) }
|
19
19
|
end
|
20
20
|
|
21
|
-
def expand_hash_attribute(root, name)
|
21
|
+
def expand_hash_attribute(root, name, validate_references)
|
22
22
|
h = send(name)
|
23
23
|
return if h.nil?
|
24
24
|
|
25
25
|
update_values = h.map do |k, v|
|
26
|
-
new_object = expand_object(root, v)
|
26
|
+
new_object = expand_object(root, v, validate_references)
|
27
27
|
new_object.nil? ? nil : [k, new_object]
|
28
28
|
end
|
29
29
|
|
@@ -33,14 +33,14 @@ module OpenAPIParser::Expandable
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def expand_objects(root, attribute_names)
|
36
|
+
def expand_objects(root, attribute_names, validate_references)
|
37
37
|
return unless attribute_names
|
38
38
|
|
39
39
|
attribute_names.each do |name|
|
40
40
|
v = send(name)
|
41
41
|
next if v.nil?
|
42
42
|
|
43
|
-
new_object = expand_object(root, v)
|
43
|
+
new_object = expand_object(root, v, validate_references)
|
44
44
|
next if new_object.nil?
|
45
45
|
|
46
46
|
_update_child_object(v, new_object)
|
@@ -48,7 +48,7 @@ module OpenAPIParser::Expandable
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def expand_list_objects(root, attribute_names)
|
51
|
+
def expand_list_objects(root, attribute_names, validate_references)
|
52
52
|
return unless attribute_names
|
53
53
|
|
54
54
|
attribute_names.each do |name|
|
@@ -56,7 +56,7 @@ module OpenAPIParser::Expandable
|
|
56
56
|
next if l.nil?
|
57
57
|
|
58
58
|
l.each_with_index do |v, idx|
|
59
|
-
new_object = expand_object(root, v)
|
59
|
+
new_object = expand_object(root, v, validate_references)
|
60
60
|
next if new_object.nil?
|
61
61
|
|
62
62
|
_update_child_object(v, new_object)
|
@@ -65,12 +65,15 @@ module OpenAPIParser::Expandable
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def expand_object(root, object)
|
68
|
+
def expand_object(root, object, validate_references)
|
69
69
|
if object.kind_of?(OpenAPIParser::Schemas::Reference)
|
70
|
-
|
70
|
+
ref_object = referenced_object(root, object)
|
71
|
+
raise OpenAPIParser::MissingReferenceError.new(object.ref) if ref_object.nil? && validate_references
|
72
|
+
|
73
|
+
return ref_object
|
71
74
|
end
|
72
75
|
|
73
|
-
object.expand_reference(root) if object.kind_of?(OpenAPIParser::Expandable)
|
76
|
+
object.expand_reference(root, validate_references) if object.kind_of?(OpenAPIParser::Expandable)
|
74
77
|
nil
|
75
78
|
end
|
76
79
|
|
@@ -1,5 +1,13 @@
|
|
1
1
|
class OpenAPIParser::Config
|
2
2
|
def initialize(config)
|
3
|
+
# TODO: This deprecation warning can be removed after we set the default to `true`
|
4
|
+
# in a later (major?) version update.
|
5
|
+
unless config.key?(:strict_reference_validation)
|
6
|
+
msg = "[DEPRECATION] strict_reference_validation config is not set. It defaults to `false` now, " +
|
7
|
+
"but will be `true` in a future version. Please explicitly set to `false` " +
|
8
|
+
"if you want to skip reference validation on schema load."
|
9
|
+
warn(msg)
|
10
|
+
end
|
3
11
|
@config = config
|
4
12
|
end
|
5
13
|
|
@@ -16,9 +24,15 @@ class OpenAPIParser::Config
|
|
16
24
|
end
|
17
25
|
|
18
26
|
def strict_response_validation
|
27
|
+
# TODO: in a major version update, change this to default to `true`.
|
28
|
+
# https://github.com/ota42y/openapi_parser/pull/123/files#r767142217
|
19
29
|
@config.fetch(:strict_response_validation, false)
|
20
30
|
end
|
21
31
|
|
32
|
+
def strict_reference_validation
|
33
|
+
@config.fetch(:strict_reference_validation, false)
|
34
|
+
end
|
35
|
+
|
22
36
|
def validate_header
|
23
37
|
@config.fetch(:validate_header, true)
|
24
38
|
end
|
@@ -5,6 +5,12 @@ module OpenAPIParser
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
+
class MissingReferenceError < OpenAPIError
|
9
|
+
def message
|
10
|
+
"'#{@reference}' was referenced but could not be found"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
class ValidateError < OpenAPIError
|
9
15
|
def initialize(data, type, reference)
|
10
16
|
super(reference)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class OpenAPIParser::ReferenceExpander
|
2
2
|
class << self
|
3
3
|
# @param [OpenAPIParser::Schemas::OpenAPI] openapi
|
4
|
-
def expand(openapi)
|
5
|
-
openapi.expand_reference(openapi)
|
4
|
+
def expand(openapi, validate_references)
|
5
|
+
openapi.expand_reference(openapi, validate_references)
|
6
6
|
openapi.purge_object_cache
|
7
7
|
end
|
8
8
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class OpenAPIParser::SchemaValidator
|
2
2
|
class Base
|
3
|
-
# @param [OpenAPIParser::SchemaValidator::Validatable] validatable
|
4
3
|
def initialize(validatable, coerce_value)
|
5
4
|
@validatable = validatable
|
6
5
|
@coerce_value = coerce_value
|
@@ -8,21 +7,17 @@ class OpenAPIParser::SchemaValidator
|
|
8
7
|
|
9
8
|
attr_reader :validatable
|
10
9
|
|
11
|
-
# @!attribute [r] validatable
|
12
|
-
# @return [OpenAPIParser::SchemaValidator::Validatable]
|
13
|
-
|
14
10
|
# need override
|
15
|
-
# @param [Array] _value
|
16
|
-
# @param [OpenAPIParser::Schemas::Schema] _schema
|
17
11
|
def coerce_and_validate(_value, _schema, **_keyword_args)
|
18
12
|
raise 'need implement'
|
19
13
|
end
|
20
14
|
|
21
15
|
def validate_discriminator_schema(discriminator, value, parent_discriminator_schemas: [])
|
22
|
-
|
16
|
+
property_name = discriminator.property_name
|
17
|
+
unless (property_name && value.key?(property_name))
|
23
18
|
return [nil, OpenAPIParser::NotExistDiscriminatorPropertyName.new(discriminator.property_name, value, discriminator.object_reference)]
|
24
19
|
end
|
25
|
-
mapping_key = value[
|
20
|
+
mapping_key = value[property_name]
|
26
21
|
|
27
22
|
# it's allowed to have discriminator without mapping, then we need to lookup discriminator.property_name
|
28
23
|
# but the format is not the full path, just model name in the components
|
data/lib/openapi_parser.rb
CHANGED
@@ -44,9 +44,9 @@ module OpenAPIParser
|
|
44
44
|
# Open-uri doesn't open file scheme uri, so we try to open file path directly
|
45
45
|
# File scheme uri which points to a remote file is not supported.
|
46
46
|
content = if uri.scheme == 'file'
|
47
|
-
open(uri.path
|
48
|
-
|
49
|
-
uri.open(
|
47
|
+
open(uri.path)&.read
|
48
|
+
elsif uri.is_a?(OpenURI::OpenRead)
|
49
|
+
uri.open()&.read
|
50
50
|
end
|
51
51
|
|
52
52
|
extension = Pathname.new(uri.path).extname
|
@@ -61,8 +61,8 @@ module OpenAPIParser
|
|
61
61
|
URI.join("file:///", path.to_s)
|
62
62
|
end
|
63
63
|
|
64
|
-
def parse_file(content,
|
65
|
-
case
|
64
|
+
def parse_file(content, ext)
|
65
|
+
case ext.downcase
|
66
66
|
when '.yaml', '.yml'
|
67
67
|
parse_yaml(content)
|
68
68
|
when '.json'
|
@@ -91,7 +91,7 @@ module OpenAPIParser
|
|
91
91
|
def load_hash(hash, config:, uri:, schema_registry:)
|
92
92
|
root = Schemas::OpenAPI.new(hash, config, uri: uri, schema_registry: schema_registry)
|
93
93
|
|
94
|
-
OpenAPIParser::ReferenceExpander.expand(root) if config.expand_reference
|
94
|
+
OpenAPIParser::ReferenceExpander.expand(root, config.strict_reference_validation) if config.expand_reference
|
95
95
|
|
96
96
|
# TODO: use callbacks
|
97
97
|
root.paths&.path&.values&.each do | path_item |
|
data/openapi_parser.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'parser for OpenAPI 3.0 or later'
|
13
13
|
spec.homepage = 'https://github.com/ota42y/openapi_parser'
|
14
14
|
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
16
|
|
16
17
|
# Specify which files should be added to the gem when it is released.
|
17
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -30,4 +31,5 @@ Gem::Specification.new do |spec|
|
|
30
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
32
|
spec.add_development_dependency 'rspec-parameterized'
|
32
33
|
spec.add_development_dependency 'simplecov'
|
34
|
+
spec.add_development_dependency "steep"
|
33
35
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Classes
|
2
|
+
module OpenAPIParser
|
3
|
+
class Config
|
4
|
+
@config: untyped
|
5
|
+
alias request_body_options request_validator_options
|
6
|
+
alias path_params_options request_validator_options
|
7
|
+
|
8
|
+
def initialize: (untyped config) -> untyped
|
9
|
+
def datetime_coerce_class: -> (singleton(Object) | nil)
|
10
|
+
def coerce_value: -> bool
|
11
|
+
def expand_reference: -> bool
|
12
|
+
def strict_response_validation: -> bool
|
13
|
+
def validate_header: -> bool
|
14
|
+
def request_validator_options: -> OpenAPIParser::SchemaValidator::Options
|
15
|
+
def response_validate_options: -> OpenAPIParser::SchemaValidator::ResponseValidateOptions
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Classes
|
2
|
+
module OpenAPIParser
|
3
|
+
class SchemaValidator
|
4
|
+
include Validatable
|
5
|
+
@value: Hash[bot, bot]
|
6
|
+
@schema: OpenAPIParser::Schemas::Schema
|
7
|
+
@coerce_value: bool | nil
|
8
|
+
@datetime_coerce_class: singleton(Object) | nil
|
9
|
+
@string_validator: OpenAPIParser::SchemaValidator::StringValidator | nil
|
10
|
+
@integer_validator: OpenAPIParser::SchemaValidator::IntegerValidator | nil
|
11
|
+
@float_validator: OpenAPIParser::SchemaValidator::FloatValidator | nil
|
12
|
+
@boolean_validator: OpenAPIParser::SchemaValidator::BooleanValidator | nil
|
13
|
+
@object_validator: OpenAPIParser::SchemaValidator::ObjectValidator | nil
|
14
|
+
@array_validator: OpenAPIParser::SchemaValidator::ArrayValidator | nil
|
15
|
+
@any_of_validator: OpenAPIParser::SchemaValidator::AnyOfValidator | nil
|
16
|
+
@all_of_validator: OpenAPIParser::SchemaValidator::AllOfValidator | nil
|
17
|
+
@one_of_validator: OpenAPIParser::SchemaValidator::OneOfValidator | nil
|
18
|
+
@nil_validator: OpenAPIParser::SchemaValidator::NilValidator | nil
|
19
|
+
@unspecified_type_validator: OpenAPIParser::SchemaValidator::UnspecifiedTypeValidator | nil
|
20
|
+
|
21
|
+
def self.validate: (Hash[bot, bot] value, OpenAPIParser::Schemas::Schema schema, OpenAPIParser::SchemaValidator::Options options) -> Object
|
22
|
+
def initialize: (Hash[bot, bot] value, OpenAPIParser::Schemas::Schema schema, OpenAPIParser::SchemaValidator::Options options) -> untyped
|
23
|
+
def validate_data: -> Object
|
24
|
+
def validate_schema: (Object value, OpenAPIParser::Schemas::Schema schema, **bot) -> [Object, OpenAPIParser::validate_error]
|
25
|
+
def validate_integer: (Object value, OpenAPIParser::Schemas::Schema schema) -> [Object, OpenAPIParser::validate_error]
|
26
|
+
|
27
|
+
private
|
28
|
+
def validator: (Object value, OpenAPIParser::Schemas::Schema schema) -> [OpenAPIParser::SchemaValidator::Base, OpenAPIParser::validate_error]
|
29
|
+
def string_validator: -> OpenAPIParser::SchemaValidator::StringValidator
|
30
|
+
def integer_validator: -> OpenAPIParser::SchemaValidator::IntegerValidator
|
31
|
+
def float_validator: -> OpenAPIParser::SchemaValidator::FloatValidator
|
32
|
+
def boolean_validator: -> OpenAPIParser::SchemaValidator::BooleanValidator
|
33
|
+
def object_validator: -> OpenAPIParser::SchemaValidator::ObjectValidator
|
34
|
+
def array_validator: -> OpenAPIParser::SchemaValidator::ArrayValidator
|
35
|
+
def any_of_validator: -> OpenAPIParser::SchemaValidator::AnyOfValidator
|
36
|
+
def all_of_validator: -> OpenAPIParser::SchemaValidator::AllOfValidator
|
37
|
+
def one_of_validator: -> OpenAPIParser::SchemaValidator::OneOfValidator
|
38
|
+
def nil_validator: -> OpenAPIParser::SchemaValidator::NilValidator
|
39
|
+
def unspecified_type_validator: -> OpenAPIParser::SchemaValidator::UnspecifiedTypeValidator
|
40
|
+
|
41
|
+
module Validatable
|
42
|
+
def validate_schema: (Object value, OpenAPIParser::Schemas::Schema schema, **untyped) -> [Object, OpenAPIParser::validate_error]
|
43
|
+
def validate_integer: (Object _value, OpenAPIParser::Schemas::Schema _schema) -> [Object, OpenAPIParser::validate_error]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Classes
|
2
|
+
module OpenAPIParser
|
3
|
+
class SchemaValidator
|
4
|
+
class Base
|
5
|
+
@coerce_value: bool | nil
|
6
|
+
|
7
|
+
def initialize: (OpenAPIParser::SchemaValidator::Validatable validatable, (bool | nil) coerce_value) -> untyped
|
8
|
+
attr_reader validatable: OpenAPIParser::SchemaValidator::Validatable
|
9
|
+
def coerce_and_validate: (Object _value, OpenAPIParser::Schemas::Schema _schema, **untyped) -> bot
|
10
|
+
def validate_discriminator_schema: (
|
11
|
+
OpenAPIParser::Schemas::Discriminator discriminator,
|
12
|
+
Hash[String, bot] value,
|
13
|
+
?parent_discriminator_schemas: Array[OpenAPIParser::Schemas::Schema]
|
14
|
+
) -> [Object | nil, OpenAPIParser::validate_error]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Classes
|
2
|
+
module OpenAPIParser
|
3
|
+
class SchemaValidator
|
4
|
+
class Options
|
5
|
+
attr_reader coerce_value: bool | nil
|
6
|
+
attr_reader datetime_coerce_class: singleton(Object) | nil
|
7
|
+
attr_reader validate_header: bool
|
8
|
+
def initialize: (?coerce_value: bool | nil, ?datetime_coerce_class: singleton(Object) | nil, ?validate_header: bool) -> untyped
|
9
|
+
end
|
10
|
+
|
11
|
+
class ResponseValidateOptions
|
12
|
+
attr_reader strict: bool
|
13
|
+
attr_reader validate_header: bool
|
14
|
+
def initialize: (?strict: bool, ?validate_header: bool) -> untyped
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Classes
|
2
|
+
module OpenAPIParser
|
3
|
+
module Schemas
|
4
|
+
class Base
|
5
|
+
include OpenAPIParser::Expandable
|
6
|
+
include OpenAPIParser::Findable
|
7
|
+
|
8
|
+
attr_reader parent: OpenAPIParser::Schemas::Base | nil
|
9
|
+
attr_reader raw_schema: Hash[String, bot]
|
10
|
+
attr_reader object_reference: String
|
11
|
+
attr_reader root: OpenAPIParser::Schemas::OpenAPI
|
12
|
+
def initialize: (String object_reference, OpenAPIParser::Schemas::Base | nil parent, OpenAPIParser::Schemas::OpenAPI root, Hash[String, bot] raw_schema) -> nil
|
13
|
+
def after_init: -> nil
|
14
|
+
def inspect: -> String
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OpenAPIParser
|
2
|
+
def self.parse: (Hash[bot, bot] schema, ?Hash[bot, bot] config) -> OpenAPIParser::Schemas::OpenAPI
|
3
|
+
def self.parse_with_filepath: (Hash[bot, bot] schema, String filepath, ?Hash[bot, bot] config) -> OpenAPIParser::Schemas::OpenAPI
|
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
|
6
|
+
def self.file_uri: (String filepath) -> URI::Generic
|
7
|
+
def self.parse_file: (String? content, String ext) -> Hash[bot, bot]
|
8
|
+
def self.parse_yaml: (String? content) -> Hash[bot, bot]
|
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
|
11
|
+
end
|
12
|
+
|
13
|
+
module OpenAPIParser
|
14
|
+
module Schemas
|
15
|
+
class OpenAPI
|
16
|
+
def initialize: (Hash[bot, bot] hash, untyped config, uri: OpenAPIParser::readable_uri?, schema_registry: Hash[bot, bot]) -> OpenAPIParser::Schemas::OpenAPI
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/sig/types.rbs
ADDED
data/sig/wip_types.rbs
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module OpenAPIParser
|
2
|
+
type readable_uri = URI::Generic | OpenURI::OpenRead
|
3
|
+
type validate_error = nil
|
4
|
+
end
|
5
|
+
|
6
|
+
module OpenAPIParser
|
7
|
+
module Schemas
|
8
|
+
class Schema
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class OpenAPIParser::SchemaValidator::Base
|
14
|
+
end
|
15
|
+
|
16
|
+
class OpenAPIParser::SchemaValidator::StringValidator
|
17
|
+
end
|
18
|
+
|
19
|
+
class OpenAPIParser::SchemaValidator::IntegerValidator
|
20
|
+
end
|
21
|
+
|
22
|
+
class OpenAPIParser::SchemaValidator::FloatValidator
|
23
|
+
end
|
24
|
+
|
25
|
+
class OpenAPIParser::SchemaValidator::BooleanValidator
|
26
|
+
end
|
27
|
+
|
28
|
+
class OpenAPIParser::SchemaValidator::ObjectValidator
|
29
|
+
end
|
30
|
+
|
31
|
+
class OpenAPIParser::SchemaValidator::ArrayValidator
|
32
|
+
end
|
33
|
+
|
34
|
+
class OpenAPIParser::SchemaValidator::AnyOfValidator
|
35
|
+
end
|
36
|
+
|
37
|
+
class OpenAPIParser::SchemaValidator::AllOfValidator
|
38
|
+
end
|
39
|
+
|
40
|
+
class OpenAPIParser::SchemaValidator::OneOfValidator
|
41
|
+
end
|
42
|
+
|
43
|
+
class OpenAPIParser::SchemaValidator::NilValidator
|
44
|
+
end
|
45
|
+
|
46
|
+
class OpenAPIParser::SchemaValidator::UnspecifiedTypeValidator
|
47
|
+
end
|
48
|
+
|
49
|
+
class OpenAPIParser::Schemas::OpenAPI < OpenAPIParser::Schemas::Base
|
50
|
+
attr_reader paths: untyped
|
51
|
+
end
|
52
|
+
|
53
|
+
module OpenAPIParser::Expandable
|
54
|
+
def expand_reference: (OpenAPIParser::Schemas::OpenAPI root) -> nil
|
55
|
+
end
|
56
|
+
|
57
|
+
module OpenAPIParser::Findable
|
58
|
+
def find_object: (String reference) -> ::OpenAPIParser::Schemas::Schema
|
59
|
+
end
|
60
|
+
|
61
|
+
class OpenAPIParser::Schemas::Discriminator < OpenAPIParser::Schemas::Base
|
62
|
+
attr_reader property_name: (String | nil)
|
63
|
+
attr_reader mapping: Hash[String, String]
|
64
|
+
end
|
65
|
+
|
66
|
+
class OpenAPIParser::OpenAPIError
|
67
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: steep
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: parser for OpenAPI 3.0 or later
|
126
140
|
email:
|
127
141
|
- ota42y@gmail.com
|
@@ -134,13 +148,14 @@ files:
|
|
134
148
|
- ".rspec"
|
135
149
|
- ".rubocop.yml"
|
136
150
|
- ".rubocop_ignore.yml"
|
151
|
+
- ".ruby-version"
|
137
152
|
- CHANGELOG.md
|
138
153
|
- CODE_OF_CONDUCT.md
|
139
154
|
- Gemfile
|
140
155
|
- LICENSE.txt
|
141
156
|
- README.md
|
142
157
|
- Rakefile
|
143
|
-
-
|
158
|
+
- Steepfile
|
144
159
|
- bin/console
|
145
160
|
- bin/setup
|
146
161
|
- lib/openapi_parser.rb
|
@@ -205,6 +220,15 @@ files:
|
|
205
220
|
- lib/openapi_parser/schemas/schema.rb
|
206
221
|
- lib/openapi_parser/version.rb
|
207
222
|
- openapi_parser.gemspec
|
223
|
+
- sig/openapi_parser.rbs
|
224
|
+
- sig/openapi_parser/config.rbs
|
225
|
+
- sig/openapi_parser/schema_validator.rbs
|
226
|
+
- sig/openapi_parser/schema_validators/base.rbs
|
227
|
+
- sig/openapi_parser/schema_validators/options.rbs
|
228
|
+
- sig/openapi_parser/schemas/base.rbs
|
229
|
+
- sig/openapi_parser/version.rbs
|
230
|
+
- sig/types.rbs
|
231
|
+
- sig/wip_types.rbs
|
208
232
|
homepage: https://github.com/ota42y/openapi_parser
|
209
233
|
licenses:
|
210
234
|
- MIT
|
@@ -217,14 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
241
|
requirements:
|
218
242
|
- - ">="
|
219
243
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
244
|
+
version: 2.6.0
|
221
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
246
|
requirements:
|
223
|
-
- - "
|
247
|
+
- - ">"
|
224
248
|
- !ruby/object:Gem::Version
|
225
|
-
version:
|
249
|
+
version: 1.3.1
|
226
250
|
requirements: []
|
227
|
-
rubygems_version: 3.2.
|
251
|
+
rubygems_version: 3.2.32
|
228
252
|
signing_key:
|
229
253
|
specification_version: 4
|
230
254
|
summary: OpenAPI3 parser
|