jsapi 0.8.0 → 0.9.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/base.rb +55 -0
- data/lib/jsapi/dsl/callback.rb +21 -0
- data/lib/jsapi/dsl/class_methods.rb +116 -10
- data/lib/jsapi/dsl/definitions.rb +173 -33
- data/lib/jsapi/dsl/examples.rb +30 -0
- data/lib/jsapi/dsl/operation.rb +60 -32
- data/lib/jsapi/dsl/parameter.rb +2 -2
- data/lib/jsapi/dsl/request_body.rb +2 -2
- data/lib/jsapi/dsl/response.rb +35 -11
- data/lib/jsapi/dsl/schema.rb +16 -16
- data/lib/jsapi/dsl.rb +4 -4
- data/lib/jsapi/meta/base/attributes.rb +21 -19
- data/lib/jsapi/meta/base/model.rb +15 -7
- data/lib/jsapi/meta/callback/model.rb +34 -0
- data/lib/jsapi/meta/callback/reference.rb +14 -0
- data/lib/jsapi/meta/callback.rb +19 -0
- data/lib/jsapi/meta/contact.rb +30 -0
- data/lib/jsapi/meta/defaults.rb +2 -2
- data/lib/jsapi/meta/definitions.rb +230 -124
- data/lib/jsapi/meta/example/model.rb +43 -0
- data/lib/jsapi/meta/example/reference.rb +14 -0
- data/lib/jsapi/meta/example.rb +19 -0
- data/lib/jsapi/meta/external_documentation.rb +25 -0
- data/lib/jsapi/meta/header/model.rb +81 -0
- data/lib/jsapi/meta/header/reference.rb +14 -0
- data/lib/jsapi/meta/header.rb +19 -0
- data/lib/jsapi/meta/info.rb +52 -0
- data/lib/jsapi/meta/license.rb +25 -0
- data/lib/jsapi/meta/link/model.rb +48 -0
- data/lib/jsapi/meta/link/reference.rb +14 -0
- data/lib/jsapi/meta/link.rb +19 -0
- data/lib/jsapi/meta/oauth_flow.rb +52 -0
- data/lib/jsapi/meta/openapi.rb +0 -28
- data/lib/jsapi/meta/operation.rb +19 -18
- data/lib/jsapi/meta/parameter/model.rb +6 -4
- data/lib/jsapi/meta/parameter/reference.rb +6 -4
- data/lib/jsapi/meta/parameter/to_openapi.rb +13 -0
- data/lib/jsapi/meta/parameter.rb +2 -1
- data/lib/jsapi/meta/property.rb +1 -1
- data/lib/jsapi/meta/request_body/model.rb +6 -5
- data/lib/jsapi/meta/request_body.rb +1 -1
- data/lib/jsapi/meta/response/model.rb +16 -13
- data/lib/jsapi/meta/response.rb +1 -1
- data/lib/jsapi/meta/schema/array.rb +1 -1
- data/lib/jsapi/meta/schema/base.rb +5 -5
- data/lib/jsapi/meta/schema/discriminator.rb +2 -2
- data/lib/jsapi/meta/schema/object.rb +3 -3
- data/lib/jsapi/meta/schema/reference.rb +1 -1
- data/lib/jsapi/meta/schema.rb +2 -2
- data/lib/jsapi/meta/security_requirement.rb +25 -0
- data/lib/jsapi/meta/security_scheme/api_key.rb +38 -0
- data/lib/jsapi/meta/security_scheme/base.rb +14 -0
- data/lib/jsapi/meta/security_scheme/http/basic.rb +34 -0
- data/lib/jsapi/meta/security_scheme/http/bearer.rb +36 -0
- data/lib/jsapi/meta/security_scheme/http/other.rb +36 -0
- data/lib/jsapi/meta/security_scheme/http.rb +29 -0
- data/lib/jsapi/meta/security_scheme/oauth2.rb +44 -0
- data/lib/jsapi/meta/security_scheme/open_id_connect.rb +32 -0
- data/lib/jsapi/meta/security_scheme.rb +49 -0
- data/lib/jsapi/meta/server.rb +34 -0
- data/lib/jsapi/meta/server_variable.rb +34 -0
- data/lib/jsapi/meta/tag.rb +34 -0
- data/lib/jsapi/meta.rb +15 -1
- data/lib/jsapi/model/base.rb +5 -5
- data/lib/jsapi/version.rb +1 -1
- metadata +38 -42
- data/lib/jsapi/dsl/node.rb +0 -62
- data/lib/jsapi/dsl/openapi/callback.rb +0 -23
- data/lib/jsapi/dsl/openapi/callbacks.rb +0 -34
- data/lib/jsapi/dsl/openapi/examples.rb +0 -32
- data/lib/jsapi/dsl/openapi/root.rb +0 -126
- data/lib/jsapi/dsl/openapi.rb +0 -6
- data/lib/jsapi/meta/openapi/callback/model.rb +0 -34
- data/lib/jsapi/meta/openapi/callback/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/callback.rb +0 -21
- data/lib/jsapi/meta/openapi/contact.rb +0 -32
- data/lib/jsapi/meta/openapi/example/model.rb +0 -44
- data/lib/jsapi/meta/openapi/example/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/example.rb +0 -21
- data/lib/jsapi/meta/openapi/external_documentation.rb +0 -27
- data/lib/jsapi/meta/openapi/header/model.rb +0 -82
- data/lib/jsapi/meta/openapi/header/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/header.rb +0 -21
- data/lib/jsapi/meta/openapi/info.rb +0 -54
- data/lib/jsapi/meta/openapi/license.rb +0 -27
- data/lib/jsapi/meta/openapi/link/model.rb +0 -50
- data/lib/jsapi/meta/openapi/link/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/link.rb +0 -21
- data/lib/jsapi/meta/openapi/oauth_flow.rb +0 -52
- data/lib/jsapi/meta/openapi/root.rb +0 -132
- data/lib/jsapi/meta/openapi/security_requirement.rb +0 -27
- data/lib/jsapi/meta/openapi/security_scheme/api_key.rb +0 -40
- data/lib/jsapi/meta/openapi/security_scheme/base.rb +0 -16
- data/lib/jsapi/meta/openapi/security_scheme/http/basic.rb +0 -36
- data/lib/jsapi/meta/openapi/security_scheme/http/bearer.rb +0 -39
- data/lib/jsapi/meta/openapi/security_scheme/http/other.rb +0 -39
- data/lib/jsapi/meta/openapi/security_scheme/http.rb +0 -31
- data/lib/jsapi/meta/openapi/security_scheme/oauth2.rb +0 -46
- data/lib/jsapi/meta/openapi/security_scheme/open_id_connect.rb +0 -34
- data/lib/jsapi/meta/openapi/security_scheme.rb +0 -51
- data/lib/jsapi/meta/openapi/server.rb +0 -36
- data/lib/jsapi/meta/openapi/server_variable.rb +0 -36
- data/lib/jsapi/meta/openapi/tag.rb +0 -36
data/lib/jsapi/model/base.rb
CHANGED
@@ -50,11 +50,6 @@ module Jsapi
|
|
50
50
|
"#{attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')}>"
|
51
51
|
end
|
52
52
|
|
53
|
-
def method_missing(*args) # :nodoc:
|
54
|
-
name = args.first.to_s
|
55
|
-
_attr_readers.key?(name) ? _attr_readers[name] : super
|
56
|
-
end
|
57
|
-
|
58
53
|
def respond_to_missing?(param1, _param2) # :nodoc:
|
59
54
|
_attr_readers.key?(param1.to_s) ? true : super
|
60
55
|
end
|
@@ -68,6 +63,11 @@ module Jsapi
|
|
68
63
|
def _nested_validity
|
69
64
|
@nested.validate(errors)
|
70
65
|
end
|
66
|
+
|
67
|
+
def method_missing(*args) # :nodoc:
|
68
|
+
name = args.first.to_s
|
69
|
+
_attr_readers.key?(name) ? _attr_readers[name] : super
|
70
|
+
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/lib/jsapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.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-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
documents
|
13
|
+
description:
|
15
14
|
email: denis@dmgoeller.de
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
@@ -26,15 +25,12 @@ files:
|
|
26
25
|
- lib/jsapi/controller/parameters_invalid.rb
|
27
26
|
- lib/jsapi/controller/response.rb
|
28
27
|
- lib/jsapi/dsl.rb
|
28
|
+
- lib/jsapi/dsl/base.rb
|
29
|
+
- lib/jsapi/dsl/callback.rb
|
29
30
|
- lib/jsapi/dsl/class_methods.rb
|
30
31
|
- lib/jsapi/dsl/definitions.rb
|
31
32
|
- lib/jsapi/dsl/error.rb
|
32
|
-
- lib/jsapi/dsl/
|
33
|
-
- lib/jsapi/dsl/openapi.rb
|
34
|
-
- lib/jsapi/dsl/openapi/callback.rb
|
35
|
-
- lib/jsapi/dsl/openapi/callbacks.rb
|
36
|
-
- lib/jsapi/dsl/openapi/examples.rb
|
37
|
-
- lib/jsapi/dsl/openapi/root.rb
|
33
|
+
- lib/jsapi/dsl/examples.rb
|
38
34
|
- lib/jsapi/dsl/operation.rb
|
39
35
|
- lib/jsapi/dsl/parameter.rb
|
40
36
|
- lib/jsapi/dsl/request_body.rb
|
@@ -61,47 +57,34 @@ files:
|
|
61
57
|
- lib/jsapi/meta/callable.rb
|
62
58
|
- lib/jsapi/meta/callable/symbol_evaluator.rb
|
63
59
|
- lib/jsapi/meta/callable/symbol_sequence_evaluator.rb
|
60
|
+
- lib/jsapi/meta/callback.rb
|
61
|
+
- lib/jsapi/meta/callback/model.rb
|
62
|
+
- lib/jsapi/meta/callback/reference.rb
|
63
|
+
- lib/jsapi/meta/contact.rb
|
64
64
|
- lib/jsapi/meta/defaults.rb
|
65
65
|
- lib/jsapi/meta/definitions.rb
|
66
|
+
- lib/jsapi/meta/example.rb
|
67
|
+
- lib/jsapi/meta/example/model.rb
|
68
|
+
- lib/jsapi/meta/example/reference.rb
|
66
69
|
- lib/jsapi/meta/existence.rb
|
70
|
+
- lib/jsapi/meta/external_documentation.rb
|
71
|
+
- lib/jsapi/meta/header.rb
|
72
|
+
- lib/jsapi/meta/header/model.rb
|
73
|
+
- lib/jsapi/meta/header/reference.rb
|
74
|
+
- lib/jsapi/meta/info.rb
|
75
|
+
- lib/jsapi/meta/license.rb
|
76
|
+
- lib/jsapi/meta/link.rb
|
77
|
+
- lib/jsapi/meta/link/model.rb
|
78
|
+
- lib/jsapi/meta/link/reference.rb
|
79
|
+
- lib/jsapi/meta/oauth_flow.rb
|
67
80
|
- lib/jsapi/meta/openapi.rb
|
68
|
-
- lib/jsapi/meta/openapi/callback.rb
|
69
|
-
- lib/jsapi/meta/openapi/callback/model.rb
|
70
|
-
- lib/jsapi/meta/openapi/callback/reference.rb
|
71
|
-
- lib/jsapi/meta/openapi/contact.rb
|
72
|
-
- lib/jsapi/meta/openapi/example.rb
|
73
|
-
- lib/jsapi/meta/openapi/example/model.rb
|
74
|
-
- lib/jsapi/meta/openapi/example/reference.rb
|
75
81
|
- lib/jsapi/meta/openapi/extensions.rb
|
76
|
-
- lib/jsapi/meta/openapi/external_documentation.rb
|
77
|
-
- lib/jsapi/meta/openapi/header.rb
|
78
|
-
- lib/jsapi/meta/openapi/header/model.rb
|
79
|
-
- lib/jsapi/meta/openapi/header/reference.rb
|
80
|
-
- lib/jsapi/meta/openapi/info.rb
|
81
|
-
- lib/jsapi/meta/openapi/license.rb
|
82
|
-
- lib/jsapi/meta/openapi/link.rb
|
83
|
-
- lib/jsapi/meta/openapi/link/model.rb
|
84
|
-
- lib/jsapi/meta/openapi/link/reference.rb
|
85
|
-
- lib/jsapi/meta/openapi/oauth_flow.rb
|
86
|
-
- lib/jsapi/meta/openapi/root.rb
|
87
|
-
- lib/jsapi/meta/openapi/security_requirement.rb
|
88
|
-
- lib/jsapi/meta/openapi/security_scheme.rb
|
89
|
-
- lib/jsapi/meta/openapi/security_scheme/api_key.rb
|
90
|
-
- lib/jsapi/meta/openapi/security_scheme/base.rb
|
91
|
-
- lib/jsapi/meta/openapi/security_scheme/http.rb
|
92
|
-
- lib/jsapi/meta/openapi/security_scheme/http/basic.rb
|
93
|
-
- lib/jsapi/meta/openapi/security_scheme/http/bearer.rb
|
94
|
-
- lib/jsapi/meta/openapi/security_scheme/http/other.rb
|
95
|
-
- lib/jsapi/meta/openapi/security_scheme/oauth2.rb
|
96
|
-
- lib/jsapi/meta/openapi/security_scheme/open_id_connect.rb
|
97
|
-
- lib/jsapi/meta/openapi/server.rb
|
98
|
-
- lib/jsapi/meta/openapi/server_variable.rb
|
99
|
-
- lib/jsapi/meta/openapi/tag.rb
|
100
82
|
- lib/jsapi/meta/openapi/version.rb
|
101
83
|
- lib/jsapi/meta/operation.rb
|
102
84
|
- lib/jsapi/meta/parameter.rb
|
103
85
|
- lib/jsapi/meta/parameter/model.rb
|
104
86
|
- lib/jsapi/meta/parameter/reference.rb
|
87
|
+
- lib/jsapi/meta/parameter/to_openapi.rb
|
105
88
|
- lib/jsapi/meta/property.rb
|
106
89
|
- lib/jsapi/meta/reference_error.rb
|
107
90
|
- lib/jsapi/meta/request_body.rb
|
@@ -137,6 +120,19 @@ files:
|
|
137
120
|
- lib/jsapi/meta/schema/validation/minimum.rb
|
138
121
|
- lib/jsapi/meta/schema/validation/multiple_of.rb
|
139
122
|
- lib/jsapi/meta/schema/validation/pattern.rb
|
123
|
+
- lib/jsapi/meta/security_requirement.rb
|
124
|
+
- lib/jsapi/meta/security_scheme.rb
|
125
|
+
- lib/jsapi/meta/security_scheme/api_key.rb
|
126
|
+
- lib/jsapi/meta/security_scheme/base.rb
|
127
|
+
- lib/jsapi/meta/security_scheme/http.rb
|
128
|
+
- lib/jsapi/meta/security_scheme/http/basic.rb
|
129
|
+
- lib/jsapi/meta/security_scheme/http/bearer.rb
|
130
|
+
- lib/jsapi/meta/security_scheme/http/other.rb
|
131
|
+
- lib/jsapi/meta/security_scheme/oauth2.rb
|
132
|
+
- lib/jsapi/meta/security_scheme/open_id_connect.rb
|
133
|
+
- lib/jsapi/meta/server.rb
|
134
|
+
- lib/jsapi/meta/server_variable.rb
|
135
|
+
- lib/jsapi/meta/tag.rb
|
140
136
|
- lib/jsapi/model.rb
|
141
137
|
- lib/jsapi/model/base.rb
|
142
138
|
- lib/jsapi/model/error.rb
|
@@ -167,5 +163,5 @@ requirements: []
|
|
167
163
|
rubygems_version: 3.5.6
|
168
164
|
signing_key:
|
169
165
|
specification_version: 4
|
170
|
-
summary:
|
166
|
+
summary: Easily build OpenAPI compliant APIs with Rails.
|
171
167
|
test_files: []
|
data/lib/jsapi/dsl/node.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module DSL
|
5
|
-
class Node
|
6
|
-
def initialize(meta_model, &block)
|
7
|
-
@_meta_model = meta_model
|
8
|
-
instance_eval(&block) if block
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(*args, &block) # :nodoc:
|
12
|
-
_keyword(*args, &block)
|
13
|
-
end
|
14
|
-
|
15
|
-
def respond_to_missing?(*args) # :nodoc:
|
16
|
-
_keyword?(args.first)
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :_meta_model
|
22
|
-
|
23
|
-
def _define(*args, &block)
|
24
|
-
block.call
|
25
|
-
rescue Error => e
|
26
|
-
raise e.prepend_origin(args.compact.join(' '))
|
27
|
-
rescue StandardError => e
|
28
|
-
raise Error.new(e, args.compact.join(' ').presence)
|
29
|
-
end
|
30
|
-
|
31
|
-
def _eval(model, klass = Node, &block)
|
32
|
-
return unless block
|
33
|
-
|
34
|
-
if model.reference?
|
35
|
-
raise Error, 'reference cannot be specified together with a block'
|
36
|
-
end
|
37
|
-
|
38
|
-
klass.new(model, &block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def _find_method(name)
|
42
|
-
["#{name}=", "add_#{name}"].find do |method|
|
43
|
-
_meta_model.respond_to?(method)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def _keyword(name, *params, &block)
|
48
|
-
method = _find_method(name)
|
49
|
-
raise "unsupported method: #{name}" unless method
|
50
|
-
|
51
|
-
_define(name) do
|
52
|
-
value = _meta_model.public_send(method, *params)
|
53
|
-
_eval(value, &block)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def _keyword?(name)
|
58
|
-
_find_method(name).present?
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module DSL
|
5
|
-
module OpenAPI
|
6
|
-
# Used to specify details of a callback.
|
7
|
-
class Callback < Node
|
8
|
-
|
9
|
-
# Adds a callback operation.
|
10
|
-
#
|
11
|
-
# operation '{$request.query.foo}' do
|
12
|
-
# parameter 'bar', type: 'string'
|
13
|
-
# end
|
14
|
-
def operation(expression, **keywords, &block)
|
15
|
-
_define('operation', expression.inspect) do
|
16
|
-
operation_model = _meta_model.add_operation(expression, keywords)
|
17
|
-
Operation.new(operation_model, &block) if block
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module DSL
|
5
|
-
module OpenAPI
|
6
|
-
module Callbacks
|
7
|
-
# Defines an \OpenAPI callback or refers a reusable callback.
|
8
|
-
#
|
9
|
-
# # define a callback
|
10
|
-
# callback 'foo' do
|
11
|
-
# operation '{$request.query.foo}'
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# # refer a reusable callback
|
15
|
-
# callback ref: 'foo'
|
16
|
-
#
|
17
|
-
# Refers the reusable callback with the same name if neither any
|
18
|
-
# keywords nor a block is specified.
|
19
|
-
#
|
20
|
-
# callback 'foo'
|
21
|
-
#
|
22
|
-
def callback(name = nil, **keywords, &block)
|
23
|
-
_define('callback', name&.inspect) do
|
24
|
-
name = keywords[:ref] if name.nil?
|
25
|
-
keywords = { ref: name } unless keywords.any? || block
|
26
|
-
|
27
|
-
callback_model = _meta_model.add_callback(name, keywords)
|
28
|
-
_eval(callback_model, OpenAPI::Callback, &block)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module DSL
|
5
|
-
module OpenAPI
|
6
|
-
module Examples
|
7
|
-
# Adds an example.
|
8
|
-
#
|
9
|
-
# example 'foo', value: 'bar'
|
10
|
-
#
|
11
|
-
# example 'foo'
|
12
|
-
#
|
13
|
-
# The default name is <code>'default'</code>.
|
14
|
-
def example(name_or_value = nil, **keywords, &block)
|
15
|
-
_define('example', name_or_value&.inspect) do
|
16
|
-
if keywords.any? || block
|
17
|
-
# example 'foo', value: 'bar', ...
|
18
|
-
name = name_or_value
|
19
|
-
else
|
20
|
-
# example 'foo'
|
21
|
-
name = nil
|
22
|
-
keywords = { value: name_or_value }
|
23
|
-
end
|
24
|
-
|
25
|
-
example = _meta_model.add_example(name, keywords)
|
26
|
-
Node.new(example, &block) if block
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module DSL
|
5
|
-
module OpenAPI
|
6
|
-
# Used to specify details of an \OpenAPI object.
|
7
|
-
class Root < Node
|
8
|
-
include Callbacks
|
9
|
-
|
10
|
-
##
|
11
|
-
# :method: base_path
|
12
|
-
# :args: arg
|
13
|
-
# Specifies the base path of the API.
|
14
|
-
#
|
15
|
-
# base_path '/foo'
|
16
|
-
#
|
17
|
-
# See Meta::OpenAPI::Root#base_path for further information.
|
18
|
-
|
19
|
-
##
|
20
|
-
# :method: consumes
|
21
|
-
# :args: mime_types
|
22
|
-
# Specifies one or more MIME types the API can consume.
|
23
|
-
#
|
24
|
-
# consumes 'application/json'
|
25
|
-
#
|
26
|
-
# consumes %w[application/json application/pdf]
|
27
|
-
#
|
28
|
-
# See Meta::OpenAPI::Root#consumes for further information.
|
29
|
-
|
30
|
-
##
|
31
|
-
# :method: external_docs
|
32
|
-
# :args: **keywords, &block
|
33
|
-
# Specifies the external documentation.
|
34
|
-
#
|
35
|
-
# external_docs url: 'https://foo.bar'
|
36
|
-
#
|
37
|
-
# See Meta::OpenAPI::Root#external_docs for further information.
|
38
|
-
|
39
|
-
##
|
40
|
-
# :method: host
|
41
|
-
# :args: arg
|
42
|
-
# Specifies the host serving the API.
|
43
|
-
#
|
44
|
-
# host 'foo.bar'
|
45
|
-
#
|
46
|
-
# See Meta::OpenAPI::Root#host for further information.
|
47
|
-
|
48
|
-
##
|
49
|
-
# :method: info
|
50
|
-
# :args: **keywords, &block
|
51
|
-
# Specifies general information about the API.
|
52
|
-
#
|
53
|
-
# info title: 'foo', version: 1
|
54
|
-
#
|
55
|
-
# See Meta::OpenAPI::Root#info for further information.
|
56
|
-
|
57
|
-
##
|
58
|
-
# :method: link
|
59
|
-
# :args: name, **keywords, &block
|
60
|
-
# Adds a link.
|
61
|
-
#
|
62
|
-
# link 'foo', operation_id: 'bar'
|
63
|
-
#
|
64
|
-
# See Meta::OpenAPI::Root#links for further information.
|
65
|
-
|
66
|
-
##
|
67
|
-
# :method: produces
|
68
|
-
# :args: mime_types
|
69
|
-
# Specifies one or more MIME types the API can produce.
|
70
|
-
#
|
71
|
-
# produces 'application/json'
|
72
|
-
#
|
73
|
-
# produces %w[application/json application/pdf]'
|
74
|
-
#
|
75
|
-
# See Meta::OpenAPI::Root#produces for further information.
|
76
|
-
|
77
|
-
##
|
78
|
-
# :method: scheme
|
79
|
-
# :args: arg
|
80
|
-
# Adds a URI scheme supported by the API.
|
81
|
-
#
|
82
|
-
# scheme 'https'
|
83
|
-
#
|
84
|
-
# See Meta::OpenAPI::Root#scheme for further information.
|
85
|
-
|
86
|
-
##
|
87
|
-
# :method: security_requirement
|
88
|
-
# :args: **keywords, &block
|
89
|
-
# Adds a security requirement.
|
90
|
-
#
|
91
|
-
# security_requirement do
|
92
|
-
# scheme 'basic_auth'
|
93
|
-
# end
|
94
|
-
#
|
95
|
-
# See Meta::OpenAPI::Root#security_requirements for further information.
|
96
|
-
|
97
|
-
##
|
98
|
-
# :method: security_scheme
|
99
|
-
# :args: name, **keywords, &block
|
100
|
-
# Adds a security scheme.
|
101
|
-
#
|
102
|
-
# security_scheme 'basic_auth', type: 'http', scheme: 'basic'
|
103
|
-
#
|
104
|
-
# See Meta::OpenAPI::Root#security_schemes for further information.
|
105
|
-
|
106
|
-
##
|
107
|
-
# :method: server
|
108
|
-
# :args: arg
|
109
|
-
# Adds a server providing the API.
|
110
|
-
#
|
111
|
-
# server url: 'https://foo.bar'
|
112
|
-
#
|
113
|
-
# See Meta::OpenAPI::Root#servers for further information.
|
114
|
-
|
115
|
-
##
|
116
|
-
# :method: tag
|
117
|
-
# :args: **keywords, &block
|
118
|
-
# Adds a tag.
|
119
|
-
#
|
120
|
-
# tag name: 'foo', description: 'description of foo'
|
121
|
-
#
|
122
|
-
# See Meta::OpenAPI::Root#tags for further information.
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
data/lib/jsapi/dsl/openapi.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
module Callback
|
7
|
-
# Represents a callback object. Applies to \OpenAPI 3.0 and higher.
|
8
|
-
class Model < Meta::Base::Model
|
9
|
-
##
|
10
|
-
# :attr: operations
|
11
|
-
attribute :operations, { String => Object }, default: {}
|
12
|
-
|
13
|
-
undef add_operation
|
14
|
-
|
15
|
-
# Adds a callback operation.
|
16
|
-
#
|
17
|
-
# Raises an +ArgumentError+ if +expression+ is blank.
|
18
|
-
def add_operation(expression, keywords = {})
|
19
|
-
raise ArgumentError, "expression can't be blank" if expression.blank?
|
20
|
-
|
21
|
-
(@operations ||= {})[expression.to_s] = Operation.new(nil, keywords)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns a hash representing the \OpenAPI callback object.
|
25
|
-
def to_openapi(version, definitions)
|
26
|
-
operations.transform_values do |operation|
|
27
|
-
{ operation.method => operation.to_openapi(version, definitions) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
module Callback
|
7
|
-
class Reference < Meta::Base::Reference
|
8
|
-
# Returns a hash representing the \OpenAPI reference object.
|
9
|
-
def to_openapi(*)
|
10
|
-
{ '$ref': "#/components/callbacks/#{ref}" }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'callback/model'
|
4
|
-
require_relative 'callback/reference'
|
5
|
-
|
6
|
-
module Jsapi
|
7
|
-
module Meta
|
8
|
-
module OpenAPI
|
9
|
-
module Callback
|
10
|
-
class << self
|
11
|
-
# Creates a callback model or reference.
|
12
|
-
def new(keywords = {})
|
13
|
-
return Reference.new(keywords) if keywords.key?(:ref)
|
14
|
-
|
15
|
-
Model.new(keywords)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
# Represents a contact object.
|
7
|
-
class Contact < Meta::Base::Model
|
8
|
-
include Extensions
|
9
|
-
|
10
|
-
##
|
11
|
-
# :attr: email
|
12
|
-
# The email address of the contact.
|
13
|
-
attribute :email, String
|
14
|
-
|
15
|
-
##
|
16
|
-
# :attr: name
|
17
|
-
# The name of the contact.
|
18
|
-
attribute :name, String
|
19
|
-
|
20
|
-
##
|
21
|
-
# :attr: url
|
22
|
-
# The URL of the contact.
|
23
|
-
attribute :url, String
|
24
|
-
|
25
|
-
# Returns a hash representing the \OpenAPI contact object.
|
26
|
-
def to_openapi(*)
|
27
|
-
with_openapi_extensions(name: name, url: url, email: email)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
module Example
|
7
|
-
class Model < Meta::Base::Model
|
8
|
-
include Extensions
|
9
|
-
|
10
|
-
##
|
11
|
-
# :attr: description
|
12
|
-
# The optional description of the example.
|
13
|
-
attribute :description, String
|
14
|
-
|
15
|
-
##
|
16
|
-
# :attr: external
|
17
|
-
# If true, +value+ is interpreted as a URI pointing to an external sample value.
|
18
|
-
attribute :external, values: [true, false]
|
19
|
-
|
20
|
-
##
|
21
|
-
# :attr: summary
|
22
|
-
# The optional summary of the example.
|
23
|
-
attribute :summary, String
|
24
|
-
|
25
|
-
##
|
26
|
-
# :attr: value
|
27
|
-
# The sample value.
|
28
|
-
attribute :value
|
29
|
-
|
30
|
-
# Returns a hash representing the \OpenAPI example object.
|
31
|
-
def to_openapi(*)
|
32
|
-
with_openapi_extensions(summary: summary, description: description).tap do |hash|
|
33
|
-
if external?
|
34
|
-
hash[:external_value] = value
|
35
|
-
else
|
36
|
-
hash[:value] = value
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
module Example
|
7
|
-
class Reference < Meta::Base::Reference
|
8
|
-
# Returns a hash representing the \OpenAPI reference object.
|
9
|
-
def to_openapi(*)
|
10
|
-
{ '$ref': "#/components/examples/#{ref}" }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'example/model'
|
4
|
-
require_relative 'example/reference'
|
5
|
-
|
6
|
-
module Jsapi
|
7
|
-
module Meta
|
8
|
-
module OpenAPI
|
9
|
-
module Example
|
10
|
-
class << self
|
11
|
-
# Creates a new example model or reference.
|
12
|
-
def new(keywords = {})
|
13
|
-
return Reference.new(keywords) if keywords.key?(:ref)
|
14
|
-
|
15
|
-
Model.new(keywords)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jsapi
|
4
|
-
module Meta
|
5
|
-
module OpenAPI
|
6
|
-
# Represents an external documentation object.
|
7
|
-
class ExternalDocumentation < Meta::Base::Model
|
8
|
-
include Extensions
|
9
|
-
|
10
|
-
##
|
11
|
-
# :attr: description
|
12
|
-
# The optional description of the external documentation.
|
13
|
-
attribute :description, String
|
14
|
-
|
15
|
-
##
|
16
|
-
# :attr: url
|
17
|
-
# The URL of the external documentation.
|
18
|
-
attribute :url, String
|
19
|
-
|
20
|
-
# Returns a hash representing the \OpenAPI external documentation object.
|
21
|
-
def to_openapi(*)
|
22
|
-
with_openapi_extensions(url: url, description: description)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|