grape-starter 2.0.0 → 2.1.0

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: 8d9f7ca7efc30bff48e6f765786b43a6cfd6d2c1c68d93063bbab89c4042bb5d
4
- data.tar.gz: 1ecd2c9a8ce6eeebd94ed79a5e08bb81328c327a361750ca6ae1aff8578281ef
3
+ metadata.gz: 3120d80bd3930bf6d8760f03ef07a3b9ca9330fb2413705fc2330a2120c7a258
4
+ data.tar.gz: 33efe62100801cc5def02818625b7c6e336449009bab66d4ef61f0dfc4b6b45f
5
5
  SHA512:
6
- metadata.gz: baa02a26a233adc4f6edd6afe687356b99d29ef59071a170cf6183fb257be59254d7c2bb2e04bcf63bd67e8978e46c6a261cbb71319340ebeedacee3a8427f22
7
- data.tar.gz: 43a5e2557d01d84bccc0cf91e5d7c52446b86572a2343d19ce2d905172b01b5c83bbf085d04d646e7cf6faf01b5466e0f47912323c32433981b693b5ff1bfad1
6
+ metadata.gz: 60074684dfe1773666cf6c24c373edcd009eec3ab9d0b33c13caa05c5a1f57cb263160f21c28aacefcc0f63c82f0ed4df077bc095dea17f90398319e6d247e83
7
+ data.tar.gz: 9b57425801bce4d43f439fe93600764e5e37d1f3cc08d2c0ce6a5a1298e2304352eb2850ef082a7d23f899e4740c2c0c97dd324e8de28fab86563039cbd2a49e
data/CHANGELOG.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  - contributions
4
4
 
5
+ ### v2.1.0 / 2023-10-21 Imports OApi specs
6
+
7
+ - [(#41)](https://github.com/LeFnord/grape-starter/pull/41) Adds generating of desc block [LeFnord](https://github.com/LeFnord)
8
+
5
9
  ### v2.0.0 / 2023-10-21 Imports OApi specs
6
10
 
7
- - [(#38)](https://github.com/LeFnord/grape-starter/pull/38) Handles nested body [LeFnord](https://github.com/LeFnord)
11
+ - [(#39)](https://github.com/LeFnord/grape-starter/pull/39) Handles nested body [LeFnord](https://github.com/LeFnord)
8
12
  - [(#38)](https://github.com/LeFnord/grape-starter/pull/38) Handle parameters from request body [LeFnord](https://github.com/LeFnord)
9
13
  - [(#37)](https://github.com/LeFnord/grape-starter/pull/37) Ignores possible version segments in path [LeFnord](https://github.com/LeFnord)
10
14
  - Sets min ruby to 3.1 [LeFnord](https://github.com/LeFnord)
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: false
2
+
3
+ module Starter
4
+ module Importer
5
+ class Description
6
+ attr_accessor :content
7
+
8
+ def initialize(content:)
9
+ @content = content
10
+ end
11
+
12
+ def to_s
13
+ return if content.blank?
14
+
15
+ desc = content['summary'] || name
16
+
17
+ entry = "desc '#{desc}' do\n"
18
+ entry << " detail '#{content['description']}'\n" if content.key?('description')
19
+ entry << " tags #{content['tags']}\n" if content.key?('tags')
20
+ entry << 'end'
21
+
22
+ entry
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/AbcSize
1
2
  # frozen_string_literal: false
2
3
 
3
4
  module Starter
@@ -39,10 +40,13 @@ module Starter
39
40
  verbs.keys.each_with_object([]) do |verb, memo|
40
41
  next unless allowed_verbs.include?(verb)
41
42
 
43
+ memo << verbs[verb]['describe'].to_s if verbs[verb]['describe'].present?
44
+
42
45
  if (parameters = verbs[verb]['parameters'].presence)
43
46
  params_block = params_block(parameters)
44
47
  memo << params_block
45
48
  end
49
+
46
50
  memo << "#{verb} '#{segment}' do\n # your code comes here\nend\n"
47
51
  end
48
52
  end
@@ -71,3 +75,5 @@ module Starter
71
75
  end
72
76
  end
73
77
  end
78
+
79
+ # rubocop:enable Metrics/AbcSize
@@ -145,6 +145,8 @@ module Starter
145
145
  entry = definition['required'] ? 'requires' : 'optional'
146
146
  entry << " :#{name}"
147
147
  entry << ", type: #{type}"
148
+ entry << ", default: '#{definition['default']}'" if definition.key?('default') && definition['default'].present?
149
+ entry << ", values: #{definition['enum'].map(&:to_s)}" if definition.key?('enum')
148
150
  doc = documentation
149
151
  entry << ", #{doc}" if doc
150
152
 
@@ -58,7 +58,9 @@ module Starter
58
58
  memo[verb] = content
59
59
  next unless content.key?('parameters') || content.key?('requestBody') || path_params
60
60
 
61
- parameters = ((content['parameters'] || path_params || []) + [content['requestBody']]).compact
61
+ parameters = ((content.delete('parameters') || path_params || []) + [content.delete('requestBody')]).compact
62
+
63
+ memo[verb]['describe'] = Description.new(content: content.except('responses'))
62
64
 
63
65
  memo[verb]['parameters'] = parameters.each_with_object({}) do |definition, para|
64
66
  parameter = Parameter.new(definition:, components:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Starter
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-starter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LeFnord
@@ -118,6 +118,7 @@ files:
118
118
  - lib/starter/config.rb
119
119
  - lib/starter/file_ops.rb
120
120
  - lib/starter/import.rb
121
+ - lib/starter/importer/description.rb
121
122
  - lib/starter/importer/namespace.rb
122
123
  - lib/starter/importer/nested_params.rb
123
124
  - lib/starter/importer/parameter.rb