ree_lib 1.0.9 → 1.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 756ef68a2b67f69d7b39d4877f51bebef0bf9f16c2d826f75a66fa43784ac779
4
- data.tar.gz: f9668ac762030ae0b4e0d53d9edafd7751396b30e4b1f4ae67188b889aef6360
3
+ metadata.gz: 44e1a436822756b530e7f11947c68f43377096b4b15d8c6d60880a8f2116d1b2
4
+ data.tar.gz: cea2b849ec06361e461b282c93632cbcc2131bedfcbf260c87fcca56dfb53539
5
5
  SHA512:
6
- metadata.gz: 7f0f85267b26e8249d4c8c9d46532717acc53a4378e19e20e5f07e2431b751cee6591ac97677ffc528b651fef7428f868a73e9d87ef44103f94a21b412ff5f6d
7
- data.tar.gz: c31dd2b537126f8590b656002f169fbce184448bedc79d4c0c58b7de769a940e5f780a7d73e70595a68966bafda85a13ef73031da79df69808d3eea5fb224352
6
+ metadata.gz: 53f014bef46e41b7f1826ef4487ff0fce03c66b4578a7d6ddd65a37aaa94989aef52523dd368514f1e533b141aac9e9fedc341e4cc14b69dc4a1528482c53ed1
7
+ data.tar.gz: fe75d4036275c8a4013fbb064ced2f61b014c7ccccb5e48b7966e83f22f44adbc47345b37c01c2498f6f1d1dc035a21bf3ffa6a86a9aca0ac85665d8a13ac74b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.9)
4
+ ree_lib (1.0.10)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -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.9"
4
+ VERSION = "1.0.10"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov