ree_lib 1.0.8 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/lib/ree_lib/packages/ree_http/package/ree_http/functions/build_request_executor.rb +3 -2
- data/lib/ree_lib/packages/ree_json/package/ree_json/functions/from_json.rb +5 -1
- data/lib/ree_lib/packages/ree_json/schemas/ree_json/functions/from_json.schema.json +1 -1
- data/lib/ree_lib/packages/ree_json/spec/ree_json/functions/from_json_spec.rb +4 -0
- data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/dto/endpoint_dto.rb +1 -0
- data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_endpoint_schema.rb +1 -0
- data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_request_body_schema.rb +3 -2
- data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb +12 -2
- data/lib/ree_lib/packages/ree_swagger/schemas/ree_swagger/functions/build_schema.schema.json +4 -0
- data/lib/ree_lib/packages/ree_swagger/spec/functions/build_endpoint_schema_spec.rb +5 -0
- data/lib/ree_lib/packages/ree_swagger/spec/functions/build_schema_spec.rb +17 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1857f5c4388ddb54b06b96eec4dff68b48500010d6fe83c7745074c259e3ba6
|
4
|
+
data.tar.gz: 7b8c5bca28e57ee3da6fc6ccb1c032db43b9b1bfb516c23c7cb6be8aed0c2e5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cedd921b6f53e8d6510f8bf55d52a3414dda9440012277798aa5ff77429c01448520574377e28d36aa6784d6e6dec9509b5830670a6ef1d2c772e430db1dcead
|
7
|
+
data.tar.gz: c1df54e9603fbe776a4ce507bff3379e699592052735ed93caa9078232879b914957e611bdb5098efd1f5440488005cdcb60eaba8a8672559dd7e72f50104282
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ree_lib (1.0.
|
4
|
+
ree_lib (1.0.11)
|
5
5
|
binding_of_caller (~> 1.0.0)
|
6
6
|
i18n (~> 1.12.0)
|
7
7
|
loofah (~> 2.18.0)
|
@@ -36,9 +36,11 @@ GEM
|
|
36
36
|
crass (~> 1.0.2)
|
37
37
|
nokogiri (>= 1.5.9)
|
38
38
|
msgpack (1.5.4)
|
39
|
+
nokogiri (1.13.8-x86_64-darwin)
|
40
|
+
racc (~> 1.4)
|
39
41
|
nokogiri (1.13.8-x86_64-linux)
|
40
42
|
racc (~> 1.4)
|
41
|
-
oj (3.13.
|
43
|
+
oj (3.13.20)
|
42
44
|
pg (1.4.2)
|
43
45
|
public_suffix (4.0.7)
|
44
46
|
racc (1.6.0)
|
@@ -5,7 +5,7 @@ class ReeHttp::BuildRequestExecutor
|
|
5
5
|
|
6
6
|
fn :build_request_executor do
|
7
7
|
link 'ree_http/constants', -> {
|
8
|
-
DEFAULT_TIMEOUT & DEFAULT_WRITE_TIMEOUT & DEFAULT_FORCE_SSL
|
8
|
+
HTTPS & DEFAULT_TIMEOUT & DEFAULT_WRITE_TIMEOUT & DEFAULT_FORCE_SSL
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
@@ -47,7 +47,8 @@ class ReeHttp::BuildRequestExecutor
|
|
47
47
|
request_executor.write_timeout = opts[:write_timeout]
|
48
48
|
request_executor.read_timeout = opts[:timeout]
|
49
49
|
|
50
|
-
request_executor.use_ssl = opts[:force_ssl]
|
50
|
+
request_executor.use_ssl = opts[:force_ssl] || uri.scheme == HTTPS
|
51
|
+
|
51
52
|
|
52
53
|
if opts[:ca_certs?]
|
53
54
|
request_executor = build_ca_certs(request_executor, opts[:ca_certs?])
|
@@ -7,6 +7,8 @@ class ReeJson::FromJson
|
|
7
7
|
}
|
8
8
|
end
|
9
9
|
|
10
|
+
ParseJsonError = Class.new(StandardError)
|
11
|
+
|
10
12
|
contract(
|
11
13
|
Any,
|
12
14
|
Kwargs[
|
@@ -16,7 +18,7 @@ class ReeJson::FromJson
|
|
16
18
|
symbol_keys?: Bool,
|
17
19
|
RestKeys => Any
|
18
20
|
] => Hash
|
19
|
-
).throws(
|
21
|
+
).throws(ParseJsonError)
|
20
22
|
def call(object, mode: :rails, **opts)
|
21
23
|
options = DEFAULT_OPTIONS
|
22
24
|
.dup
|
@@ -25,5 +27,7 @@ class ReeJson::FromJson
|
|
25
27
|
)
|
26
28
|
|
27
29
|
Oj.load(object, options)
|
30
|
+
rescue ArgumentError, EncodingError
|
31
|
+
raise ParseJsonError.new
|
28
32
|
end
|
29
33
|
end
|
data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_endpoint_schema.rb
CHANGED
@@ -112,6 +112,7 @@ class ReeSwagger::BuildEndpointSchema
|
|
112
112
|
|
113
113
|
method_schema[:parameters] = parameters if parameters
|
114
114
|
method_schema[:requestBody] = request_body if request_body
|
115
|
+
method_schema[:security] = [{ ApiKeyAuth: [] }] if endpoint.authenticate
|
115
116
|
|
116
117
|
schema = {endpoint.method => method_schema}
|
117
118
|
|
data/lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_request_body_schema.rb
CHANGED
@@ -38,10 +38,11 @@ class ReeSwagger::BuildRequestBodySchema
|
|
38
38
|
|
39
39
|
return if properties.empty?
|
40
40
|
|
41
|
-
{
|
41
|
+
obj = {
|
42
42
|
type: 'object',
|
43
43
|
properties: properties,
|
44
|
-
required: required_fields
|
45
44
|
}
|
45
|
+
obj[:required] = required_fields if required_fields.size != 0
|
46
|
+
obj
|
46
47
|
end
|
47
48
|
end
|
@@ -8,8 +8,8 @@ class ReeSwagger::BuildSchema
|
|
8
8
|
link 'ree_swagger/dto/endpoint_dto', -> { EndpointDto }
|
9
9
|
end
|
10
10
|
|
11
|
-
contract(String, String, String, ArrayOf[EndpointDto] => Hash)
|
12
|
-
def call(title:, description:, version:, endpoints:)
|
11
|
+
contract(String, String, String, String, ArrayOf[EndpointDto] => Hash)
|
12
|
+
def call(title:, description:, version:, api_url:, endpoints:)
|
13
13
|
{
|
14
14
|
openapi: "3.0.0",
|
15
15
|
info: {
|
@@ -17,6 +17,16 @@ class ReeSwagger::BuildSchema
|
|
17
17
|
description: description,
|
18
18
|
version: version
|
19
19
|
},
|
20
|
+
components: {
|
21
|
+
securitySchemes: {
|
22
|
+
ApiKeyAuth: {
|
23
|
+
type: 'apiKey',
|
24
|
+
in: 'header',
|
25
|
+
name: 'Authorization'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
servers: [{ url: api_url }],
|
20
30
|
paths: endpoints.each_with_object(Hash.new { _1[_2] = {} }) {
|
21
31
|
path_dto = build_endpoint_schema(_1)
|
22
32
|
_2[path_dto.path].merge!(path_dto.schema)
|
@@ -71,6 +71,7 @@ RSpec.describe :build_endpoint_schema do
|
|
71
71
|
schema = build_endpoint_schema(ReeSwagger::EndpointDto.new(
|
72
72
|
method: :post,
|
73
73
|
respond_to: :json,
|
74
|
+
authenticate: false,
|
74
75
|
path: '/versions/:id',
|
75
76
|
sections: ["versions"],
|
76
77
|
caster: caster,
|
@@ -97,6 +98,7 @@ RSpec.describe :build_endpoint_schema do
|
|
97
98
|
csv_schema = build_endpoint_schema(ReeSwagger::EndpointDto.new(
|
98
99
|
method: :get,
|
99
100
|
respond_to: :csv,
|
101
|
+
authenticate: false,
|
100
102
|
path: '/files/:id',
|
101
103
|
sections: ["files"],
|
102
104
|
caster: file_caster,
|
@@ -226,6 +228,7 @@ RSpec.describe :build_endpoint_schema do
|
|
226
228
|
path: '/versions/:id',
|
227
229
|
caster: caster,
|
228
230
|
respond_to: :json,
|
231
|
+
authenticate: false,
|
229
232
|
serializer: nil,
|
230
233
|
response_status: 200,
|
231
234
|
description: nil,
|
@@ -288,6 +291,7 @@ RSpec.describe :build_endpoint_schema do
|
|
288
291
|
method: :get,
|
289
292
|
path: '/versions/:id',
|
290
293
|
respond_to: :json,
|
294
|
+
authenticate: false,
|
291
295
|
caster: nil,
|
292
296
|
serializer: nil,
|
293
297
|
response_status: 200,
|
@@ -311,6 +315,7 @@ RSpec.describe :build_endpoint_schema do
|
|
311
315
|
method: :get,
|
312
316
|
path: '/versions/:id',
|
313
317
|
respond_to: :json,
|
318
|
+
authenticate: false,
|
314
319
|
caster: caster,
|
315
320
|
serializer: nil,
|
316
321
|
response_status: 200,
|
@@ -6,8 +6,10 @@ RSpec.describe :build_schema do
|
|
6
6
|
title: 'Sample API',
|
7
7
|
description: 'Sample API description',
|
8
8
|
version: '0.0.1',
|
9
|
+
api_url: 'https://some-api.com/api/v1',
|
9
10
|
endpoints: [ReeSwagger::EndpointDto.new(
|
10
11
|
method: :get,
|
12
|
+
authenticate: true,
|
11
13
|
path: '/version',
|
12
14
|
respond_to: :json,
|
13
15
|
caster: nil,
|
@@ -27,9 +29,24 @@ RSpec.describe :build_schema do
|
|
27
29
|
description: 'Sample API description',
|
28
30
|
version: '0.0.1'
|
29
31
|
},
|
32
|
+
components: {
|
33
|
+
securitySchemes: {
|
34
|
+
bearerAuth: {
|
35
|
+
type: 'http',
|
36
|
+
scheme: 'bearer',
|
37
|
+
bearerFormat: 'JWT'
|
38
|
+
}
|
39
|
+
}
|
40
|
+
},
|
41
|
+
servers: [
|
42
|
+
{ url: 'https://some-api.com/api/v1' }
|
43
|
+
],
|
30
44
|
paths: {
|
31
45
|
'/version' => {
|
32
46
|
get: {
|
47
|
+
security: [
|
48
|
+
{bearerAuth: []}
|
49
|
+
],
|
33
50
|
responses: {
|
34
51
|
200 => {
|
35
52
|
description: ''
|
data/lib/ree_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ree_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|