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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21753e8008242096b9b9f780b264e6826a963d0b3e18ae04a2996ed00426ef6d
4
- data.tar.gz: 5fc2d171c79e6c657358fec5caf57f0fde2adb19a19e95361290725144c9f4b3
3
+ metadata.gz: d1857f5c4388ddb54b06b96eec4dff68b48500010d6fe83c7745074c259e3ba6
4
+ data.tar.gz: 7b8c5bca28e57ee3da6fc6ccb1c032db43b9b1bfb516c23c7cb6be8aed0c2e5c
5
5
  SHA512:
6
- metadata.gz: d345bf12b261d42a34cb0fcfe17345f012218a2eb63bef1b4c132283f3b87fd9285775ab36b246330573f5247515c156e2f76c784f34d790f1cf3ea4ed327d14
7
- data.tar.gz: cbe232fb49e266695f68db6c60fbcf7568ceeae79a15bae9c73c051bd97ab44a255f26edf942fae9fafac99bbe474af9d1dbd0a5075aa344a519e8238a92e2c3
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.8)
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.19)
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(ArgumentError)
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
@@ -10,7 +10,7 @@
10
10
  {
11
11
  "doc": "",
12
12
  "throws": [
13
- "ArgumentError"
13
+ "ReeJson::FromJson::ParseJsonError"
14
14
  ],
15
15
  "return": "Hash",
16
16
  "args": [
@@ -11,4 +11,8 @@ RSpec.describe :from_json do
11
11
  result = from_json("{\":id\":{\"^o\":\"Object\"}}", mode: :object)
12
12
  expect(result[:id]).to be_a(Object)
13
13
  }
14
+
15
+ it {
16
+ expect{from_json("{213: \"123\"}")}.to raise_error(ReeJson::FromJson::ParseJsonError)
17
+ }
14
18
  end
@@ -13,6 +13,7 @@ class ReeSwagger::EndpointDto
13
13
  path: String,
14
14
  caster: Nilor[ReeMapper::Mapper],
15
15
  serializer: Nilor[ReeMapper::Mapper],
16
+ authenticate: Bool,
16
17
  summary: Nilor[String],
17
18
  description: Nilor[String],
18
19
  response_status: Integer,
@@ -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
 
@@ -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)
@@ -26,6 +26,10 @@
26
26
  "arg": "version",
27
27
  "type": "String"
28
28
  },
29
+ {
30
+ "arg": "api_url",
31
+ "type": "String"
32
+ },
29
33
  {
30
34
  "arg": "endpoints",
31
35
  "type": "ArrayOf[ReeSwagger::EndpointDto]"
@@ -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: ''
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.11"
5
5
  end
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.8
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-15 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree