grape 1.8.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -1
- data/README.md +377 -334
- data/UPGRADING.md +231 -6
- data/grape.gemspec +6 -10
- data/lib/grape/api/instance.rb +13 -10
- data/lib/grape/api.rb +17 -8
- data/lib/grape/content_types.rb +0 -2
- data/lib/grape/cookies.rb +2 -1
- data/lib/grape/dry_types.rb +0 -2
- data/lib/grape/dsl/desc.rb +23 -21
- data/lib/grape/dsl/headers.rb +1 -1
- data/lib/grape/dsl/inside_route.rb +47 -22
- data/lib/grape/dsl/parameters.rb +4 -3
- data/lib/grape/dsl/routing.rb +20 -4
- data/lib/grape/dsl/validations.rb +13 -0
- data/lib/grape/endpoint.rb +15 -10
- data/lib/grape/{util/env.rb → env.rb} +0 -5
- data/lib/grape/error_formatter/txt.rb +11 -10
- data/lib/grape/exceptions/base.rb +3 -3
- data/lib/grape/exceptions/missing_group_type.rb +1 -1
- data/lib/grape/exceptions/unsupported_group_type.rb +1 -1
- data/lib/grape/exceptions/validation.rb +0 -2
- data/lib/grape/exceptions/validation_array_errors.rb +1 -0
- data/lib/grape/exceptions/validation_errors.rb +1 -3
- data/lib/grape/extensions/hash.rb +5 -1
- data/lib/grape/http/headers.rb +18 -24
- data/lib/grape/{util/json.rb → json.rb} +1 -3
- data/lib/grape/locale/en.yml +3 -0
- data/lib/grape/middleware/auth/base.rb +0 -2
- data/lib/grape/middleware/auth/dsl.rb +0 -2
- data/lib/grape/middleware/auth/strategies.rb +1 -2
- data/lib/grape/middleware/base.rb +0 -2
- data/lib/grape/middleware/error.rb +55 -50
- data/lib/grape/middleware/formatter.rb +21 -18
- data/lib/grape/middleware/globals.rb +1 -3
- data/lib/grape/middleware/stack.rb +2 -3
- data/lib/grape/middleware/versioner/accept_version_header.rb +0 -2
- data/lib/grape/middleware/versioner/header.rb +17 -163
- data/lib/grape/middleware/versioner/param.rb +2 -4
- data/lib/grape/middleware/versioner/path.rb +1 -3
- data/lib/grape/namespace.rb +3 -4
- data/lib/grape/path.rb +24 -29
- data/lib/grape/railtie.rb +9 -0
- data/lib/grape/request.rb +3 -5
- data/lib/grape/router/base_route.rb +39 -0
- data/lib/grape/router/greedy_route.rb +20 -0
- data/lib/grape/router/pattern.rb +39 -30
- data/lib/grape/router/route.rb +22 -59
- data/lib/grape/router.rb +30 -36
- data/lib/grape/util/accept/header.rb +19 -0
- data/lib/grape/util/accept_header_handler.rb +105 -0
- data/lib/grape/util/base_inheritable.rb +4 -4
- data/lib/grape/util/cache.rb +0 -3
- data/lib/grape/util/endpoint_configuration.rb +1 -1
- data/lib/grape/util/header.rb +13 -0
- data/lib/grape/util/inheritable_values.rb +0 -2
- data/lib/grape/util/lazy/block.rb +29 -0
- data/lib/grape/util/lazy/object.rb +45 -0
- data/lib/grape/util/lazy/value.rb +38 -0
- data/lib/grape/util/lazy/value_array.rb +21 -0
- data/lib/grape/util/lazy/value_enumerable.rb +34 -0
- data/lib/grape/util/lazy/value_hash.rb +21 -0
- data/lib/grape/util/media_type.rb +70 -0
- data/lib/grape/util/reverse_stackable_values.rb +1 -6
- data/lib/grape/util/stackable_values.rb +1 -6
- data/lib/grape/util/strict_hash_configuration.rb +3 -3
- data/lib/grape/validations/attributes_doc.rb +38 -36
- data/lib/grape/validations/contract_scope.rb +71 -0
- data/lib/grape/validations/params_scope.rb +10 -9
- data/lib/grape/validations/types/array_coercer.rb +0 -2
- data/lib/grape/validations/types/build_coercer.rb +69 -71
- data/lib/grape/validations/types/dry_type_coercer.rb +1 -11
- data/lib/grape/validations/types/json.rb +0 -2
- data/lib/grape/validations/types/primitive_coercer.rb +0 -2
- data/lib/grape/validations/types/set_coercer.rb +0 -3
- data/lib/grape/validations/types.rb +0 -3
- data/lib/grape/validations/validators/base.rb +2 -1
- data/lib/grape/validations/validators/default_validator.rb +5 -1
- data/lib/grape/validations/validators/length_validator.rb +42 -0
- data/lib/grape/validations/validators/values_validator.rb +8 -3
- data/lib/grape/validations.rb +3 -7
- data/lib/grape/version.rb +1 -1
- data/lib/grape/{util/xml.rb → xml.rb} +1 -1
- data/lib/grape.rb +38 -269
- metadata +33 -274
- data/lib/grape/eager_load.rb +0 -20
- data/lib/grape/middleware/versioner/parse_media_type_patch.rb +0 -24
- data/lib/grape/router/attribute_translator.rb +0 -63
- data/lib/grape/util/lazy_block.rb +0 -27
- data/lib/grape/util/lazy_object.rb +0 -43
- data/lib/grape/util/lazy_value.rb +0 -91
- data/spec/grape/api/custom_validations_spec.rb +0 -213
- data/spec/grape/api/deeply_included_options_spec.rb +0 -56
- data/spec/grape/api/defines_boolean_in_params_spec.rb +0 -38
- data/spec/grape/api/documentation_spec.rb +0 -59
- data/spec/grape/api/inherited_helpers_spec.rb +0 -114
- data/spec/grape/api/instance_spec.rb +0 -103
- data/spec/grape/api/invalid_format_spec.rb +0 -45
- data/spec/grape/api/namespace_parameters_in_route_spec.rb +0 -38
- data/spec/grape/api/nested_helpers_spec.rb +0 -50
- data/spec/grape/api/optional_parameters_in_route_spec.rb +0 -43
- data/spec/grape/api/parameters_modification_spec.rb +0 -41
- data/spec/grape/api/patch_method_helpers_spec.rb +0 -79
- data/spec/grape/api/recognize_path_spec.rb +0 -21
- data/spec/grape/api/required_parameters_in_route_spec.rb +0 -37
- data/spec/grape/api/required_parameters_with_invalid_method_spec.rb +0 -26
- data/spec/grape/api/routes_with_requirements_spec.rb +0 -59
- data/spec/grape/api/shared_helpers_exactly_one_of_spec.rb +0 -41
- data/spec/grape/api/shared_helpers_spec.rb +0 -36
- data/spec/grape/api_remount_spec.rb +0 -509
- data/spec/grape/api_spec.rb +0 -4356
- data/spec/grape/dsl/callbacks_spec.rb +0 -45
- data/spec/grape/dsl/desc_spec.rb +0 -98
- data/spec/grape/dsl/headers_spec.rb +0 -62
- data/spec/grape/dsl/helpers_spec.rb +0 -100
- data/spec/grape/dsl/inside_route_spec.rb +0 -531
- data/spec/grape/dsl/logger_spec.rb +0 -24
- data/spec/grape/dsl/middleware_spec.rb +0 -60
- data/spec/grape/dsl/parameters_spec.rb +0 -180
- data/spec/grape/dsl/request_response_spec.rb +0 -225
- data/spec/grape/dsl/routing_spec.rb +0 -275
- data/spec/grape/dsl/settings_spec.rb +0 -261
- data/spec/grape/dsl/validations_spec.rb +0 -55
- data/spec/grape/endpoint/declared_spec.rb +0 -846
- data/spec/grape/endpoint_spec.rb +0 -1085
- data/spec/grape/entity_spec.rb +0 -336
- data/spec/grape/exceptions/base_spec.rb +0 -81
- data/spec/grape/exceptions/body_parse_errors_spec.rb +0 -185
- data/spec/grape/exceptions/invalid_accept_header_spec.rb +0 -358
- data/spec/grape/exceptions/invalid_formatter_spec.rb +0 -15
- data/spec/grape/exceptions/invalid_response_spec.rb +0 -11
- data/spec/grape/exceptions/invalid_versioner_option_spec.rb +0 -15
- data/spec/grape/exceptions/missing_group_type_spec.rb +0 -17
- data/spec/grape/exceptions/missing_mime_type_spec.rb +0 -17
- data/spec/grape/exceptions/missing_option_spec.rb +0 -15
- data/spec/grape/exceptions/unknown_options_spec.rb +0 -15
- data/spec/grape/exceptions/unknown_validator_spec.rb +0 -15
- data/spec/grape/exceptions/unsupported_group_type_spec.rb +0 -19
- data/spec/grape/exceptions/validation_errors_spec.rb +0 -92
- data/spec/grape/exceptions/validation_spec.rb +0 -19
- data/spec/grape/extensions/param_builders/hash_spec.rb +0 -83
- data/spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb +0 -105
- data/spec/grape/extensions/param_builders/hashie/mash_spec.rb +0 -79
- data/spec/grape/grape_spec.rb +0 -9
- data/spec/grape/integration/global_namespace_function_spec.rb +0 -29
- data/spec/grape/integration/rack_sendfile_spec.rb +0 -48
- data/spec/grape/integration/rack_spec.rb +0 -51
- data/spec/grape/loading_spec.rb +0 -44
- data/spec/grape/middleware/auth/base_spec.rb +0 -31
- data/spec/grape/middleware/auth/dsl_spec.rb +0 -60
- data/spec/grape/middleware/auth/strategies_spec.rb +0 -120
- data/spec/grape/middleware/base_spec.rb +0 -221
- data/spec/grape/middleware/error_spec.rb +0 -85
- data/spec/grape/middleware/exception_spec.rb +0 -294
- data/spec/grape/middleware/formatter_spec.rb +0 -461
- data/spec/grape/middleware/globals_spec.rb +0 -30
- data/spec/grape/middleware/stack_spec.rb +0 -155
- data/spec/grape/middleware/versioner/accept_version_header_spec.rb +0 -122
- data/spec/grape/middleware/versioner/header_spec.rb +0 -345
- data/spec/grape/middleware/versioner/param_spec.rb +0 -171
- data/spec/grape/middleware/versioner/path_spec.rb +0 -62
- data/spec/grape/middleware/versioner_spec.rb +0 -21
- data/spec/grape/named_api_spec.rb +0 -19
- data/spec/grape/parser_spec.rb +0 -86
- data/spec/grape/path_spec.rb +0 -252
- data/spec/grape/presenters/presenter_spec.rb +0 -71
- data/spec/grape/request_spec.rb +0 -126
- data/spec/grape/util/inheritable_setting_spec.rb +0 -242
- data/spec/grape/util/inheritable_values_spec.rb +0 -79
- data/spec/grape/util/reverse_stackable_values_spec.rb +0 -134
- data/spec/grape/util/stackable_values_spec.rb +0 -128
- data/spec/grape/util/strict_hash_configuration_spec.rb +0 -38
- data/spec/grape/validations/attributes_doc_spec.rb +0 -153
- data/spec/grape/validations/instance_behaivour_spec.rb +0 -43
- data/spec/grape/validations/multiple_attributes_iterator_spec.rb +0 -38
- data/spec/grape/validations/params_scope_spec.rb +0 -1420
- data/spec/grape/validations/single_attribute_iterator_spec.rb +0 -56
- data/spec/grape/validations/types/array_coercer_spec.rb +0 -33
- data/spec/grape/validations/types/primitive_coercer_spec.rb +0 -150
- data/spec/grape/validations/types/set_coercer_spec.rb +0 -32
- data/spec/grape/validations/types_spec.rb +0 -111
- data/spec/grape/validations/validators/all_or_none_spec.rb +0 -162
- data/spec/grape/validations/validators/allow_blank_spec.rb +0 -575
- data/spec/grape/validations/validators/at_least_one_of_spec.rb +0 -205
- data/spec/grape/validations/validators/base_spec.rb +0 -38
- data/spec/grape/validations/validators/coerce_spec.rb +0 -1261
- data/spec/grape/validations/validators/default_spec.rb +0 -463
- data/spec/grape/validations/validators/exactly_one_of_spec.rb +0 -233
- data/spec/grape/validations/validators/except_values_spec.rb +0 -192
- data/spec/grape/validations/validators/mutual_exclusion_spec.rb +0 -214
- data/spec/grape/validations/validators/presence_spec.rb +0 -315
- data/spec/grape/validations/validators/regexp_spec.rb +0 -161
- data/spec/grape/validations/validators/same_as_spec.rb +0 -57
- data/spec/grape/validations/validators/values_spec.rb +0 -733
- data/spec/grape/validations/validators/zh-CN.yml +0 -10
- data/spec/grape/validations_spec.rb +0 -2030
- data/spec/integration/eager_load/eager_load_spec.rb +0 -15
- data/spec/integration/multi_json/json_spec.rb +0 -7
- data/spec/integration/multi_xml/xml_spec.rb +0 -7
- data/spec/shared/deprecated_class_examples.rb +0 -16
- data/spec/shared/versioning_examples.rb +0 -215
- data/spec/spec_helper.rb +0 -52
- data/spec/support/basic_auth_encode_helpers.rb +0 -11
- data/spec/support/chunks.rb +0 -14
- data/spec/support/content_type_helpers.rb +0 -15
- data/spec/support/endpoint_faker.rb +0 -25
- data/spec/support/file_streamer.rb +0 -13
- data/spec/support/integer_helpers.rb +0 -13
- data/spec/support/versioned_helpers.rb +0 -55
@@ -59,6 +59,7 @@ module Grape
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.inherited(klass)
|
62
|
+
super
|
62
63
|
return if klass.name.blank?
|
63
64
|
|
64
65
|
short_validator_name = klass.name.demodulize.underscore.delete_suffix('_validator')
|
@@ -85,7 +86,7 @@ end
|
|
85
86
|
|
86
87
|
Grape::Validations::Base = Class.new(Grape::Validations::Validators::Base) do
|
87
88
|
def self.inherited(*)
|
88
|
-
|
89
|
+
Grape.deprecator.warn 'Grape::Validations::Base is deprecated! Use Grape::Validations::Validators::Base instead.'
|
89
90
|
super
|
90
91
|
end
|
91
92
|
end
|
@@ -11,7 +11,11 @@ module Grape
|
|
11
11
|
|
12
12
|
def validate_param!(attr_name, params)
|
13
13
|
params[attr_name] = if @default.is_a? Proc
|
14
|
-
@default.
|
14
|
+
if @default.parameters.empty?
|
15
|
+
@default.call
|
16
|
+
else
|
17
|
+
@default.call(params)
|
18
|
+
end
|
15
19
|
elsif @default.frozen? || !@default.duplicable?
|
16
20
|
@default
|
17
21
|
else
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Grape
|
4
|
+
module Validations
|
5
|
+
module Validators
|
6
|
+
class LengthValidator < Base
|
7
|
+
def initialize(attrs, options, required, scope, **opts)
|
8
|
+
@min = options[:min]
|
9
|
+
@max = options[:max]
|
10
|
+
|
11
|
+
super
|
12
|
+
|
13
|
+
raise ArgumentError, 'min must be an integer greater than or equal to zero' if !@min.nil? && (!@min.is_a?(Integer) || @min.negative?)
|
14
|
+
raise ArgumentError, 'max must be an integer greater than or equal to zero' if !@max.nil? && (!@max.is_a?(Integer) || @max.negative?)
|
15
|
+
raise ArgumentError, "min #{@min} cannot be greater than max #{@max}" if !@min.nil? && !@max.nil? && @min > @max
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_param!(attr_name, params)
|
19
|
+
param = params[attr_name]
|
20
|
+
|
21
|
+
raise ArgumentError, "parameter #{param} does not support #length" unless param.respond_to?(:length)
|
22
|
+
|
23
|
+
return unless (!@min.nil? && param.length < @min) || (!@max.nil? && param.length > @max)
|
24
|
+
|
25
|
+
raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)], message: build_message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_message
|
29
|
+
if options_key?(:message)
|
30
|
+
@option[:message]
|
31
|
+
elsif @min && @max
|
32
|
+
format I18n.t(:length, scope: 'grape.errors.messages'), min: @min, max: @max
|
33
|
+
elsif @min
|
34
|
+
format I18n.t(:length_min, scope: 'grape.errors.messages'), min: @min
|
35
|
+
else
|
36
|
+
format I18n.t(:length_max, scope: 'grape.errors.messages'), max: @max
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -10,11 +10,11 @@ module Grape
|
|
10
10
|
@values = options[:value]
|
11
11
|
@proc = options[:proc]
|
12
12
|
|
13
|
-
|
13
|
+
Grape.deprecator.warn('The values validator except option is deprecated. Use the except validator instead.') if @excepts
|
14
14
|
|
15
15
|
raise ArgumentError, 'proc must be a Proc' if @proc && !@proc.is_a?(Proc)
|
16
16
|
|
17
|
-
|
17
|
+
Grape.deprecator.warn('The values validator proc option is deprecated. The lambda expression can now be assigned directly to values.') if @proc
|
18
18
|
else
|
19
19
|
@excepts = nil
|
20
20
|
@values = nil
|
@@ -85,7 +85,12 @@ module Grape
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def required_for_root_scope?
|
88
|
-
|
88
|
+
return false unless @required
|
89
|
+
|
90
|
+
scope = @scope
|
91
|
+
scope = scope.parent while scope.lateral?
|
92
|
+
|
93
|
+
scope.root?
|
89
94
|
end
|
90
95
|
|
91
96
|
def validation_exception(attr_name, message)
|
data/lib/grape/validations.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Grape
|
4
|
-
# Registry to store and locate known Validators.
|
5
4
|
module Validations
|
6
5
|
module_function
|
7
6
|
|
@@ -12,7 +11,7 @@ module Grape
|
|
12
11
|
# Register a new validator, so it can be used to validate parameters.
|
13
12
|
# @param short_name [String] all lower-case, no spaces
|
14
13
|
# @param klass [Class] the validator class. Should inherit from
|
15
|
-
# Validations::Base.
|
14
|
+
# Grape::Validations::Validators::Base.
|
16
15
|
def register_validator(short_name, klass)
|
17
16
|
validators[short_name] = klass
|
18
17
|
end
|
@@ -21,14 +20,11 @@ module Grape
|
|
21
20
|
validators.delete(short_name)
|
22
21
|
end
|
23
22
|
|
24
|
-
# Find a validator and if not found will try to load it
|
25
23
|
def require_validator(short_name)
|
26
24
|
str_name = short_name.to_s
|
27
|
-
validators.fetch(str_name)
|
28
|
-
Grape::Validations::Validators.const_get("#{str_name.camelize}Validator")
|
29
|
-
end
|
25
|
+
validators.fetch(str_name) { Grape::Validations::Validators.const_get(:"#{str_name.camelize}Validator") }
|
30
26
|
rescue NameError
|
31
|
-
raise Grape::Exceptions::UnknownValidator
|
27
|
+
raise Grape::Exceptions::UnknownValidator, short_name
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
data/lib/grape/version.rb
CHANGED
data/lib/grape.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
require 'rack'
|
5
|
-
require 'rack/builder'
|
6
|
-
require 'rack/accept'
|
7
|
-
require 'rack/auth/basic'
|
8
|
-
require 'rack/auth/digest/md5'
|
9
|
-
require 'set'
|
10
|
-
require 'bigdecimal'
|
11
|
-
require 'date'
|
12
3
|
require 'active_support'
|
13
4
|
require 'active_support/concern'
|
14
5
|
require 'active_support/configurable'
|
@@ -17,6 +8,7 @@ require 'active_support/isolated_execution_state' if ActiveSupport::VERSION::MAJ
|
|
17
8
|
require 'active_support/core_ext/array/conversions'
|
18
9
|
require 'active_support/core_ext/array/extract_options'
|
19
10
|
require 'active_support/core_ext/array/wrap'
|
11
|
+
require 'active_support/core_ext/enumerable'
|
20
12
|
require 'active_support/core_ext/hash/conversions'
|
21
13
|
require 'active_support/core_ext/hash/deep_merge'
|
22
14
|
require 'active_support/core_ext/hash/except'
|
@@ -24,270 +16,50 @@ require 'active_support/core_ext/hash/indifferent_access'
|
|
24
16
|
require 'active_support/core_ext/hash/keys'
|
25
17
|
require 'active_support/core_ext/hash/reverse_merge'
|
26
18
|
require 'active_support/core_ext/hash/slice'
|
19
|
+
require 'active_support/core_ext/module/delegation'
|
27
20
|
require 'active_support/core_ext/object/blank'
|
21
|
+
require 'active_support/core_ext/object/deep_dup'
|
28
22
|
require 'active_support/core_ext/object/duplicable'
|
29
|
-
require 'active_support/
|
23
|
+
require 'active_support/core_ext/string/output_safety'
|
24
|
+
require 'active_support/core_ext/string/exclude'
|
30
25
|
require 'active_support/deprecation'
|
31
26
|
require 'active_support/inflector'
|
27
|
+
require 'active_support/ordered_options'
|
32
28
|
require 'active_support/notifications'
|
33
|
-
|
29
|
+
|
30
|
+
require 'English'
|
31
|
+
require 'bigdecimal'
|
32
|
+
require 'date'
|
33
|
+
require 'dry-types'
|
34
|
+
require 'forwardable'
|
35
|
+
require 'json'
|
36
|
+
require 'logger'
|
37
|
+
require 'mustermann/grape'
|
38
|
+
require 'pathname'
|
39
|
+
require 'rack'
|
40
|
+
require 'rack/auth/basic'
|
41
|
+
require 'rack/builder'
|
42
|
+
require 'rack/head'
|
43
|
+
require 'set'
|
44
|
+
require 'singleton'
|
45
|
+
require 'zeitwerk'
|
46
|
+
|
47
|
+
loader = Zeitwerk::Loader.for_gem
|
48
|
+
loader.inflector.inflect(
|
49
|
+
'api' => 'API',
|
50
|
+
'dsl' => 'DSL'
|
51
|
+
)
|
52
|
+
railtie = "#{__dir__}/grape/railtie.rb"
|
53
|
+
loader.do_not_eager_load(railtie)
|
54
|
+
loader.setup
|
34
55
|
|
35
56
|
I18n.load_path << File.expand_path('grape/locale/en.yml', __dir__)
|
36
57
|
|
37
58
|
module Grape
|
38
59
|
include ActiveSupport::Configurable
|
39
|
-
extend ::ActiveSupport::Autoload
|
40
|
-
|
41
|
-
eager_autoload do
|
42
|
-
autoload :API
|
43
|
-
autoload :Endpoint
|
44
|
-
|
45
|
-
autoload :Namespace
|
46
|
-
|
47
|
-
autoload :Path
|
48
|
-
autoload :Cookies
|
49
|
-
autoload :Validations
|
50
|
-
autoload :ErrorFormatter
|
51
|
-
autoload :Formatter
|
52
|
-
autoload :Parser
|
53
|
-
autoload :Request
|
54
|
-
autoload :Env, 'grape/util/env'
|
55
|
-
autoload :Json, 'grape/util/json'
|
56
|
-
autoload :Xml, 'grape/util/xml'
|
57
|
-
autoload :DryTypes
|
58
|
-
end
|
59
|
-
|
60
|
-
module Http
|
61
|
-
extend ::ActiveSupport::Autoload
|
62
|
-
eager_autoload do
|
63
|
-
autoload :Headers
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
module Exceptions
|
68
|
-
extend ::ActiveSupport::Autoload
|
69
|
-
eager_autoload do
|
70
|
-
autoload :Base
|
71
|
-
autoload :Validation
|
72
|
-
autoload :ValidationArrayErrors
|
73
|
-
autoload :ValidationErrors
|
74
|
-
autoload :MissingVendorOption
|
75
|
-
autoload :MissingMimeType
|
76
|
-
autoload :MissingOption
|
77
|
-
autoload :InvalidFormatter
|
78
|
-
autoload :InvalidVersionerOption
|
79
|
-
autoload :UnknownValidator
|
80
|
-
autoload :UnknownOptions
|
81
|
-
autoload :UnknownParameter
|
82
|
-
autoload :InvalidWithOptionForRepresent
|
83
|
-
autoload :IncompatibleOptionValues
|
84
|
-
autoload :MissingGroupType
|
85
|
-
autoload :UnsupportedGroupType
|
86
|
-
autoload :InvalidMessageBody
|
87
|
-
autoload :InvalidAcceptHeader
|
88
|
-
autoload :InvalidVersionHeader
|
89
|
-
autoload :MethodNotAllowed
|
90
|
-
autoload :InvalidResponse
|
91
|
-
autoload :EmptyMessageBody
|
92
|
-
autoload :TooManyMultipartFiles
|
93
|
-
autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type'
|
94
|
-
autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type'
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
module Extensions
|
99
|
-
extend ::ActiveSupport::Autoload
|
100
|
-
eager_autoload do
|
101
|
-
autoload :Hash
|
102
|
-
end
|
103
|
-
module ActiveSupport
|
104
|
-
extend ::ActiveSupport::Autoload
|
105
|
-
eager_autoload do
|
106
|
-
autoload :HashWithIndifferentAccess
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
module Hashie
|
111
|
-
extend ::ActiveSupport::Autoload
|
112
|
-
eager_autoload do
|
113
|
-
autoload :Mash
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
module Middleware
|
119
|
-
extend ::ActiveSupport::Autoload
|
120
|
-
eager_autoload do
|
121
|
-
autoload :Base
|
122
|
-
autoload :Versioner
|
123
|
-
autoload :Formatter
|
124
|
-
autoload :Error
|
125
|
-
autoload :Globals
|
126
|
-
autoload :Stack
|
127
|
-
autoload :Helpers
|
128
|
-
end
|
129
|
-
|
130
|
-
module Auth
|
131
|
-
extend ::ActiveSupport::Autoload
|
132
|
-
eager_autoload do
|
133
|
-
autoload :Base
|
134
|
-
autoload :DSL
|
135
|
-
autoload :StrategyInfo
|
136
|
-
autoload :Strategies
|
137
|
-
end
|
138
|
-
end
|
139
60
|
|
140
|
-
|
141
|
-
|
142
|
-
eager_autoload do
|
143
|
-
autoload :Path
|
144
|
-
autoload :Header
|
145
|
-
autoload :Param
|
146
|
-
autoload :AcceptVersionHeader
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
module Util
|
152
|
-
extend ::ActiveSupport::Autoload
|
153
|
-
eager_autoload do
|
154
|
-
autoload :InheritableValues
|
155
|
-
autoload :StackableValues
|
156
|
-
autoload :ReverseStackableValues
|
157
|
-
autoload :InheritableSetting
|
158
|
-
autoload :StrictHashConfiguration
|
159
|
-
autoload :Registrable
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
module ErrorFormatter
|
164
|
-
extend ::ActiveSupport::Autoload
|
165
|
-
eager_autoload do
|
166
|
-
autoload :Base
|
167
|
-
autoload :Json
|
168
|
-
autoload :Txt
|
169
|
-
autoload :Xml
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
module Formatter
|
174
|
-
extend ::ActiveSupport::Autoload
|
175
|
-
eager_autoload do
|
176
|
-
autoload :Json
|
177
|
-
autoload :SerializableHash
|
178
|
-
autoload :Txt
|
179
|
-
autoload :Xml
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
module Parser
|
184
|
-
extend ::ActiveSupport::Autoload
|
185
|
-
eager_autoload do
|
186
|
-
autoload :Json
|
187
|
-
autoload :Xml
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
module DSL
|
192
|
-
extend ::ActiveSupport::Autoload
|
193
|
-
eager_autoload do
|
194
|
-
autoload :API
|
195
|
-
autoload :Callbacks
|
196
|
-
autoload :Settings
|
197
|
-
autoload :Configuration
|
198
|
-
autoload :InsideRoute
|
199
|
-
autoload :Helpers
|
200
|
-
autoload :Middleware
|
201
|
-
autoload :Parameters
|
202
|
-
autoload :RequestResponse
|
203
|
-
autoload :Routing
|
204
|
-
autoload :Validations
|
205
|
-
autoload :Logger
|
206
|
-
autoload :Desc
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
class API
|
211
|
-
extend ::ActiveSupport::Autoload
|
212
|
-
eager_autoload do
|
213
|
-
autoload :Helpers
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
module Presenters
|
218
|
-
extend ::ActiveSupport::Autoload
|
219
|
-
eager_autoload do
|
220
|
-
autoload :Presenter
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
module ServeStream
|
225
|
-
extend ::ActiveSupport::Autoload
|
226
|
-
eager_autoload do
|
227
|
-
autoload :FileBody
|
228
|
-
autoload :SendfileResponse
|
229
|
-
autoload :StreamResponse
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
module Validations
|
234
|
-
extend ::ActiveSupport::Autoload
|
235
|
-
|
236
|
-
eager_autoload do
|
237
|
-
autoload :AttributesIterator
|
238
|
-
autoload :MultipleAttributesIterator
|
239
|
-
autoload :SingleAttributeIterator
|
240
|
-
autoload :Types
|
241
|
-
autoload :ParamsScope
|
242
|
-
autoload :ValidatorFactory
|
243
|
-
autoload :Base, 'grape/validations/validators/base'
|
244
|
-
end
|
245
|
-
|
246
|
-
module Types
|
247
|
-
extend ::ActiveSupport::Autoload
|
248
|
-
|
249
|
-
eager_autoload do
|
250
|
-
autoload :InvalidValue
|
251
|
-
autoload :DryTypeCoercer
|
252
|
-
autoload :ArrayCoercer
|
253
|
-
autoload :SetCoercer
|
254
|
-
autoload :PrimitiveCoercer
|
255
|
-
autoload :CustomTypeCoercer
|
256
|
-
autoload :CustomTypeCollectionCoercer
|
257
|
-
autoload :MultipleTypeCoercer
|
258
|
-
autoload :VariantCollectionCoercer
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
module Validators
|
263
|
-
extend ::ActiveSupport::Autoload
|
264
|
-
|
265
|
-
eager_autoload do
|
266
|
-
autoload :Base
|
267
|
-
autoload :MultipleParamsBase
|
268
|
-
autoload :AllOrNoneOfValidator
|
269
|
-
autoload :AllowBlankValidator
|
270
|
-
autoload :AsValidator
|
271
|
-
autoload :AtLeastOneOfValidator
|
272
|
-
autoload :CoerceValidator
|
273
|
-
autoload :DefaultValidator
|
274
|
-
autoload :ExactlyOneOfValidator
|
275
|
-
autoload :ExceptValuesValidator
|
276
|
-
autoload :MutualExclusionValidator
|
277
|
-
autoload :PresenceValidator
|
278
|
-
autoload :RegexpValidator
|
279
|
-
autoload :SameAsValidator
|
280
|
-
autoload :ValuesValidator
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
module Types
|
286
|
-
extend ::ActiveSupport::Autoload
|
287
|
-
|
288
|
-
eager_autoload do
|
289
|
-
autoload :InvalidValue
|
290
|
-
end
|
61
|
+
def self.deprecator
|
62
|
+
@deprecator ||= ActiveSupport::Deprecation.new('2.0', 'Grape')
|
291
63
|
end
|
292
64
|
|
293
65
|
configure do |config|
|
@@ -296,10 +68,7 @@ module Grape
|
|
296
68
|
end
|
297
69
|
end
|
298
70
|
|
299
|
-
|
300
|
-
|
301
|
-
require 'grape/
|
302
|
-
|
303
|
-
require 'grape/util/endpoint_configuration'
|
304
|
-
|
305
|
-
require 'grape/version'
|
71
|
+
# https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html
|
72
|
+
# adding Grape.deprecator to Rails App if any
|
73
|
+
require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1')
|
74
|
+
loader.eager_load
|