smithy 2.0.0.pre0 → 2.0.0.pre1

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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/smithy-ruby +1 -4
  4. data/lib/smithy/command.rb +68 -0
  5. data/lib/smithy/generators/base.rb +19 -0
  6. data/lib/smithy/generators/client.rb +106 -0
  7. data/lib/smithy/generators/schema.rb +61 -0
  8. data/lib/smithy/generators.rb +29 -0
  9. data/lib/smithy/model/flattener.rb +114 -0
  10. data/lib/smithy/model/operation_parser.rb +42 -0
  11. data/lib/smithy/model/rbs.rb +57 -0
  12. data/lib/smithy/model/service_index.rb +51 -0
  13. data/lib/smithy/model/service_parser.rb +74 -0
  14. data/lib/smithy/model/shape.rb +49 -0
  15. data/lib/smithy/model/structure_parser.rb +43 -0
  16. data/lib/smithy/model/yard.rb +100 -0
  17. data/lib/smithy/model.rb +54 -0
  18. data/lib/smithy/plan.rb +79 -3
  19. data/lib/smithy/templates/client/auth_parameters.erb +29 -0
  20. data/lib/smithy/templates/client/auth_parameters_rbs.erb +14 -0
  21. data/lib/smithy/templates/client/auth_plugin.erb +115 -0
  22. data/lib/smithy/templates/client/auth_resolver.erb +16 -0
  23. data/lib/smithy/templates/client/auth_resolver_rbs.erb +5 -0
  24. data/lib/smithy/templates/client/client.erb +142 -0
  25. data/lib/smithy/templates/client/client_rbs.erb +29 -0
  26. data/lib/smithy/templates/client/customizations.erb +3 -0
  27. data/lib/smithy/templates/client/endpoint_parameters.erb +65 -0
  28. data/lib/smithy/templates/client/endpoint_parameters_rbs.erb +13 -0
  29. data/lib/smithy/templates/client/endpoint_plugin.erb +58 -0
  30. data/lib/smithy/templates/client/endpoint_provider.erb +15 -0
  31. data/lib/smithy/templates/client/endpoint_provider_rbs.erb +5 -0
  32. data/lib/smithy/templates/client/endpoint_provider_spec.erb +70 -0
  33. data/lib/smithy/templates/client/errors.erb +69 -0
  34. data/lib/smithy/templates/client/errors_rbs.erb +17 -0
  35. data/lib/smithy/templates/client/gemspec.erb +17 -0
  36. data/lib/smithy/templates/client/module.erb +22 -0
  37. data/lib/smithy/templates/client/module_rbs.erb +7 -0
  38. data/lib/smithy/templates/client/paginators.erb +33 -0
  39. data/lib/smithy/templates/client/protocol_spec.erb +144 -0
  40. data/lib/smithy/templates/client/rubocop_yml.erb +33 -0
  41. data/lib/smithy/templates/client/schema.erb +76 -0
  42. data/lib/smithy/templates/client/schema_rbs.erb +13 -0
  43. data/lib/smithy/templates/client/spec_helper.erb +10 -0
  44. data/lib/smithy/templates/client/types.erb +64 -0
  45. data/lib/smithy/templates/client/types_rbs.erb +47 -0
  46. data/lib/smithy/templates/client/waiters.erb +42 -0
  47. data/lib/smithy/util/hash_formatter.rb +124 -0
  48. data/lib/smithy/util/underscore.rb +18 -0
  49. data/lib/smithy/util.rb +9 -0
  50. data/lib/smithy/views/client/auth_parameter.rb +29 -0
  51. data/lib/smithy/views/client/auth_parameters.rb +23 -0
  52. data/lib/smithy/views/client/auth_parameters_rbs.rb +23 -0
  53. data/lib/smithy/views/client/auth_plugin.rb +35 -0
  54. data/lib/smithy/views/client/auth_resolver.rb +125 -0
  55. data/lib/smithy/views/client/auth_resolver_rbs.rb +19 -0
  56. data/lib/smithy/views/client/client.rb +208 -0
  57. data/lib/smithy/views/client/client_rbs.rb +231 -0
  58. data/lib/smithy/views/client/customizations.rb +10 -0
  59. data/lib/smithy/views/client/endpoint_parameter.rb +156 -0
  60. data/lib/smithy/views/client/endpoint_parameters.rb +43 -0
  61. data/lib/smithy/views/client/endpoint_parameters_rbs.rb +28 -0
  62. data/lib/smithy/views/client/endpoint_plugin.rb +27 -0
  63. data/lib/smithy/views/client/endpoint_provider.rb +241 -0
  64. data/lib/smithy/views/client/endpoint_provider_rbs.rb +19 -0
  65. data/lib/smithy/views/client/endpoint_provider_spec.rb +137 -0
  66. data/lib/smithy/views/client/errors.rb +88 -0
  67. data/lib/smithy/views/client/errors_rbs.rb +12 -0
  68. data/lib/smithy/views/client/gemspec.rb +36 -0
  69. data/lib/smithy/views/client/module.rb +107 -0
  70. data/lib/smithy/views/client/module_rbs.rb +20 -0
  71. data/lib/smithy/views/client/operation_examples.rb +157 -0
  72. data/lib/smithy/views/client/paginators.rb +108 -0
  73. data/lib/smithy/views/client/plugin.rb +29 -0
  74. data/lib/smithy/views/client/plugin_list.rb +57 -0
  75. data/lib/smithy/views/client/protocol_spec.rb +254 -0
  76. data/lib/smithy/views/client/request_response_example.rb +179 -0
  77. data/lib/smithy/views/client/rubocop_yml.rb +19 -0
  78. data/lib/smithy/views/client/schema.rb +356 -0
  79. data/lib/smithy/views/client/schema_rbs.rb +84 -0
  80. data/lib/smithy/views/client/shape_to_hash.rb +99 -0
  81. data/lib/smithy/views/client/spec_helper.rb +19 -0
  82. data/lib/smithy/views/client/types.rb +293 -0
  83. data/lib/smithy/views/client/types_rbs.rb +67 -0
  84. data/lib/smithy/views/client/waiters.rb +82 -0
  85. data/lib/smithy/views/client.rb +47 -0
  86. data/lib/smithy/views/view.rb +30 -0
  87. data/lib/smithy/views.rb +9 -0
  88. data/lib/smithy/weld.rb +109 -0
  89. data/lib/smithy/welds/auth/anonymous_auth.rb +31 -0
  90. data/lib/smithy/welds/auth/http_api_key_auth.rb +34 -0
  91. data/lib/smithy/welds/auth/http_basic_auth.rb +34 -0
  92. data/lib/smithy/welds/auth/http_bearer_auth.rb +34 -0
  93. data/lib/smithy/welds/auth/http_digest_auth.rb +34 -0
  94. data/lib/smithy/welds/plugins.rb +54 -0
  95. data/lib/smithy/welds/rpc_v2_cbor.rb +20 -0
  96. data/lib/smithy/welds/rubocop.rb +33 -0
  97. data/lib/smithy/welds/transforms/default_endpoint_rules.json +35 -0
  98. data/lib/smithy/welds/transforms/default_endpoint_tests.json +24 -0
  99. data/lib/smithy/welds/transforms/endpoints.rb +68 -0
  100. data/lib/smithy/welds/transforms/synthetic_input_output.rb +60 -0
  101. data/lib/smithy/welds.rb +29 -0
  102. data/lib/smithy.rb +33 -2
  103. metadata +144 -9
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ module Client
6
+ # @api private
7
+ module ShapeToHash
8
+ class << self
9
+ def transform_value(model, value, shape)
10
+ return value if value.nil?
11
+
12
+ case shape['type']
13
+ when 'structure', 'union' then structure(model, shape, value)
14
+ when 'list' then list(model, shape, value)
15
+ when 'map' then map(model, shape, value)
16
+ when 'float', 'double' then float(value, shape)
17
+ when 'timestamp' then timestamp(value)
18
+ else
19
+ value
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def map(model, shape, value)
26
+ member_shape = Model.shape(model, shape['value']['target'])
27
+ value.transform_values do |v|
28
+ transform_value(model, v, member_shape)
29
+ end
30
+ end
31
+
32
+ def list(model, shape, value)
33
+ member_shape = Model.shape(model, shape['member']['target'])
34
+ value.map { |v| transform_value(model, v, member_shape) }
35
+ end
36
+
37
+ def structure(model, shape, value)
38
+ value.each_with_object({}) do |(k, v), o|
39
+ member_shape = Model.shape(model, shape['members'][k]['target'])
40
+ o[k.underscore.to_sym] = transform_value(model, v, member_shape)
41
+ end
42
+ end
43
+
44
+ def timestamp(value)
45
+ return value if nil?
46
+
47
+ CodegenValue.new(value, :timestamp)
48
+ end
49
+
50
+ def float(value, _shape)
51
+ case value
52
+ when 'Infinity' then CodegenValue.new(Float::INFINITY, :float)
53
+ when '-Infinity' then CodegenValue.new(-Float::INFINITY, :float)
54
+ when 'NaN' then CodegenValue.new(Float::NAN, :float)
55
+ else
56
+ value
57
+ end
58
+ end
59
+ end
60
+
61
+ # @api private
62
+ class CodegenValue
63
+ def initialize(value, shape)
64
+ @value = value
65
+ @shape = shape
66
+ end
67
+
68
+ def inspect
69
+ case @shape
70
+ when :float then float
71
+ when :timestamp then timestamp
72
+ else @value.inspect
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def timestamp
79
+ if @value.is_a?(String)
80
+ "Time.parse(#{@value})"
81
+ else
82
+ "Time.at(#{@value})"
83
+ end
84
+ end
85
+
86
+ def float
87
+ if @value.nan?
88
+ 'Float::NAN'
89
+ elsif @value.infinite?
90
+ "#{'-' if @value.negative?}Float::INFINITY"
91
+ else
92
+ @value.inspect
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ module Client
6
+ # @api private
7
+ class SpecHelper < View
8
+ def initialize(plan)
9
+ @plan = plan
10
+ super()
11
+ end
12
+
13
+ def gem_name
14
+ @plan.gem_name
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,293 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ module Client
6
+ # @api private
7
+ class Types < View
8
+ def initialize(plan)
9
+ @plan = plan
10
+ @model = plan.model
11
+ super()
12
+ end
13
+
14
+ def module_name
15
+ @plan.module_name
16
+ end
17
+
18
+ def types
19
+ Model::ServiceIndex
20
+ .new(@model)
21
+ .shapes_for(@plan.service)
22
+ .select { |_key, shape| %w[enum intEnum structure union].include?(shape['type']) }
23
+ .map { |id, shape| build_type(id, shape) }
24
+ end
25
+
26
+ private
27
+
28
+ def build_type(id, shape)
29
+ args = [@plan.service, @model, id, shape]
30
+ case shape['type']
31
+ when 'enum', 'intEnum' then EnumType.new(*args)
32
+ when 'structure' then StructureType.new(*args)
33
+ when 'union' then UnionType.new(*args)
34
+ end
35
+ end
36
+
37
+ # @api private
38
+ class Type
39
+ def initialize(service, model, id, shape)
40
+ _, @service = service.first
41
+ @model = model
42
+ @shape = shape
43
+ @type = shape['type']
44
+ @name = (@service.dig('rename', id) || Model::Shape.name(id)).camelize
45
+ @traits = shape.fetch('traits', {})
46
+ @members = build_members(shape['members'])
47
+ end
48
+
49
+ attr_reader :type, :name, :members
50
+
51
+ def docstrings
52
+ lines = []
53
+ lines.concat(documentation_docstrings)
54
+ lines.concat(deprecated_docstrings)
55
+ lines.concat(external_documentation_docstrings)
56
+ lines.concat(sensitive_docstrings)
57
+ lines.concat(since_docstrings)
58
+ lines.concat(unstable_docstrings)
59
+ lines
60
+ end
61
+
62
+ private
63
+
64
+ def documentation_docstrings
65
+ @traits.fetch('smithy.api#documentation', '').split("\n")
66
+ end
67
+
68
+ def deprecated_docstrings
69
+ return [] unless @traits.key?('smithy.api#deprecated')
70
+
71
+ message = @traits['smithy.api#deprecated'].fetch('message', '')
72
+ since = @traits['smithy.api#deprecated'].fetch('since', '')
73
+ Model::YARD.deprecated_docstrings(message, since)
74
+ end
75
+
76
+ def external_documentation_docstrings
77
+ return [] unless @traits.key?('smithy.api#externalDocumentation')
78
+
79
+ hash = @traits.fetch('smithy.api#externalDocumentation', {})
80
+ Model::YARD.external_documentation_docstrings(hash)
81
+ end
82
+
83
+ def sensitive_docstrings
84
+ return [] unless @traits.key?('smithy.api#sensitive')
85
+
86
+ [Model::YARD.sensitive_docstring]
87
+ end
88
+
89
+ def since_docstrings
90
+ return [] unless @traits.key?('smithy.api#since')
91
+
92
+ [Model::YARD.since_docstring(@traits['smithy.api#since'])]
93
+ end
94
+
95
+ def unstable_docstrings
96
+ return [] unless @traits.key?('smithy.api#unstable')
97
+
98
+ [Model::YARD.unstable_docstring]
99
+ end
100
+ end
101
+
102
+ # @api private
103
+ class EnumType < Type
104
+ private
105
+
106
+ def build_members(members)
107
+ members.map { |name, member| EnumMember.new(@service, @model, name, member) }
108
+ end
109
+ end
110
+
111
+ # @api private
112
+ class StructureType < Type
113
+ def input?
114
+ @traits.key?('smithy.api#input')
115
+ end
116
+
117
+ def defaults
118
+ @members.select { |member| member if member.default? }
119
+ end
120
+
121
+ def attribute_docstrings
122
+ lines = []
123
+ members.each do |member|
124
+ lines.concat(member.docstrings)
125
+ end
126
+ lines
127
+ end
128
+
129
+ private
130
+
131
+ def build_members(members)
132
+ members.map { |name, member| StructMember.new(@service, @model, name, member) }
133
+ end
134
+ end
135
+
136
+ # @api private
137
+ class UnionType < Type
138
+ def attribute_docstrings
139
+ lines = []
140
+ members.each do |member|
141
+ lines.concat(member.docstrings)
142
+ end
143
+ lines
144
+ end
145
+
146
+ private
147
+
148
+ def build_members(members)
149
+ members.map { |name, member| StructMember.new(@service, @model, name, member) }
150
+ end
151
+ end
152
+
153
+ # @api private
154
+ class Member
155
+ def initialize(service, model, name, member)
156
+ @service = service
157
+ @model = model
158
+ @name = name
159
+ @member = member
160
+ @traits = member.fetch('traits', {})
161
+ @target = Model.shape(model, member['target'])
162
+ end
163
+
164
+ attr_reader :name
165
+
166
+ def docstrings
167
+ lines = []
168
+ lines.concat(documentation_docstrings)
169
+ lines.concat(deprecated_docstrings)
170
+ lines.concat(external_documentation_docstrings)
171
+ lines.concat(since_docstrings)
172
+ lines.concat(unstable_docstrings)
173
+ lines
174
+ end
175
+
176
+ def documentation_docstrings
177
+ lines = @member.fetch('traits', {}).fetch('smithy.api#documentation', '').split("\n")
178
+ return lines unless lines.empty?
179
+
180
+ @target.fetch('traits', {}).fetch('smithy.api#documentation', '').split("\n")
181
+ end
182
+
183
+ def deprecated_docstrings
184
+ return [] unless @traits.key?('smithy.api#deprecated')
185
+
186
+ message = @traits['smithy.api#deprecated'].fetch('message', '')
187
+ since = @traits['smithy.api#deprecated'].fetch('since', '')
188
+ Model::YARD.deprecated_docstrings(message, since)
189
+ end
190
+
191
+ def external_documentation_docstrings
192
+ return [] unless @traits.key?('smithy.api#externalDocumentation')
193
+
194
+ hash = @traits.fetch('smithy.api#externalDocumentation', {})
195
+ Model::YARD.external_documentation_docstrings(hash)
196
+ end
197
+
198
+ def since_docstrings
199
+ return [] unless @traits.key?('smithy.api#since')
200
+
201
+ [Model::YARD.since_docstring(@traits['smithy.api#since'])]
202
+ end
203
+
204
+ def unstable_docstrings
205
+ return [] unless @traits.key?('smithy.api#unstable')
206
+
207
+ [Model::YARD.unstable_docstring]
208
+ end
209
+ end
210
+
211
+ # @api private
212
+ class EnumMember < Member
213
+ def value
214
+ value = @traits['smithy.api#enumValue']
215
+ case value
216
+ when String then "'#{value}'"
217
+ else value
218
+ end
219
+ end
220
+
221
+ def documentation_docstrings
222
+ @member.fetch('traits', {}).fetch('smithy.api#documentation', '').split("\n")
223
+ end
224
+ end
225
+
226
+ # @api private
227
+ class StructMember < Member
228
+ def docstrings # rubocop:disable Metrics/AbcSize
229
+ lines = ["@!attribute #{@name.underscore}"]
230
+ lines.concat(indented_docstrings(documentation_docstrings))
231
+ lines.concat(indented_docstrings(deprecated_docstrings))
232
+ lines.concat(indented_docstrings(external_documentation_docstrings))
233
+ lines.concat(indented_docstrings(recommended_docstrings))
234
+ lines.concat(indented_docstrings(since_docstrings))
235
+ lines.concat(indented_docstrings(unstable_docstrings))
236
+ lines.concat(indented_docstrings(return_docstrings))
237
+ lines
238
+ end
239
+
240
+ def default?
241
+ traits = @member.fetch('traits', {})
242
+ traits.key?('smithy.api#default') && !traits.key?('smithy.api#clientOptional')
243
+ end
244
+
245
+ def default
246
+ default = @member.dig('traits', 'smithy.api#default')
247
+ case @target['type']
248
+ when 'blob' then "Base64.strict_decode64('#{default}')"
249
+ when 'bigDecimal' then "BigDecimal('#{default}')"
250
+ when 'document' then document_default(default)
251
+ when 'enum', 'string' then "'#{default}'"
252
+ when 'timestamp' then timestamp_default(default)
253
+ else default
254
+ end
255
+ end
256
+
257
+ private
258
+
259
+ def indented_docstrings(docstrings)
260
+ docstrings.map { |docstring| " #{docstring}" }
261
+ end
262
+
263
+ def recommended_docstrings
264
+ return [] unless @traits.key?('smithy.api#recommended')
265
+
266
+ reason = @traits['smithy.api#recommended'].fetch('reason', '')
267
+ Model::YARD.recommended_docstrings(reason)
268
+ end
269
+
270
+ def return_docstrings
271
+ [Model::YARD.return_docstring(@service, @model, @member['target'], @target)]
272
+ end
273
+
274
+ def document_default(default)
275
+ case default
276
+ when nil then 'nil'
277
+ when String then "'#{default}'"
278
+ else default
279
+ end
280
+ end
281
+
282
+ def timestamp_default(default)
283
+ case default
284
+ when Integer then "Time.at(#{default})"
285
+ when String then "Time.parse('#{default}')"
286
+ else default
287
+ end
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end
293
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ module Client
6
+ # @api private
7
+ class TypesRbs < View
8
+ def initialize(plan)
9
+ @plan = plan
10
+ @model = plan.model
11
+ super()
12
+ end
13
+
14
+ def module_name
15
+ @plan.module_name
16
+ end
17
+
18
+ def types
19
+ Model::ServiceIndex
20
+ .new(@model)
21
+ .shapes_for(@plan.service)
22
+ .select { |_key, shape| %w[enum intEnum structure union].include?(shape['type']) }
23
+ .map { |id, structure| Type.new(@model, id, structure) }
24
+ end
25
+
26
+ # @api private
27
+ class Type
28
+ def initialize(model, id, shape)
29
+ @model = model
30
+ @id = id
31
+ @shape = shape
32
+ @type = shape['type']
33
+ @members = build_members(shape['members'])
34
+ end
35
+
36
+ attr_reader :type, :members
37
+
38
+ def name
39
+ Model::Shape.name(@id).camelize
40
+ end
41
+
42
+ private
43
+
44
+ def build_members(members)
45
+ members.map { |name, member| Member.new(@model, name, member) }
46
+ end
47
+ end
48
+
49
+ # @api private
50
+ class Member
51
+ def initialize(model, name, member)
52
+ @model = model
53
+ @name = name
54
+ @id = member['target']
55
+ @target = Model.shape(@model, member['target'])
56
+ end
57
+
58
+ attr_reader :name
59
+
60
+ def rbs_type
61
+ Model::RBS.type(@model, @id, @target)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ module Client
6
+ # @api private
7
+ class Waiters < View
8
+ def initialize(plan)
9
+ @plan = plan
10
+ @model = @plan.model
11
+ super()
12
+ end
13
+
14
+ def module_name
15
+ @plan.module_name
16
+ end
17
+
18
+ def waiters
19
+ waiters = []
20
+ operations = Model::ServiceIndex.new(@model).operations_for(@plan.service)
21
+ operations.each do |operation_id, operation|
22
+ waiters_from_trait = waitable_trait(operation)
23
+ next if waiters_from_trait.empty?
24
+
25
+ operation_name = Model::Shape.name(operation_id).underscore
26
+ waiters_from_trait.map do |waiter_name, waiter|
27
+ waiters << Waiter.new(operation_name, waiter_name, waiter)
28
+ end
29
+ end
30
+ waiters.sort_by(&:name)
31
+ end
32
+
33
+ private
34
+
35
+ def waitable_trait(operation)
36
+ operation.fetch('traits', {}).fetch('smithy.waiters#waitable', {})
37
+ end
38
+
39
+ # @api private
40
+ class Waiter
41
+ def initialize(operation_name, name, waiter)
42
+ @operation_name = operation_name
43
+ @name = name
44
+ @documentation = waiter.fetch('documentation', '')
45
+ @acceptors = formatted_acceptors(waiter['acceptors'])
46
+ @min_delay = waiter['minDelay'] || 2
47
+ @max_delay = waiter['maxDelay'] || 120
48
+ @deprecated = waiter['deprecated']
49
+ end
50
+
51
+ attr_reader :operation_name, :name, :documentation, :acceptors, :min_delay, :max_delay
52
+
53
+ def docstrings
54
+ @documentation.split("\n")
55
+ end
56
+
57
+ def formatted_acceptors(acceptors)
58
+ acceptors.each { |acceptor| preprocess_acceptor(acceptor) }
59
+
60
+ Util::HashFormatter.new(
61
+ wrap: false,
62
+ inline: false,
63
+ quote_strings: true
64
+ ).format(acceptors: acceptors).split("\n")
65
+ end
66
+
67
+ def preprocess_acceptor(acceptor)
68
+ if (matcher = acceptor['matcher']['output'] || acceptor['matcher']['inputOutput'])
69
+ matcher['path'] = Util::Underscore.underscore_jmespath(matcher['path'])
70
+ elsif (error_type = acceptor['matcher']['errorType'])
71
+ acceptor['matcher']['errorType'] = Model::Shape.name(error_type)
72
+ end
73
+ end
74
+
75
+ def deprecated?
76
+ !!@deprecated
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ module Views
5
+ # @api private
6
+ module Client; end
7
+ end
8
+ end
9
+
10
+ # helper classes
11
+ require_relative 'client/auth_parameter'
12
+ require_relative 'client/endpoint_parameter'
13
+ require_relative 'client/operation_examples'
14
+ require_relative 'client/plugin'
15
+ require_relative 'client/plugin_list'
16
+ require_relative 'client/request_response_example'
17
+ require_relative 'client/shape_to_hash'
18
+
19
+ # views
20
+ require_relative 'client/auth_parameters'
21
+ require_relative 'client/auth_parameters_rbs'
22
+ require_relative 'client/auth_plugin'
23
+ require_relative 'client/auth_resolver'
24
+ require_relative 'client/auth_resolver_rbs'
25
+ require_relative 'client/client'
26
+ require_relative 'client/client_rbs'
27
+ require_relative 'client/customizations'
28
+ require_relative 'client/endpoint_parameters'
29
+ require_relative 'client/endpoint_parameters_rbs'
30
+ require_relative 'client/endpoint_plugin'
31
+ require_relative 'client/endpoint_provider'
32
+ require_relative 'client/endpoint_provider_rbs'
33
+ require_relative 'client/endpoint_provider_spec'
34
+ require_relative 'client/errors'
35
+ require_relative 'client/errors_rbs'
36
+ require_relative 'client/gemspec'
37
+ require_relative 'client/module'
38
+ require_relative 'client/module_rbs'
39
+ require_relative 'client/paginators'
40
+ require_relative 'client/protocol_spec'
41
+ require_relative 'client/rubocop_yml'
42
+ require_relative 'client/schema'
43
+ require_relative 'client/schema_rbs'
44
+ require_relative 'client/spec_helper'
45
+ require_relative 'client/types'
46
+ require_relative 'client/types_rbs'
47
+ require_relative 'client/waiters'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module Smithy
6
+ module Views
7
+ # @api private
8
+ class View
9
+ class << self
10
+ TEMPLATE_DIR = File.expand_path('../templates', __dir__.to_s)
11
+
12
+ def inherited(subclass)
13
+ parts = (subclass.name || '').split('::')
14
+ parts.shift(2) #=> remove Smithy::Views
15
+ type = parts.shift #=> remove Client/Server
16
+ parts.unshift(type) #=> add <Type>
17
+ path = File.join(parts.map(&:underscore))
18
+ subclass.template_file = File.join(TEMPLATE_DIR, "#{path}.erb")
19
+ super
20
+ end
21
+
22
+ attr_accessor :template_file
23
+ end
24
+
25
+ def render
26
+ ERB.new(File.read(self.class.template_file), trim_mode: '-').result(binding)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smithy
4
+ # @api private
5
+ module Views; end
6
+ end
7
+
8
+ require_relative 'views/view'
9
+ require_relative 'views/client'