jsapi 0.9.1 → 1.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/dsl/definitions.rb +1 -1
- data/lib/jsapi/dsl/operation.rb +20 -0
- data/lib/jsapi/dsl/schema.rb +12 -2
- data/lib/jsapi/meta/callback/{model.rb → base.rb} +4 -6
- data/lib/jsapi/meta/callback/reference.rb +2 -6
- data/lib/jsapi/meta/callback.rb +3 -3
- data/lib/jsapi/meta/contact.rb +2 -2
- data/lib/jsapi/meta/defaults.rb +1 -1
- data/lib/jsapi/meta/definitions.rb +10 -8
- data/lib/jsapi/meta/example/{model.rb → base.rb} +5 -5
- data/lib/jsapi/meta/example/reference.rb +2 -6
- data/lib/jsapi/meta/example.rb +3 -3
- data/lib/jsapi/meta/external_documentation.rb +2 -2
- data/lib/jsapi/meta/header/{model.rb → base.rb} +3 -3
- data/lib/jsapi/meta/header/reference.rb +2 -6
- data/lib/jsapi/meta/header.rb +3 -3
- data/lib/jsapi/meta/info.rb +15 -7
- data/lib/jsapi/meta/license.rb +28 -5
- data/lib/jsapi/meta/link/{model.rb → base.rb} +2 -2
- data/lib/jsapi/meta/link/reference.rb +2 -6
- data/lib/jsapi/meta/link.rb +3 -3
- data/lib/jsapi/meta/{base → model}/attributes.rb +15 -18
- data/lib/jsapi/meta/{base/model.rb → model/base.rb} +2 -2
- data/lib/jsapi/meta/model/reference.rb +72 -0
- data/lib/jsapi/meta/{base → model}/type_caster.rb +1 -1
- data/lib/jsapi/meta/model.rb +6 -0
- data/lib/jsapi/meta/oauth_flow.rb +2 -2
- data/lib/jsapi/meta/openapi/extensions.rb +9 -25
- data/lib/jsapi/meta/openapi/version.rb +11 -0
- data/lib/jsapi/meta/openapi.rb +10 -0
- data/lib/jsapi/meta/operation.rb +16 -18
- data/lib/jsapi/meta/parameter/{model.rb → base.rb} +86 -69
- data/lib/jsapi/meta/parameter/reference.rb +4 -9
- data/lib/jsapi/meta/parameter.rb +3 -4
- data/lib/jsapi/meta/property.rb +7 -6
- data/lib/jsapi/meta/request_body/{model.rb → base.rb} +11 -9
- data/lib/jsapi/meta/request_body/reference.rb +2 -6
- data/lib/jsapi/meta/request_body.rb +3 -3
- data/lib/jsapi/meta/rescue_handler.rb +1 -1
- data/lib/jsapi/meta/response/{model.rb → base.rb} +3 -3
- data/lib/jsapi/meta/response/reference.rb +2 -9
- data/lib/jsapi/meta/response.rb +3 -3
- data/lib/jsapi/meta/schema/additional_properties.rb +2 -2
- data/lib/jsapi/meta/schema/array.rb +3 -5
- data/lib/jsapi/meta/schema/base.rb +10 -12
- data/lib/jsapi/meta/schema/conversion.rb +2 -2
- data/lib/jsapi/meta/schema/discriminator.rb +1 -1
- data/lib/jsapi/meta/schema/numeric.rb +3 -5
- data/lib/jsapi/meta/schema/object.rb +3 -5
- data/lib/jsapi/meta/schema/reference.rb +6 -6
- data/lib/jsapi/meta/schema/string.rb +3 -5
- data/lib/jsapi/meta/security_requirement.rb +3 -3
- data/lib/jsapi/meta/security_scheme/base.rb +1 -1
- data/lib/jsapi/meta/server.rb +2 -2
- data/lib/jsapi/meta/server_variable.rb +2 -2
- data/lib/jsapi/meta/tag.rb +2 -2
- data/lib/jsapi/meta.rb +1 -1
- data/lib/jsapi/version.rb +1 -1
- metadata +14 -15
- data/lib/jsapi/meta/base/reference.rb +0 -35
- data/lib/jsapi/meta/base.rb +0 -6
- data/lib/jsapi/meta/parameter/to_openapi.rb +0 -13
@@ -3,8 +3,8 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
module Response
|
6
|
-
#
|
7
|
-
class
|
6
|
+
# Specifies a response.
|
7
|
+
class Base < Model::Base
|
8
8
|
include OpenAPI::Extensions
|
9
9
|
|
10
10
|
delegate_missing_to :schema
|
@@ -42,7 +42,7 @@ module Jsapi
|
|
42
42
|
##
|
43
43
|
# :attr_reader: schema
|
44
44
|
# The Schema of the response.
|
45
|
-
attribute :schema,
|
45
|
+
attribute :schema, accessors: %i[reader]
|
46
46
|
|
47
47
|
def initialize(keywords = {})
|
48
48
|
keywords = keywords.dup
|
@@ -3,15 +3,8 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
module Response
|
6
|
-
|
7
|
-
|
8
|
-
def to_openapi(version, *)
|
9
|
-
version = OpenAPI::Version.from(version)
|
10
|
-
path = version.major == 2 ? 'responses' : 'components/responses'
|
11
|
-
|
12
|
-
{ '$ref': "#/#{path}/#{ref}" }
|
13
|
-
end
|
14
|
-
end
|
6
|
+
# Refers a reusable response.
|
7
|
+
class Reference < Model::Reference; end
|
15
8
|
end
|
16
9
|
end
|
17
10
|
end
|
data/lib/jsapi/meta/response.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'response/
|
3
|
+
require_relative 'response/base'
|
4
4
|
require_relative 'response/reference'
|
5
5
|
|
6
6
|
module Jsapi
|
7
7
|
module Meta
|
8
8
|
module Response
|
9
9
|
class << self
|
10
|
-
# Creates a
|
10
|
+
# Creates a Base or Reference.
|
11
11
|
def new(keywords = {})
|
12
12
|
return Reference.new(keywords) if keywords.key?(:ref)
|
13
13
|
|
14
|
-
|
14
|
+
Base.new(keywords)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -3,13 +3,13 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
module Schema
|
6
|
-
class AdditionalProperties <
|
6
|
+
class AdditionalProperties < Model::Base
|
7
7
|
delegate_missing_to :schema
|
8
8
|
|
9
9
|
##
|
10
10
|
# :attr: schema
|
11
11
|
# The Schema of additional properties.
|
12
|
-
attribute :schema,
|
12
|
+
attribute :schema, accessors: %i[reader]
|
13
13
|
|
14
14
|
##
|
15
15
|
# :attr: source
|
@@ -7,19 +7,17 @@ module Jsapi
|
|
7
7
|
##
|
8
8
|
# :attr: items
|
9
9
|
# The Schema defining the kind of items.
|
10
|
-
attribute :items, Schema
|
10
|
+
attribute :items, Schema, accessors: %i[reader]
|
11
11
|
|
12
12
|
##
|
13
13
|
# :attr: max_items
|
14
14
|
# The maximum length of an array.
|
15
|
-
attribute :max_items
|
15
|
+
attribute :max_items, accessors: %i[reader]
|
16
16
|
|
17
17
|
##
|
18
18
|
# :attr: min_items
|
19
19
|
# The minimum length of an array.
|
20
|
-
attribute :min_items
|
21
|
-
|
22
|
-
undef items=, max_items=, min_items=
|
20
|
+
attribute :min_items, accessors: %i[reader]
|
23
21
|
|
24
22
|
def items=(keywords = {}) # :nodoc:
|
25
23
|
if keywords.key?(:schema)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
module Schema
|
6
|
-
class Base <
|
6
|
+
class Base < Model::Base
|
7
7
|
include OpenAPI::Extensions
|
8
8
|
|
9
9
|
##
|
@@ -24,7 +24,7 @@ module Jsapi
|
|
24
24
|
##
|
25
25
|
# :attr: enum
|
26
26
|
# The allowed values.
|
27
|
-
attribute :enum
|
27
|
+
attribute :enum, accessors: %i[reader]
|
28
28
|
|
29
29
|
##
|
30
30
|
# :attr: examples
|
@@ -53,8 +53,6 @@ module Jsapi
|
|
53
53
|
# The validations.
|
54
54
|
attr_reader :validations
|
55
55
|
|
56
|
-
undef enum=
|
57
|
-
|
58
56
|
# Creates a new schema.
|
59
57
|
def initialize(keywords = {})
|
60
58
|
keywords = keywords.dup
|
@@ -96,9 +94,9 @@ module Jsapi
|
|
96
94
|
default: default,
|
97
95
|
examples: examples.presence,
|
98
96
|
deprecated: deprecated?.presence
|
99
|
-
}.tap do |
|
97
|
+
}.tap do |result|
|
100
98
|
validations.each_value do |validation|
|
101
|
-
|
99
|
+
result.merge!(validation.to_json_schema_validation)
|
102
100
|
end
|
103
101
|
end.compact
|
104
102
|
end
|
@@ -129,14 +127,14 @@ module Jsapi
|
|
129
127
|
examples: examples.presence,
|
130
128
|
deprecated: deprecated?.presence
|
131
129
|
}
|
132
|
-
end.tap do |
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
130
|
+
end.tap do |result|
|
131
|
+
result[:title] = title
|
132
|
+
result[:description] = description
|
133
|
+
result[:default] = default
|
134
|
+
result[:externalDocs] = external_docs&.to_openapi
|
137
135
|
|
138
136
|
validations.each_value do |validation|
|
139
|
-
|
137
|
+
result.merge!(validation.to_openapi_validation(version))
|
140
138
|
end
|
141
139
|
end
|
142
140
|
)
|
@@ -9,18 +9,16 @@ module Jsapi
|
|
9
9
|
##
|
10
10
|
# :attr: maximum
|
11
11
|
# The (exclusive) maximum.
|
12
|
-
attribute :maximum
|
12
|
+
attribute :maximum, accessors: %i[reader]
|
13
13
|
|
14
14
|
##
|
15
15
|
# :attr: minimum
|
16
16
|
# The (exclusive) minimum.
|
17
|
-
attribute :minimum
|
17
|
+
attribute :minimum, accessors: %i[reader]
|
18
18
|
|
19
19
|
##
|
20
20
|
# :attr: multiple_of
|
21
|
-
attribute :multiple_of
|
22
|
-
|
23
|
-
undef maximum=, minimum=, multiple_of=
|
21
|
+
attribute :multiple_of, accessors: %i[reader]
|
24
22
|
|
25
23
|
def maximum=(value) # :nodoc:
|
26
24
|
boundary = Boundary.from(value)
|
@@ -24,15 +24,13 @@ module Jsapi
|
|
24
24
|
##
|
25
25
|
# :attr: model
|
26
26
|
# The model class to access nested object parameters by. The default
|
27
|
-
# model class is Model::Base.
|
28
|
-
attribute :model, Class, default: Model::Base
|
27
|
+
# model class is Jsapi::Model::Base.
|
28
|
+
attribute :model, Class, default: Jsapi::Model::Base
|
29
29
|
|
30
30
|
##
|
31
31
|
# :attr: properties
|
32
32
|
# The properties.
|
33
|
-
attribute :properties, { String => Property }
|
34
|
-
|
35
|
-
undef add_property
|
33
|
+
attribute :properties, { String => Property }, accessors: %i[reader writer]
|
36
34
|
|
37
35
|
def add_property(name, keywords = {}) # :nodoc:
|
38
36
|
(@properties ||= {})[name.to_s] = Property.new(name, **keywords)
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
module Schema
|
6
|
-
|
6
|
+
# Refers a reusable schema.
|
7
|
+
class Reference < Model::Reference
|
7
8
|
##
|
8
9
|
# :attr: existence
|
9
10
|
# The level of Existence. The default level of existence is +ALLOW_OMITTED+.
|
@@ -21,12 +22,11 @@ module Jsapi
|
|
21
22
|
{ '$ref': "#/definitions/#{ref}" }
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
def to_openapi(version, *)
|
26
|
-
version = OpenAPI::Version.from(version)
|
27
|
-
path = version.major == 2 ? 'definitions' : 'components/schemas'
|
25
|
+
private
|
28
26
|
|
29
|
-
|
27
|
+
# Overrides Model::Reference#openapi_components_path.
|
28
|
+
def openapi_components_path(version)
|
29
|
+
version.major == 2 ? 'definitions' : super
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -14,19 +14,17 @@ module Jsapi
|
|
14
14
|
##
|
15
15
|
# :attr: max_length
|
16
16
|
# The maximum length of a string.
|
17
|
-
attribute :max_length
|
17
|
+
attribute :max_length, accessors: %i[reader]
|
18
18
|
|
19
19
|
##
|
20
20
|
# :attr: min_length
|
21
21
|
# The minimum length of a string.
|
22
|
-
attribute :min_length
|
22
|
+
attribute :min_length, accessors: %i[reader]
|
23
23
|
|
24
24
|
##
|
25
25
|
# :attr: pattern
|
26
26
|
# The regular expression a string must match.
|
27
|
-
attribute :pattern
|
28
|
-
|
29
|
-
undef max_length=, min_length=, pattern=
|
27
|
+
attribute :pattern, accessors: %i[reader]
|
30
28
|
|
31
29
|
def max_length=(value) # :nodoc:
|
32
30
|
add_validation('max_length', Validation::MaxLength.new(value))
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
|
-
# Specifies a security requirement
|
6
|
-
class SecurityRequirement < Base
|
7
|
-
class Scheme < Base
|
5
|
+
# Specifies a security requirement.
|
6
|
+
class SecurityRequirement < Model::Base
|
7
|
+
class Scheme < Model::Base
|
8
8
|
##
|
9
9
|
# :attr: scopes
|
10
10
|
# The array of scopes.
|
data/lib/jsapi/meta/server.rb
CHANGED
data/lib/jsapi/meta/tag.rb
CHANGED
data/lib/jsapi/meta.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'meta/reference_error'
|
|
4
4
|
require_relative 'meta/callable'
|
5
5
|
require_relative 'meta/existence'
|
6
6
|
require_relative 'meta/openapi'
|
7
|
-
require_relative 'meta/
|
7
|
+
require_relative 'meta/model'
|
8
8
|
require_relative 'meta/defaults'
|
9
9
|
require_relative 'meta/example'
|
10
10
|
require_relative 'meta/external_documentation'
|
data/lib/jsapi/version.rb
CHANGED
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: 0
|
4
|
+
version: '1.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: 2024-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: denis@dmgoeller.de
|
@@ -50,50 +50,49 @@ files:
|
|
50
50
|
- lib/jsapi/json/string.rb
|
51
51
|
- lib/jsapi/json/value.rb
|
52
52
|
- lib/jsapi/meta.rb
|
53
|
-
- lib/jsapi/meta/base.rb
|
54
|
-
- lib/jsapi/meta/base/attributes.rb
|
55
|
-
- lib/jsapi/meta/base/model.rb
|
56
|
-
- lib/jsapi/meta/base/reference.rb
|
57
|
-
- lib/jsapi/meta/base/type_caster.rb
|
58
53
|
- lib/jsapi/meta/callable.rb
|
59
54
|
- lib/jsapi/meta/callable/symbol_evaluator.rb
|
60
55
|
- lib/jsapi/meta/callable/symbol_sequence_evaluator.rb
|
61
56
|
- lib/jsapi/meta/callback.rb
|
62
|
-
- lib/jsapi/meta/callback/
|
57
|
+
- lib/jsapi/meta/callback/base.rb
|
63
58
|
- lib/jsapi/meta/callback/reference.rb
|
64
59
|
- lib/jsapi/meta/contact.rb
|
65
60
|
- lib/jsapi/meta/defaults.rb
|
66
61
|
- lib/jsapi/meta/definitions.rb
|
67
62
|
- lib/jsapi/meta/example.rb
|
68
|
-
- lib/jsapi/meta/example/
|
63
|
+
- lib/jsapi/meta/example/base.rb
|
69
64
|
- lib/jsapi/meta/example/reference.rb
|
70
65
|
- lib/jsapi/meta/existence.rb
|
71
66
|
- lib/jsapi/meta/external_documentation.rb
|
72
67
|
- lib/jsapi/meta/header.rb
|
73
|
-
- lib/jsapi/meta/header/
|
68
|
+
- lib/jsapi/meta/header/base.rb
|
74
69
|
- lib/jsapi/meta/header/reference.rb
|
75
70
|
- lib/jsapi/meta/info.rb
|
76
71
|
- lib/jsapi/meta/license.rb
|
77
72
|
- lib/jsapi/meta/link.rb
|
78
|
-
- lib/jsapi/meta/link/
|
73
|
+
- lib/jsapi/meta/link/base.rb
|
79
74
|
- lib/jsapi/meta/link/reference.rb
|
75
|
+
- lib/jsapi/meta/model.rb
|
76
|
+
- lib/jsapi/meta/model/attributes.rb
|
77
|
+
- lib/jsapi/meta/model/base.rb
|
78
|
+
- lib/jsapi/meta/model/reference.rb
|
79
|
+
- lib/jsapi/meta/model/type_caster.rb
|
80
80
|
- lib/jsapi/meta/oauth_flow.rb
|
81
81
|
- lib/jsapi/meta/openapi.rb
|
82
82
|
- lib/jsapi/meta/openapi/extensions.rb
|
83
83
|
- lib/jsapi/meta/openapi/version.rb
|
84
84
|
- lib/jsapi/meta/operation.rb
|
85
85
|
- lib/jsapi/meta/parameter.rb
|
86
|
-
- lib/jsapi/meta/parameter/
|
86
|
+
- lib/jsapi/meta/parameter/base.rb
|
87
87
|
- lib/jsapi/meta/parameter/reference.rb
|
88
|
-
- lib/jsapi/meta/parameter/to_openapi.rb
|
89
88
|
- lib/jsapi/meta/property.rb
|
90
89
|
- lib/jsapi/meta/reference_error.rb
|
91
90
|
- lib/jsapi/meta/request_body.rb
|
92
|
-
- lib/jsapi/meta/request_body/
|
91
|
+
- lib/jsapi/meta/request_body/base.rb
|
93
92
|
- lib/jsapi/meta/request_body/reference.rb
|
94
93
|
- lib/jsapi/meta/rescue_handler.rb
|
95
94
|
- lib/jsapi/meta/response.rb
|
96
|
-
- lib/jsapi/meta/response/
|
95
|
+
- lib/jsapi/meta/response/base.rb
|
97
96
|
- lib/jsapi/meta/response/reference.rb
|
98
97
|
- lib/jsapi/meta/schema.rb
|
99
98
|
- lib/jsapi/meta/schema/additional_properties.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module Base
|
6
|
-
# The base reference class.
|
7
|
-
class Reference < Model
|
8
|
-
##
|
9
|
-
# :attr: ref
|
10
|
-
# The name of the referred object.
|
11
|
-
attribute :ref, String
|
12
|
-
|
13
|
-
# Derrives the component type from the inner most module name.
|
14
|
-
def self.component_type
|
15
|
-
@component_type ||= name.split('::')[-2].underscore
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns true.
|
19
|
-
def reference?
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
|
-
# Resolves +ref+ by looking up the object with that name in +definitions+.
|
24
|
-
#
|
25
|
-
# Raises a ReferenceError if +ref+ could not be resolved.
|
26
|
-
def resolve(definitions)
|
27
|
-
object = definitions.send("find_#{self.class.component_type}", ref)
|
28
|
-
raise ReferenceError, ref if object.nil?
|
29
|
-
|
30
|
-
object.resolve(definitions)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/jsapi/meta/base.rb
DELETED