jsapi 1.4 → 2.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.
- checksums.yaml +4 -4
- data/lib/jsapi/controller/actions/class_methods.rb +61 -0
- data/lib/jsapi/controller/actions.rb +13 -0
- data/lib/jsapi/controller/authentication/class_methods.rb +65 -0
- data/lib/jsapi/controller/authentication/credentials/api_key.rb +24 -0
- data/lib/jsapi/controller/authentication/credentials/http/base.rb +25 -0
- data/lib/jsapi/controller/authentication/credentials/http/basic.rb +34 -0
- data/lib/jsapi/controller/authentication/credentials/http/bearer.rb +30 -0
- data/lib/jsapi/controller/authentication/credentials/http.rb +5 -0
- data/lib/jsapi/controller/authentication/credentials.rb +38 -0
- data/lib/jsapi/controller/authentication.rb +70 -0
- data/lib/jsapi/controller/base.rb +5 -4
- data/lib/jsapi/controller/methods/callbacks/callback.rb +80 -0
- data/lib/jsapi/controller/methods/callbacks/class_methods.rb +62 -0
- data/lib/jsapi/controller/methods/callbacks.rb +54 -0
- data/lib/jsapi/controller/methods.rb +209 -116
- data/lib/jsapi/controller/parameters.rb +24 -20
- data/lib/jsapi/controller/response.rb +71 -39
- data/lib/jsapi/controller.rb +2 -1
- data/lib/jsapi/dsl/base.rb +38 -5
- data/lib/jsapi/dsl/class_methods.rb +2 -2
- data/lib/jsapi/dsl/definitions.rb +41 -27
- data/lib/jsapi/dsl/operation.rb +10 -109
- data/lib/jsapi/dsl/parameter.rb +1 -1
- data/lib/jsapi/dsl/path.rb +41 -18
- data/lib/jsapi/dsl/request_body.rb +1 -1
- data/lib/jsapi/dsl/response.rb +9 -6
- data/lib/jsapi/dsl/schema.rb +11 -5
- data/lib/jsapi/dsl/shared_operation_methods.rb +140 -0
- data/lib/jsapi/dsl.rb +1 -2
- data/lib/jsapi/json/array.rb +2 -2
- data/lib/jsapi/json/object.rb +6 -6
- data/lib/jsapi/json.rb +4 -6
- data/lib/jsapi/media/range.rb +102 -0
- data/lib/jsapi/media/type.rb +70 -0
- data/lib/jsapi/media/type_and_subtype.rb +38 -0
- data/lib/jsapi/media.rb +9 -0
- data/lib/jsapi/messages.rb +19 -0
- data/lib/jsapi/meta/callback/base.rb +63 -8
- data/lib/jsapi/meta/content.rb +59 -0
- data/lib/jsapi/meta/definitions.rb +299 -153
- data/lib/jsapi/meta/example/base.rb +41 -8
- data/lib/jsapi/meta/existence.rb +4 -2
- data/lib/jsapi/meta/header/base.rb +4 -2
- data/lib/jsapi/meta/info.rb +3 -1
- data/lib/jsapi/meta/license.rb +11 -5
- data/lib/jsapi/meta/model/attributes/class_methods.rb +150 -0
- data/lib/jsapi/meta/model/attributes/frozen_error.rb +16 -0
- data/lib/jsapi/meta/model/attributes/type_caster.rb +56 -0
- data/lib/jsapi/meta/model/attributes.rb +24 -118
- data/lib/jsapi/meta/model/base.rb +2 -5
- data/lib/jsapi/meta/model/reference.rb +46 -10
- data/lib/jsapi/meta/model/wrappable.rb +23 -0
- data/lib/jsapi/meta/model/wrapper.rb +26 -0
- data/lib/jsapi/meta/model.rb +2 -1
- data/lib/jsapi/meta/oauth_flow.rb +1 -1
- data/lib/jsapi/meta/openapi/extensions.rb +5 -6
- data/lib/jsapi/meta/openapi/version.rb +16 -4
- data/lib/jsapi/meta/operation.rb +177 -71
- data/lib/jsapi/meta/parameter/base.rb +10 -6
- data/lib/jsapi/meta/parameter/wrapper.rb +13 -0
- data/lib/jsapi/meta/parameter.rb +3 -0
- data/lib/jsapi/meta/path.rb +59 -13
- data/lib/jsapi/meta/pathname.rb +6 -3
- data/lib/jsapi/meta/property.rb +10 -0
- data/lib/jsapi/meta/request_body/base.rb +69 -32
- data/lib/jsapi/meta/request_body/wrapper.rb +13 -0
- data/lib/jsapi/meta/request_body.rb +3 -0
- data/lib/jsapi/meta/rescue_handler.rb +18 -17
- data/lib/jsapi/meta/response/base.rb +82 -58
- data/lib/jsapi/meta/response/reference.rb +11 -1
- data/lib/jsapi/meta/response/wrapper.rb +26 -0
- data/lib/jsapi/meta/response.rb +3 -0
- data/lib/jsapi/meta/schema/additional_properties.rb +8 -0
- data/lib/jsapi/meta/schema/array.rb +20 -8
- data/lib/jsapi/meta/schema/base.rb +10 -9
- data/lib/jsapi/meta/schema/boundary.rb +1 -0
- data/lib/jsapi/meta/schema/numeric.rb +26 -20
- data/lib/jsapi/meta/schema/object.rb +60 -44
- data/lib/jsapi/meta/schema/reference.rb +1 -8
- data/lib/jsapi/meta/schema/string.rb +12 -6
- data/lib/jsapi/meta/schema/wrapper.rb +31 -0
- data/lib/jsapi/meta/schema.rb +22 -9
- data/lib/jsapi/meta/security_requirement.rb +2 -2
- data/lib/jsapi/meta/security_scheme/api_key.rb +5 -2
- data/lib/jsapi/meta/security_scheme/base.rb +7 -5
- data/lib/jsapi/meta/security_scheme/http/basic.rb +5 -7
- data/lib/jsapi/meta/security_scheme/http/bearer.rb +5 -5
- data/lib/jsapi/meta/security_scheme/http/other.rb +1 -3
- data/lib/jsapi/meta/security_scheme/mutual_tls.rb +1 -3
- data/lib/jsapi/meta/security_scheme/oauth2.rb +18 -13
- data/lib/jsapi/meta/security_scheme/open_id_connect.rb +4 -4
- data/lib/jsapi/meta/security_scheme.rb +4 -4
- data/lib/jsapi/meta/server.rb +4 -2
- data/lib/jsapi/meta/tag.rb +9 -3
- data/lib/jsapi/meta.rb +2 -1
- data/lib/jsapi/model/base.rb +1 -1
- data/lib/jsapi/status/base.rb +35 -0
- data/lib/jsapi/status/code.rb +113 -0
- data/lib/jsapi/status/default.rb +16 -0
- data/lib/jsapi/status/range.rb +35 -0
- data/lib/jsapi/status.rb +37 -0
- data/lib/jsapi/version.rb +1 -1
- data/lib/jsapi.rb +3 -3
- metadata +36 -10
- data/lib/jsapi/controller/parameters_invalid.rb +0 -27
- data/lib/jsapi/dsl/callback.rb +0 -21
- data/lib/jsapi/dsl/error.rb +0 -36
- data/lib/jsapi/invalid_argument_error.rb +0 -12
- data/lib/jsapi/invalid_value_error.rb +0 -12
- data/lib/jsapi/invalid_value_helper.rb +0 -17
- data/lib/jsapi/meta/model/type_caster.rb +0 -50
- data/lib/jsapi/meta/schema/delegator.rb +0 -26
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jsapi
|
|
4
|
+
module Status
|
|
5
|
+
# Represents a status code.
|
|
6
|
+
class Code < Base
|
|
7
|
+
class << self
|
|
8
|
+
# Transforms +value+ to an instance of this class.
|
|
9
|
+
#
|
|
10
|
+
# Raises an +ArgumentError+ if +value+ could not be transformed.
|
|
11
|
+
def from(value)
|
|
12
|
+
return value if value.nil? || value.is_a?(Code)
|
|
13
|
+
|
|
14
|
+
code = status_code(value.to_sym) if value.respond_to?(:to_sym)
|
|
15
|
+
code ||= value.to_i
|
|
16
|
+
return new(code) if (100..599).cover?(code)
|
|
17
|
+
|
|
18
|
+
raise ArgumentError, "invalid status code: #{value.inspect}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def status_code(symbol)
|
|
22
|
+
symbol_to_code[symbol]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def symbol_to_code
|
|
28
|
+
@symbol_to_code ||= {
|
|
29
|
+
# Informational
|
|
30
|
+
100 => :continue,
|
|
31
|
+
101 => :switching_protocols,
|
|
32
|
+
102 => :processing,
|
|
33
|
+
103 => :early_hints,
|
|
34
|
+
|
|
35
|
+
# Success
|
|
36
|
+
200 => :ok,
|
|
37
|
+
201 => :created,
|
|
38
|
+
202 => :accepted,
|
|
39
|
+
203 => :non_authoritative_information,
|
|
40
|
+
204 => :no_content,
|
|
41
|
+
205 => :reset_content,
|
|
42
|
+
206 => :partial_content,
|
|
43
|
+
207 => :multi_status,
|
|
44
|
+
208 => :already_reported,
|
|
45
|
+
226 => :im_used,
|
|
46
|
+
|
|
47
|
+
# Redirection
|
|
48
|
+
300 => :multiple_choices,
|
|
49
|
+
301 => :moved_permanently,
|
|
50
|
+
302 => :found,
|
|
51
|
+
303 => :see_other,
|
|
52
|
+
304 => :not_modified,
|
|
53
|
+
307 => :temporary_redirect,
|
|
54
|
+
308 => :permanent_redirect,
|
|
55
|
+
|
|
56
|
+
# Client error
|
|
57
|
+
400 => :bad_request,
|
|
58
|
+
401 => :unauthorized,
|
|
59
|
+
402 => :payment_required,
|
|
60
|
+
403 => :forbidden,
|
|
61
|
+
404 => :not_found,
|
|
62
|
+
405 => :method_not_allowed,
|
|
63
|
+
406 => :not_acceptable,
|
|
64
|
+
407 => :proxy_authentication_required,
|
|
65
|
+
408 => :request_timeout,
|
|
66
|
+
409 => :conflict,
|
|
67
|
+
410 => :gone,
|
|
68
|
+
411 => :length_required,
|
|
69
|
+
412 => :precondition_failed,
|
|
70
|
+
413 => :content_too_large,
|
|
71
|
+
414 => :uri_too_long,
|
|
72
|
+
415 => :unsupported_media_type,
|
|
73
|
+
416 => :range_not_satisfiable,
|
|
74
|
+
417 => :expectation_failed,
|
|
75
|
+
421 => :misdirected_request,
|
|
76
|
+
422 => :unprocessable_content,
|
|
77
|
+
423 => :locked,
|
|
78
|
+
424 => :failed_dependency,
|
|
79
|
+
425 => :too_early,
|
|
80
|
+
426 => :upgrade_required,
|
|
81
|
+
428 => :precondition_required,
|
|
82
|
+
429 => :too_many_requests,
|
|
83
|
+
431 => :request_header_fields_too_large,
|
|
84
|
+
451 => :unavailable_for_legal_reasons,
|
|
85
|
+
|
|
86
|
+
# Server error
|
|
87
|
+
500 => :internal_server_error,
|
|
88
|
+
501 => :not_implemented,
|
|
89
|
+
502 => :bad_gateway,
|
|
90
|
+
503 => :service_unavailable,
|
|
91
|
+
504 => :gateway_timeout,
|
|
92
|
+
505 => :http_version_not_supported,
|
|
93
|
+
506 => :variant_also_negotiates,
|
|
94
|
+
507 => :insufficient_storage,
|
|
95
|
+
508 => :loop_detected,
|
|
96
|
+
511 => :network_authentication_required
|
|
97
|
+
}.invert
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
delegate :to_i, to: :value
|
|
102
|
+
|
|
103
|
+
def initialize(value) # :nodoc:
|
|
104
|
+
super(value, priority: 1)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Returns true if and only if +status_code+ is equal to itself.
|
|
108
|
+
def match?(status_code)
|
|
109
|
+
status_code == self
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jsapi
|
|
4
|
+
module Status
|
|
5
|
+
# The default status.
|
|
6
|
+
DEFAULT = Class.new(Base) do
|
|
7
|
+
def inspect
|
|
8
|
+
'#<Jsapi::Status::DEFAULT>'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def match?(_)
|
|
12
|
+
true
|
|
13
|
+
end
|
|
14
|
+
end.new('default', priority: 3)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jsapi
|
|
4
|
+
module Status
|
|
5
|
+
# Represents a range of status codes.
|
|
6
|
+
class Range < Base
|
|
7
|
+
def initialize(hundreds) # :nodoc:
|
|
8
|
+
super("#{hundreds}XX", priority: 2)
|
|
9
|
+
|
|
10
|
+
range_begin = hundreds * 100
|
|
11
|
+
@range = (range_begin..(range_begin + 99))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# The range of informational status codes (1xx).
|
|
15
|
+
INFORMATIONAL = Range.new(1)
|
|
16
|
+
|
|
17
|
+
# The range of success status codes (2xx).
|
|
18
|
+
SUCCESS = Range.new(2)
|
|
19
|
+
|
|
20
|
+
# The range of redirection status codes (3xx).
|
|
21
|
+
REDIRECTION = Range.new(3)
|
|
22
|
+
|
|
23
|
+
# The range of client error status codes (4xx).
|
|
24
|
+
CLIENT_ERROR = Range.new(4)
|
|
25
|
+
|
|
26
|
+
# The range of server error status codes (5xx).
|
|
27
|
+
SERVER_ERROR = Range.new(5)
|
|
28
|
+
|
|
29
|
+
# Returns true if the range covers +status_code+.
|
|
30
|
+
def match?(status_code)
|
|
31
|
+
@range.cover?(status_code.value) if status_code
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/jsapi/status.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'status/base'
|
|
4
|
+
require_relative 'status/code'
|
|
5
|
+
require_relative 'status/default'
|
|
6
|
+
require_relative 'status/range'
|
|
7
|
+
|
|
8
|
+
module Jsapi
|
|
9
|
+
# Provides classes to deal with response status codes.
|
|
10
|
+
module Status
|
|
11
|
+
class << self
|
|
12
|
+
# Transforms +value+ to an instance of Base.
|
|
13
|
+
#
|
|
14
|
+
# Raises an +ArgumentError+ if +value+ could not be transformed.
|
|
15
|
+
def from(value)
|
|
16
|
+
return value if value.is_a?(Base)
|
|
17
|
+
|
|
18
|
+
case value&.to_s
|
|
19
|
+
when nil, 'default'
|
|
20
|
+
DEFAULT
|
|
21
|
+
when '1XX', '1xx'
|
|
22
|
+
Range::INFORMATIONAL
|
|
23
|
+
when '2XX', '2xx'
|
|
24
|
+
Range::SUCCESS
|
|
25
|
+
when '3XX', '3xx'
|
|
26
|
+
Range::REDIRECTION
|
|
27
|
+
when '4XX', '4xx'
|
|
28
|
+
Range::CLIENT_ERROR
|
|
29
|
+
when '5XX', '5xx'
|
|
30
|
+
Range::SERVER_ERROR
|
|
31
|
+
else
|
|
32
|
+
Code.from(value)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/jsapi/version.rb
CHANGED
data/lib/jsapi.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'jsapi/
|
|
4
|
-
require 'jsapi/invalid_value_error'
|
|
5
|
-
require 'jsapi/invalid_argument_error'
|
|
3
|
+
require 'jsapi/messages'
|
|
6
4
|
require 'jsapi/configuration'
|
|
5
|
+
require 'jsapi/media'
|
|
6
|
+
require 'jsapi/status'
|
|
7
7
|
require 'jsapi/model'
|
|
8
8
|
require 'jsapi/meta'
|
|
9
9
|
require 'jsapi/dsl'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '
|
|
4
|
+
version: '2.0'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Göller
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: denis@dmgoeller.de
|
|
@@ -19,18 +19,28 @@ files:
|
|
|
19
19
|
- lib/jsapi.rb
|
|
20
20
|
- lib/jsapi/configuration.rb
|
|
21
21
|
- lib/jsapi/controller.rb
|
|
22
|
+
- lib/jsapi/controller/actions.rb
|
|
23
|
+
- lib/jsapi/controller/actions/class_methods.rb
|
|
24
|
+
- lib/jsapi/controller/authentication.rb
|
|
25
|
+
- lib/jsapi/controller/authentication/class_methods.rb
|
|
26
|
+
- lib/jsapi/controller/authentication/credentials.rb
|
|
27
|
+
- lib/jsapi/controller/authentication/credentials/api_key.rb
|
|
28
|
+
- lib/jsapi/controller/authentication/credentials/http.rb
|
|
29
|
+
- lib/jsapi/controller/authentication/credentials/http/base.rb
|
|
30
|
+
- lib/jsapi/controller/authentication/credentials/http/basic.rb
|
|
31
|
+
- lib/jsapi/controller/authentication/credentials/http/bearer.rb
|
|
22
32
|
- lib/jsapi/controller/base.rb
|
|
23
33
|
- lib/jsapi/controller/error.rb
|
|
24
34
|
- lib/jsapi/controller/methods.rb
|
|
35
|
+
- lib/jsapi/controller/methods/callbacks.rb
|
|
36
|
+
- lib/jsapi/controller/methods/callbacks/callback.rb
|
|
37
|
+
- lib/jsapi/controller/methods/callbacks/class_methods.rb
|
|
25
38
|
- lib/jsapi/controller/parameters.rb
|
|
26
|
-
- lib/jsapi/controller/parameters_invalid.rb
|
|
27
39
|
- lib/jsapi/controller/response.rb
|
|
28
40
|
- lib/jsapi/dsl.rb
|
|
29
41
|
- lib/jsapi/dsl/base.rb
|
|
30
|
-
- lib/jsapi/dsl/callback.rb
|
|
31
42
|
- lib/jsapi/dsl/class_methods.rb
|
|
32
43
|
- lib/jsapi/dsl/definitions.rb
|
|
33
|
-
- lib/jsapi/dsl/error.rb
|
|
34
44
|
- lib/jsapi/dsl/examples.rb
|
|
35
45
|
- lib/jsapi/dsl/operation.rb
|
|
36
46
|
- lib/jsapi/dsl/parameter.rb
|
|
@@ -38,9 +48,7 @@ files:
|
|
|
38
48
|
- lib/jsapi/dsl/request_body.rb
|
|
39
49
|
- lib/jsapi/dsl/response.rb
|
|
40
50
|
- lib/jsapi/dsl/schema.rb
|
|
41
|
-
- lib/jsapi/
|
|
42
|
-
- lib/jsapi/invalid_value_error.rb
|
|
43
|
-
- lib/jsapi/invalid_value_helper.rb
|
|
51
|
+
- lib/jsapi/dsl/shared_operation_methods.rb
|
|
44
52
|
- lib/jsapi/json.rb
|
|
45
53
|
- lib/jsapi/json/array.rb
|
|
46
54
|
- lib/jsapi/json/boolean.rb
|
|
@@ -50,6 +58,11 @@ files:
|
|
|
50
58
|
- lib/jsapi/json/object.rb
|
|
51
59
|
- lib/jsapi/json/string.rb
|
|
52
60
|
- lib/jsapi/json/value.rb
|
|
61
|
+
- lib/jsapi/media.rb
|
|
62
|
+
- lib/jsapi/media/range.rb
|
|
63
|
+
- lib/jsapi/media/type.rb
|
|
64
|
+
- lib/jsapi/media/type_and_subtype.rb
|
|
65
|
+
- lib/jsapi/messages.rb
|
|
53
66
|
- lib/jsapi/meta.rb
|
|
54
67
|
- lib/jsapi/meta/callable.rb
|
|
55
68
|
- lib/jsapi/meta/callable/symbol_evaluator.rb
|
|
@@ -58,6 +71,7 @@ files:
|
|
|
58
71
|
- lib/jsapi/meta/callback/base.rb
|
|
59
72
|
- lib/jsapi/meta/callback/reference.rb
|
|
60
73
|
- lib/jsapi/meta/contact.rb
|
|
74
|
+
- lib/jsapi/meta/content.rb
|
|
61
75
|
- lib/jsapi/meta/defaults.rb
|
|
62
76
|
- lib/jsapi/meta/definitions.rb
|
|
63
77
|
- lib/jsapi/meta/example.rb
|
|
@@ -75,9 +89,13 @@ files:
|
|
|
75
89
|
- lib/jsapi/meta/link/reference.rb
|
|
76
90
|
- lib/jsapi/meta/model.rb
|
|
77
91
|
- lib/jsapi/meta/model/attributes.rb
|
|
92
|
+
- lib/jsapi/meta/model/attributes/class_methods.rb
|
|
93
|
+
- lib/jsapi/meta/model/attributes/frozen_error.rb
|
|
94
|
+
- lib/jsapi/meta/model/attributes/type_caster.rb
|
|
78
95
|
- lib/jsapi/meta/model/base.rb
|
|
79
96
|
- lib/jsapi/meta/model/reference.rb
|
|
80
|
-
- lib/jsapi/meta/model/
|
|
97
|
+
- lib/jsapi/meta/model/wrappable.rb
|
|
98
|
+
- lib/jsapi/meta/model/wrapper.rb
|
|
81
99
|
- lib/jsapi/meta/oauth_flow.rb
|
|
82
100
|
- lib/jsapi/meta/openapi.rb
|
|
83
101
|
- lib/jsapi/meta/openapi/extensions.rb
|
|
@@ -87,6 +105,7 @@ files:
|
|
|
87
105
|
- lib/jsapi/meta/parameter.rb
|
|
88
106
|
- lib/jsapi/meta/parameter/base.rb
|
|
89
107
|
- lib/jsapi/meta/parameter/reference.rb
|
|
108
|
+
- lib/jsapi/meta/parameter/wrapper.rb
|
|
90
109
|
- lib/jsapi/meta/path.rb
|
|
91
110
|
- lib/jsapi/meta/pathname.rb
|
|
92
111
|
- lib/jsapi/meta/property.rb
|
|
@@ -94,10 +113,12 @@ files:
|
|
|
94
113
|
- lib/jsapi/meta/request_body.rb
|
|
95
114
|
- lib/jsapi/meta/request_body/base.rb
|
|
96
115
|
- lib/jsapi/meta/request_body/reference.rb
|
|
116
|
+
- lib/jsapi/meta/request_body/wrapper.rb
|
|
97
117
|
- lib/jsapi/meta/rescue_handler.rb
|
|
98
118
|
- lib/jsapi/meta/response.rb
|
|
99
119
|
- lib/jsapi/meta/response/base.rb
|
|
100
120
|
- lib/jsapi/meta/response/reference.rb
|
|
121
|
+
- lib/jsapi/meta/response/wrapper.rb
|
|
101
122
|
- lib/jsapi/meta/schema.rb
|
|
102
123
|
- lib/jsapi/meta/schema/additional_properties.rb
|
|
103
124
|
- lib/jsapi/meta/schema/array.rb
|
|
@@ -105,7 +126,6 @@ files:
|
|
|
105
126
|
- lib/jsapi/meta/schema/boolean.rb
|
|
106
127
|
- lib/jsapi/meta/schema/boundary.rb
|
|
107
128
|
- lib/jsapi/meta/schema/conversion.rb
|
|
108
|
-
- lib/jsapi/meta/schema/delegator.rb
|
|
109
129
|
- lib/jsapi/meta/schema/discriminator.rb
|
|
110
130
|
- lib/jsapi/meta/schema/integer.rb
|
|
111
131
|
- lib/jsapi/meta/schema/number.rb
|
|
@@ -124,6 +144,7 @@ files:
|
|
|
124
144
|
- lib/jsapi/meta/schema/validation/minimum.rb
|
|
125
145
|
- lib/jsapi/meta/schema/validation/multiple_of.rb
|
|
126
146
|
- lib/jsapi/meta/schema/validation/pattern.rb
|
|
147
|
+
- lib/jsapi/meta/schema/wrapper.rb
|
|
127
148
|
- lib/jsapi/meta/security_requirement.rb
|
|
128
149
|
- lib/jsapi/meta/security_scheme.rb
|
|
129
150
|
- lib/jsapi/meta/security_scheme/api_key.rb
|
|
@@ -144,6 +165,11 @@ files:
|
|
|
144
165
|
- lib/jsapi/model/errors.rb
|
|
145
166
|
- lib/jsapi/model/nestable.rb
|
|
146
167
|
- lib/jsapi/model/nested_error.rb
|
|
168
|
+
- lib/jsapi/status.rb
|
|
169
|
+
- lib/jsapi/status/base.rb
|
|
170
|
+
- lib/jsapi/status/code.rb
|
|
171
|
+
- lib/jsapi/status/default.rb
|
|
172
|
+
- lib/jsapi/status/range.rb
|
|
147
173
|
- lib/jsapi/version.rb
|
|
148
174
|
homepage: https://github.com/dmgoeller/jsapi
|
|
149
175
|
licenses:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module Controller
|
|
5
|
-
# Raised by Methods#api_operation! when the request parameters are invalid.
|
|
6
|
-
class ParametersInvalid < StandardError
|
|
7
|
-
|
|
8
|
-
# The parameters.
|
|
9
|
-
attr_reader :params
|
|
10
|
-
|
|
11
|
-
def initialize(params)
|
|
12
|
-
@params = params
|
|
13
|
-
super('')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Returns the errors encountered.
|
|
17
|
-
def errors
|
|
18
|
-
@params.errors.errors
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Overrides <code>Exception#message</code> to lazily generate the error message.
|
|
22
|
-
def message
|
|
23
|
-
"#{@params.errors.full_messages.map { |m| m.delete_suffix('.') }.join('. ')}."
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
data/lib/jsapi/dsl/callback.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module DSL
|
|
5
|
-
# Used to specify an OpenAPI callback object.
|
|
6
|
-
class Callback < Base
|
|
7
|
-
|
|
8
|
-
# Adds a callback operation.
|
|
9
|
-
#
|
|
10
|
-
# operation '{$request.query.foo}' do
|
|
11
|
-
# parameter 'bar', type: 'string'
|
|
12
|
-
# end
|
|
13
|
-
def operation(expression, **keywords, &block)
|
|
14
|
-
define('operation', expression.inspect) do
|
|
15
|
-
operation_model = @meta_model.add_operation(expression, keywords)
|
|
16
|
-
Operation.new(operation_model, &block) if block
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
data/lib/jsapi/dsl/error.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module DSL
|
|
5
|
-
# Raised when an error occurred while defining an API component.
|
|
6
|
-
class Error < StandardError
|
|
7
|
-
|
|
8
|
-
# Creates a new error. +origin+ is the innermost position at where the error occurred.
|
|
9
|
-
def initialize(error_or_message, origin = nil)
|
|
10
|
-
@path = Array(origin)
|
|
11
|
-
super(
|
|
12
|
-
if error_or_message.respond_to?(:message)
|
|
13
|
-
error_or_message.message
|
|
14
|
-
else
|
|
15
|
-
error_or_message
|
|
16
|
-
end
|
|
17
|
-
)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Overrides <code>StandardError#message</code> to append the whole path of the position
|
|
21
|
-
# at where the error occurred, for example: <code>{message} (at foo / bar)</code>.
|
|
22
|
-
def message
|
|
23
|
-
message = super
|
|
24
|
-
return message if @path.empty?
|
|
25
|
-
|
|
26
|
-
"#{message} (at #{@path.join(' / ')})"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Prepends +origin+ to the path at where the error occurred.
|
|
30
|
-
def prepend_origin(origin)
|
|
31
|
-
@path.prepend(origin) if origin.present?
|
|
32
|
-
self
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
# Raised when an argument isn't contained in the list of valid values.
|
|
5
|
-
class InvalidArgumentError < ArgumentError
|
|
6
|
-
include InvalidValueHelper
|
|
7
|
-
|
|
8
|
-
def initialize(name, value, valid_values: [])
|
|
9
|
-
super(build_message(name, value, valid_values))
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
# Raised when a value isn't contained in the list of valid values.
|
|
5
|
-
class InvalidValueError < RuntimeError
|
|
6
|
-
include InvalidValueHelper
|
|
7
|
-
|
|
8
|
-
def initialize(name, value, valid_values: [])
|
|
9
|
-
super(build_message(name, value, valid_values))
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module InvalidValueHelper # :nodoc:
|
|
5
|
-
def build_message(name, value, valid_values)
|
|
6
|
-
case valid_values.count
|
|
7
|
-
when 0
|
|
8
|
-
"#{name} must not be #{value.inspect}"
|
|
9
|
-
when 1
|
|
10
|
-
"#{name} must be #{valid_values.first.inspect}, is #{value.inspect}"
|
|
11
|
-
else
|
|
12
|
-
"#{name} must be one of #{valid_values[0..-2].map(&:inspect).join(', ')} " \
|
|
13
|
-
"or #{valid_values.last.inspect}, is #{value.inspect}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module Meta
|
|
5
|
-
module Model
|
|
6
|
-
class TypeCaster
|
|
7
|
-
STRING_CASTER = ->(arg) { arg&.to_s } # :nodoc:
|
|
8
|
-
|
|
9
|
-
SYMBOL_CASTER = ->(arg) { # :nodoc:
|
|
10
|
-
return if arg.nil?
|
|
11
|
-
|
|
12
|
-
arg = arg.to_s unless arg.respond_to?(:to_sym)
|
|
13
|
-
arg.to_sym
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
# Creates a new type caster for +klass+.
|
|
17
|
-
def initialize(klass = nil, name: 'value', values: nil)
|
|
18
|
-
klass = Object if klass.nil?
|
|
19
|
-
@caster =
|
|
20
|
-
case klass.name
|
|
21
|
-
when 'String'
|
|
22
|
-
STRING_CASTER
|
|
23
|
-
when 'Symbol'
|
|
24
|
-
SYMBOL_CASTER
|
|
25
|
-
else
|
|
26
|
-
->(arg) {
|
|
27
|
-
return arg if arg.is_a?(klass)
|
|
28
|
-
return klass.from(arg) if klass.respond_to?(:from)
|
|
29
|
-
return klass.new if arg.nil?
|
|
30
|
-
|
|
31
|
-
klass.new(arg)
|
|
32
|
-
}
|
|
33
|
-
end
|
|
34
|
-
@values = values
|
|
35
|
-
@name = name
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Casts +value+.
|
|
39
|
-
#
|
|
40
|
-
# Raises an InvalidArgumentError if the (casted) value is invalid.
|
|
41
|
-
def cast(value)
|
|
42
|
-
casted_value = @caster.call(value)
|
|
43
|
-
return casted_value unless @values&.exclude?(casted_value)
|
|
44
|
-
|
|
45
|
-
raise InvalidArgumentError.new(@name, casted_value, valid_values: @values)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jsapi
|
|
4
|
-
module Meta
|
|
5
|
-
module Schema
|
|
6
|
-
# Used by Reference to delegate method calls to the referred schema.
|
|
7
|
-
class Delegator
|
|
8
|
-
delegate_missing_to :@schema
|
|
9
|
-
|
|
10
|
-
# The level of Existence.
|
|
11
|
-
attr_reader :existence
|
|
12
|
-
|
|
13
|
-
def initialize(schema, existence)
|
|
14
|
-
@schema = schema
|
|
15
|
-
@existence = existence
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def inspect # :nodoc:
|
|
19
|
-
"#<#{self.class.name} " \
|
|
20
|
-
"schema: #{@schema.inspect}, " \
|
|
21
|
-
"existence: #{@existence.inspect}>"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|