apipie-rails 1.2.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +5 -4
  3. data/.github/workflows/rubocop-challenger.yml +1 -3
  4. data/.github/workflows/rubocop.yml +1 -1
  5. data/.rubocop_todo.yml +22 -28
  6. data/CHANGELOG.md +22 -0
  7. data/Gemfile +2 -3
  8. data/README.md +2088 -0
  9. data/apipie-rails.gemspec +7 -1
  10. data/app/views/apipie/apipies/_method_detail.erb +2 -0
  11. data/app/views/apipie/apipies/_params.html.erb +1 -0
  12. data/app/views/apipie/apipies/_params_plain.html.erb +1 -0
  13. data/config/locales/en.yml +1 -0
  14. data/config/locales/ko.yml +1 -0
  15. data/lib/apipie/application.rb +1 -1
  16. data/lib/apipie/dsl_definition.rb +10 -11
  17. data/lib/apipie/errors.rb +1 -1
  18. data/lib/apipie/extractor/collector.rb +1 -1
  19. data/lib/apipie/extractor/recorder.rb +1 -1
  20. data/lib/apipie/extractor/writer.rb +2 -2
  21. data/lib/apipie/generator/swagger/config.rb +1 -1
  22. data/lib/apipie/generator/swagger/method_description/parameters_service.rb +1 -1
  23. data/lib/apipie/generator/swagger/method_description/response_service.rb +14 -1
  24. data/lib/apipie/generator/swagger/param_description/builder.rb +9 -0
  25. data/lib/apipie/generator/swagger/param_description/type.rb +15 -2
  26. data/lib/apipie/generator/swagger/resource_description_collection.rb +2 -2
  27. data/lib/apipie/param_description.rb +1 -1
  28. data/lib/apipie/response_description.rb +34 -9
  29. data/lib/apipie/response_description_adapter.rb +3 -3
  30. data/lib/apipie/routes_formatter.rb +1 -1
  31. data/lib/apipie/static_dispatcher.rb +7 -1
  32. data/lib/apipie/version.rb +1 -1
  33. data/lib/tasks/apipie.rake +3 -3
  34. data/rel-eng/gem_release.ipynb +5 -5
  35. data/spec/controllers/users_controller_spec.rb +1 -1
  36. data/spec/dummy/app/controllers/api/v2/empty_middle_controller.rb +1 -1
  37. data/spec/dummy/app/controllers/pets_controller.rb +2 -2
  38. data/spec/dummy/app/controllers/twitter_example_controller.rb +3 -3
  39. data/spec/lib/apipie/apipies_controller_spec.rb +1 -1
  40. data/spec/lib/apipie/extractor_spec.rb +1 -1
  41. data/spec/lib/apipie/file_handler_spec.rb +1 -1
  42. data/spec/lib/apipie/generator/swagger/method_description/response_schema_service_spec.rb +6 -6
  43. data/spec/lib/apipie/generator/swagger/method_description/response_service_spec.rb +62 -0
  44. data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +14 -2
  45. data/spec/lib/apipie/generator/swagger/param_description/type_spec.rb +6 -1
  46. data/spec/lib/apipie/param_description_spec.rb +1 -1
  47. data/spec/lib/apipie/response_description/response_object_spec.rb +22 -0
  48. data/spec/lib/apipie/response_description_spec.rb +56 -0
  49. data/spec/lib/apipie/swagger_generator_spec.rb +2 -2
  50. data/spec/lib/swagger/rake_swagger_spec.rb +6 -1
  51. data/spec/lib/swagger/swagger_dsl_spec.rb +1 -1
  52. data/spec/spec_helper.rb +1 -1
  53. metadata +12 -6
  54. data/README.rst +0 -1965
data/apipie-rails.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = Apipie::VERSION
9
9
  s.authors = ["Pavel Pokorny","Ivan Necas"]
10
10
  s.email = ["pajkycz@gmail.com", "inecas@redhat.com"]
11
- s.homepage = "http://github.com/Apipie/apipie-rails"
11
+ s.homepage = "https://github.com/Apipie/apipie-rails"
12
12
  s.summary = %q{Rails REST API documentation tool}
13
13
  s.description = %q{Rails REST API documentation tool}
14
14
  s.required_ruby_version = '>= 2.6.0'
@@ -17,6 +17,12 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.require_paths = ["lib"]
19
19
 
20
+ s.metadata = {
21
+ "bug_tracker_uri" => "https://github.com/Apipie/apipie-rails/issues",
22
+ "changelog_uri" => "https://github.com/Apipie/apipie-rails/blob/master/CHANGELOG.md",
23
+ "source_code_uri" => "https://github.com/Apipie/apipie-rails"
24
+ }
25
+
20
26
  s.add_dependency "actionpack", ">= 5.0"
21
27
  s.add_dependency "activesupport", ">= 5.0"
22
28
 
@@ -55,6 +55,8 @@
55
55
  <%= render(:partial => "params", :locals => {:params => item[:returns_object]}) %>
56
56
  </tbody>
57
57
  </table>
58
+
59
+ <%= render(:partial => "headers", :locals => {:headers => item[:headers], :h_level => h_level+2 }) %>
58
60
  <% end %>
59
61
  <% end %>
60
62
 
@@ -15,6 +15,7 @@
15
15
  <small>
16
16
  <%= param[:required] ? t('apipie.required') : t('apipie.optional') %>
17
17
  <%= param[:allow_nil] ? ', '+t('apipie.nil_allowed') : '' %>
18
+ <%= param[:allow_blank] ? ', '+t('apipie.blank_allowed') : '' %>
18
19
  </small>
19
20
  </td>
20
21
  <td>
@@ -9,6 +9,7 @@
9
9
  <small>
10
10
  <%= param[:required] ? t('apipie.required') : t('apipie.optional') %>
11
11
  <%= param[:allow_nil] ? ', '+t('apipie.nil_allowed') : '' %>
12
+ <%= param[:allow_blank] ? ', '+t('apipie.blank_allowed') : '' %>
12
13
  <% if param[:validator] %>
13
14
  [ <%= Apipie.markup_to_html(param[:validator]).html_safe %> ]
14
15
  <% end %>
@@ -15,6 +15,7 @@ en:
15
15
  required: required
16
16
  optional: optional
17
17
  nil_allowed: nil allowed
18
+ blank_allowed: blank allowed
18
19
  param_name: Param name
19
20
  params: Params
20
21
  examples: Examples
@@ -15,6 +15,7 @@ ko:
15
15
  required: 필수
16
16
  optional: 옵션
17
17
  nil_allowed: nil 허용
18
+ blank_allowed: blank 허용
18
19
  param_name: Param 이름
19
20
  params: Params
20
21
  examples: 예시
@@ -89,7 +89,7 @@ module Apipie
89
89
 
90
90
  # we create separate method description for each version in
91
91
  # case the method belongs to more versions. We return just one
92
- # becuase the version doesn't matter for the purpose it's used
92
+ # because the version doesn't matter for the purpose it's used
93
93
  # (to wrap the original version with validators)
94
94
  ret_method_description ||= method_description
95
95
  resource_description.add_method_description(method_description)
@@ -178,7 +178,7 @@ module Apipie
178
178
  alias full_description desc
179
179
 
180
180
  # describe next method with document in given path
181
- # in convension, these doc located under "#{Rails.root}/doc"
181
+ # in convention, these doc located under "#{Rails.root}/doc"
182
182
  # Example:
183
183
  # document "hello_world.md"
184
184
  # def hello_world
@@ -242,7 +242,7 @@ module Apipie
242
242
 
243
243
  if Apipie.configuration.validate_presence?
244
244
  Validator::BaseValidator.raise_if_missing_params do |missing|
245
- method_params.each do |_, param|
245
+ method_params.each_value do |param|
246
246
  # check if required parameters are present
247
247
  missing << param if param.required && !params.key?(param.name)
248
248
  end
@@ -250,7 +250,7 @@ module Apipie
250
250
  end
251
251
 
252
252
  if Apipie.configuration.validate_value?
253
- method_params.each do |_, param|
253
+ method_params.each_value do |param|
254
254
  # params validations
255
255
  param.validate(params[:"#{param.name}"]) if params.key?(param.name)
256
256
  end
@@ -267,12 +267,11 @@ module Apipie
267
267
  end
268
268
  end
269
269
 
270
- if Apipie.configuration.process_value?
271
- @api_params ||= {}
272
- method_params.each do |_, param|
273
- # params processing
274
- @api_params[param.as] = param.process_value(params[:"#{param.name}"]) if params.key?(param.name)
275
- end
270
+ return unless Apipie.configuration.process_value?
271
+ @api_params ||= {}
272
+ method_params.each_value do |param|
273
+ # params processing
274
+ @api_params[param.as] = param.process_value(params[:"#{param.name}"]) if params.key?(param.name)
276
275
  end
277
276
  end
278
277
  end
@@ -453,7 +452,7 @@ module Apipie
453
452
  include Apipie::DSL::Action
454
453
  include Apipie::DSL::Param
455
454
 
456
- # defines the substitutions to be made in the API paths deifned
455
+ # defines the substitutions to be made in the API paths defined
457
456
  # in concerns included. For example:
458
457
  #
459
458
  # There is this method defined in concern:
@@ -473,7 +472,7 @@ module Apipie
473
472
  #
474
473
  # It has to be specified before the concern is included.
475
474
  #
476
- # If not specified, the default predefined substitions are
475
+ # If not specified, the default predefined substitutions are
477
476
  #
478
477
  # {:conroller_path => controller.controller_path,
479
478
  # :resource_id => `resource_id_from_apipie` }
data/lib/apipie/errors.rb CHANGED
@@ -62,7 +62,7 @@ module Apipie
62
62
  attr_accessor :value, :error
63
63
 
64
64
  def initialize(param, value, error)
65
- super param
65
+ super(param)
66
66
  @value = value
67
67
  @error = error
68
68
  end
@@ -89,7 +89,7 @@ module Apipie
89
89
  end
90
90
 
91
91
  def finalize_descriptions
92
- @descriptions.each do |method, desc|
92
+ @descriptions.each_value do |desc|
93
93
  add_routes_info(desc)
94
94
  end
95
95
  return @descriptions
@@ -90,7 +90,7 @@ module Apipie
90
90
  lines << '' << %{... contents of "#{attrs[:name]}" ...}
91
91
  else
92
92
  # Look for subelements that contain a part.
93
- attrs.each { |k,v| v.is_a?(Hash) and reformat_hash(boundary, v, lines) }
93
+ attrs.each_value { |v| v.is_a?(Hash) and reformat_hash(boundary, v, lines) }
94
94
  end
95
95
  end
96
96
 
@@ -80,7 +80,7 @@ module Apipie
80
80
 
81
81
  def write_docs
82
82
  descriptions = @collector.finalize_descriptions
83
- descriptions.each do |_, desc|
83
+ descriptions.each_value do |desc|
84
84
  if desc[:api].empty?
85
85
  logger.warn("REST_API: Couldn't find any path for #{desc_to_s(desc)}")
86
86
  next
@@ -419,7 +419,7 @@ module Apipie
419
419
  end
420
420
 
421
421
  # this method would be totally useless unless some clever guy
422
- # desided that it would be great idea to change a behavior of
422
+ # decided that it would be great idea to change a behavior of
423
423
  # "".lines method to not include end of lines.
424
424
  #
425
425
  # For more details:
@@ -24,7 +24,7 @@ module Apipie
24
24
  HEREDOC
25
25
  )
26
26
 
27
- send("#{attribute}=", value)
27
+ send(:"#{attribute}=", value)
28
28
  end
29
29
 
30
30
  old_setter_method = "swagger_#{attribute}"
@@ -96,7 +96,7 @@ class Apipie::Generator::Swagger::MethodDescription::ParametersService
96
96
  def path_param_descriptions
97
97
  @path_param_descriptions ||= all_params
98
98
  .select { |k, _| @path.param?(k) }
99
- .each { |_, desc| desc.required = true }
99
+ .each_value { |desc| desc.required = true }
100
100
  .values
101
101
  end
102
102
 
@@ -39,7 +39,8 @@ class Apipie::Generator::Swagger::MethodDescription::ResponseService
39
39
  allow_null: false,
40
40
  http_method: @http_method,
41
41
  controller_method: @method_description
42
- ).to_swagger
42
+ ).to_swagger,
43
+ headers: response_headers(response.headers)
43
44
  }.compact
44
45
  end
45
46
  end
@@ -55,4 +56,16 @@ class Apipie::Generator::Swagger::MethodDescription::ResponseService
55
56
 
56
57
  { 200 => { description: 'ok' } }
57
58
  end
59
+
60
+ # @param [Array<Hash>] headers
61
+ #
62
+ # https://swagger.io/specification/v2/#header-object
63
+ def response_headers(headers)
64
+ headers.each_with_object({}) do |header, result|
65
+ result[header[:name].to_s] = {
66
+ description: header[:description],
67
+ type: header[:validator]
68
+ }
69
+ end
70
+ end
58
71
  end
@@ -53,6 +53,7 @@ class Apipie::Generator::Swagger::ParamDescription::Builder
53
53
 
54
54
  definition.merge!(for_default)
55
55
  definition.merge!(for_required)
56
+ definition.merge!(for_example)
56
57
  definition.merge!(@description.to_hash) if @description.present?
57
58
 
58
59
  warn_optional_without_default_value(definition)
@@ -78,6 +79,14 @@ class Apipie::Generator::Swagger::ParamDescription::Builder
78
79
  }
79
80
  end
80
81
 
82
+ def for_example
83
+ return {} unless @param_description.options.key?(:example)
84
+
85
+ {
86
+ example: @param_description.options[:example],
87
+ }
88
+ end
89
+
81
90
  def required?
82
91
  required_from_path? || @param_description.required
83
92
  end
@@ -56,7 +56,7 @@ class Apipie::Generator::Swagger::ParamDescription::Type
56
56
 
57
57
  def for_array_type
58
58
  validator_opts = validator.param_description.options
59
- items_type = validator_opts[:of].to_s || validator_opts[:array_of].to_s
59
+ items_type = (validator_opts[:of] || validator_opts[:array_of]).to_s
60
60
 
61
61
  if items_type == 'Hash' && params_in_body_use_reference?
62
62
  reference_name = Apipie::Generator::Swagger::OperationId.
@@ -67,7 +67,7 @@ class Apipie::Generator::Swagger::ParamDescription::Type
67
67
  '$ref' => reference_name
68
68
  }
69
69
  else
70
- items = { type: 'string' }
70
+ items = { type: array_items_type(items_type).to_s }
71
71
  end
72
72
 
73
73
  enum = @param_description.options[:in]
@@ -80,6 +80,19 @@ class Apipie::Generator::Swagger::ParamDescription::Type
80
80
  }
81
81
  end
82
82
 
83
+ # @param [String] items_type
84
+ #
85
+ # @return [Apipie::Generator::Swagger::Type]
86
+ def array_items_type(items_type)
87
+ type = Apipie::Generator::Swagger::TypeExtractor::TYPES[items_type.downcase.to_sym]
88
+
89
+ if type == 'object' || type.blank?
90
+ Apipie::Generator::Swagger::TypeExtractor::TYPES[:string]
91
+ else
92
+ type
93
+ end
94
+ end
95
+
83
96
  def for_enum_type
84
97
  {
85
98
  type: 'string',
@@ -19,9 +19,9 @@ class Apipie::Generator::Swagger::ResourceDescriptionsCollection
19
19
 
20
20
  if method_name.present?
21
21
  resources = resources.select do |resource_description|
22
- resource_description._methods.select do |method_description_name, _|
22
+ resource_description._methods.any? do |method_description_name, _|
23
23
  method_description_name == method_name
24
- end.present?
24
+ end
25
25
  end
26
26
  end
27
27
 
@@ -245,7 +245,7 @@ module Apipie
245
245
 
246
246
  # makes modification that are based on the action that the param
247
247
  # is defined for. Typical for required and allow_nil variations in
248
- # crate/update actions.
248
+ # create/update actions.
249
249
  def action_awareness
250
250
  if action_aware?
251
251
  if !@options.key?(:allow_nil)
@@ -6,6 +6,7 @@ module Apipie
6
6
  include Apipie::DSL::Param
7
7
 
8
8
  attr_accessor :additional_properties, :typename
9
+ attr_reader :headers
9
10
 
10
11
  def initialize(method_description, scope, block, typename)
11
12
  @method_description = method_description
@@ -13,6 +14,7 @@ module Apipie
13
14
  @param_group = {scope: scope}
14
15
  @additional_properties = false
15
16
  @typename = typename
17
+ @headers = []
16
18
 
17
19
  self.instance_exec(&block) if block
18
20
 
@@ -43,6 +45,18 @@ module Apipie
43
45
  end
44
46
  end
45
47
 
48
+ # @param [String] header_name
49
+ # @param [String, symbol, Class] validator
50
+ # @param [String] description
51
+ # @param [Hash] options
52
+ def header(header_name, validator, description, options = {})
53
+ @headers << {
54
+ name: header_name,
55
+ validator: validator.to_s.downcase,
56
+ description: description,
57
+ options: options
58
+ }
59
+ end
46
60
  end
47
61
  end
48
62
 
@@ -64,15 +78,6 @@ module Apipie
64
78
  adapter)
65
79
  end
66
80
 
67
- def is_array?
68
- @is_array_of != false
69
- end
70
-
71
- def typename
72
- @response_object.typename
73
- end
74
-
75
-
76
81
  def initialize(method_description, code, options, scope, block, adapter)
77
82
 
78
83
  @type_ref = options[:param_group]
@@ -105,6 +110,14 @@ module Apipie
105
110
  @response_object.additional_properties ||= options[:additional_properties]
106
111
  end
107
112
 
113
+ def is_array?
114
+ @is_array_of != false
115
+ end
116
+
117
+ def typename
118
+ @response_object.typename
119
+ end
120
+
108
121
  def param_description
109
122
  nil
110
123
  end
@@ -118,6 +131,17 @@ module Apipie
118
131
  end
119
132
  alias allow_additional_properties additional_properties
120
133
 
134
+ # @return [Array<Hash>]
135
+ def headers
136
+ # TODO: Support headers for Apipie::ResponseDescriptionAdapter
137
+ if @response_object.is_a?(Apipie::ResponseDescriptionAdapter)
138
+ return []
139
+ end
140
+
141
+ @response_object.headers
142
+ end
143
+
144
+ # @return [Hash{Symbol->TrueClass | FalseClass}]
121
145
  def to_json(lang = nil)
122
146
  {
123
147
  :code => code,
@@ -125,6 +149,7 @@ module Apipie
125
149
  :is_array => is_array?,
126
150
  :returns_object => params_ordered.map{ |param| param.to_json(lang).tap{|h| h.delete(:validations) }}.flatten,
127
151
  :additional_properties => additional_properties,
152
+ :headers => headers
128
153
  }
129
154
  end
130
155
  end
@@ -11,7 +11,7 @@ module Apipie
11
11
  class ResponseDescriptionAdapter
12
12
  class Modifier
13
13
  def apply(adapter)
14
- raise "Modifer subclass must implement 'apply' method"
14
+ raise "Modifier subclass must implement 'apply' method"
15
15
  end
16
16
  end
17
17
 
@@ -57,7 +57,7 @@ module Apipie
57
57
  attr_reader :expected_type
58
58
 
59
59
  def [](key)
60
- return self.send(key) if self.respond_to?(key.to_s)
60
+ self.send(key) if self.respond_to?(key.to_s)
61
61
  end
62
62
 
63
63
  def initialize(expected_type, enum_values = nil, sub_properties = nil)
@@ -102,7 +102,7 @@ module Apipie
102
102
  end
103
103
 
104
104
  def [](key)
105
- return self.send(key) if self.respond_to?(key.to_s)
105
+ self.send(key) if self.respond_to?(key.to_s)
106
106
  end
107
107
 
108
108
  def add_sub_property(prop_desc)
@@ -24,7 +24,7 @@ module Apipie
24
24
  if verb.count != 1
25
25
  verb = API_METHODS.select{|defined_verb| defined_verb == rails_route.constraints[:method]}
26
26
  if verb.blank?
27
- raise "Unknow verb #{rails_route.path.spec.to_s}"
27
+ raise "Unknown verb #{rails_route.path.spec.to_s}"
28
28
  end
29
29
  end
30
30
  verb.first
@@ -4,7 +4,13 @@ module Apipie
4
4
  def initialize(root)
5
5
  @root = root.chomp('/')
6
6
  @compiled_root = /^#{Regexp.escape(root)}/
7
- @file_server = ::Rack::File.new(@root)
7
+ @file_server = if defined?(::Rack::Files)
8
+ ::Rack::Files.new(@root)
9
+ else
10
+ # Deprecated in Rack 3.0, kept
11
+ # for backward compatibility
12
+ ::Rack::File.new(@root)
13
+ end
8
14
  end
9
15
 
10
16
  def match?(path)
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = "1.2.3"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -186,11 +186,11 @@ namespace :apipie do
186
186
  av = renderer
187
187
  File.open(file_name, "w") do |f|
188
188
  variables.each do |var, val|
189
- av.instance_variable_set("@#{var}", val)
189
+ av.instance_variable_set(:"@#{var}", val)
190
190
  end
191
191
  f.write av.render(
192
192
  :template => "#{template}",
193
- :layout => (layout && "apipie/#{layout}"))
193
+ :layout => layout && "apipie/#{layout}")
194
194
  end
195
195
  end
196
196
 
@@ -259,7 +259,7 @@ namespace :apipie do
259
259
  end
260
260
 
261
261
  def generate_resource_pages(version, file_base, doc, include_json = false, lang = nil)
262
- doc[:docs][:resources].each do |resource_id, _|
262
+ doc[:docs][:resources].each_key do |resource_id|
263
263
  resource_file_base = File.join(file_base, resource_id.to_s)
264
264
  FileUtils.mkdir_p(File.dirname(resource_file_base)) unless File.exist?(File.dirname(resource_file_base))
265
265
 
@@ -10,7 +10,7 @@
10
10
  "- push access to https://github.com/Apipie/apipie-rails\n",
11
11
  "- push access to rubygems.org for apipie-rails\n",
12
12
  "- sudo yum install python-slugify asciidoc\n",
13
- "- ensure neither the `git push` or `gem push` don't require interractive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually\n",
13
+ "- ensure neither the `git push` or `gem push` don't require interactive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually\n",
14
14
  "- ensure all checks have passed on the branch you're about to release\n",
15
15
  "\n",
16
16
  "### Release process\n",
@@ -117,7 +117,7 @@
117
117
  "cell_type": "markdown",
118
118
  "metadata": {},
119
119
  "source": [
120
- "### Run tests localy if your setup allows, otherwise ensure the HEAD is green"
120
+ "### Run tests locally if your setup allows, otherwise ensure the HEAD is green"
121
121
  ]
122
122
  },
123
123
  {
@@ -217,14 +217,14 @@
217
217
  "cell_type": "markdown",
218
218
  "metadata": {},
219
219
  "source": [
220
- "#### Manual step: Update deps in the gemspec if neccessary"
220
+ "#### Manual step: Update deps in the gemspec if necessary"
221
221
  ]
222
222
  },
223
223
  {
224
224
  "cell_type": "markdown",
225
225
  "metadata": {},
226
226
  "source": [
227
- "### Check what is going to be commited"
227
+ "### Check what is going to be committed"
228
228
  ]
229
229
  },
230
230
  {
@@ -347,7 +347,7 @@
347
347
  "source": [
348
348
  "### Some manual steps follow to improve the UX\n",
349
349
  "\n",
350
- "#### New relase on GitHub\n",
350
+ "#### New release on GitHub\n",
351
351
  "\n",
352
352
  "Copy the following changelog lines to the description in form on link below\n",
353
353
  "The release title is the new version."
@@ -430,7 +430,7 @@ describe UsersController do
430
430
  expect(b.full_description.length).to be > 400
431
431
  end
432
432
 
433
- context "Usign routes.rb" do
433
+ context "Using routes.rb" do
434
434
  it "should contain basic info about method" do
435
435
  a = Apipie[UsersController, :create_route]
436
436
  expect(a.apis.count).to eq(1)
@@ -2,7 +2,7 @@ module Api
2
2
  module V2
3
3
  class EmptyMiddleController < V2::BaseController
4
4
  # This is an empty controller, used to test cases where controllers
5
- # may inherit from a middle controler that does not define a resource_description,
5
+ # may inherit from a middle controller that does not define a resource_description,
6
6
  # but the middle controller's parent does.
7
7
 
8
8
  def inconsequential_method
@@ -23,7 +23,7 @@ class PetsController < ApplicationController
23
23
  #-----------------------------------------------------------
24
24
  api :GET, "/pets/:id/as_properties", "Get a pet record"
25
25
  returns :code => 200 do
26
- property :pet_name, String, :desc => "Name of pet", :required => false
26
+ property :pet_name, String, :desc => "Name of pet", :required => false, :example => 'mypet'
27
27
  property :animal_type, %w[dog cat iguana kangaroo], :desc => "Type of pet" # required by default, because this is a 'property'
28
28
  end
29
29
  returns :code => 404 do
@@ -63,7 +63,7 @@ class PetsController < ApplicationController
63
63
  # mixing request/response and response-only parameters
64
64
  #
65
65
  # the param_group :pet_with_id has several parameters which are
66
- # not expectd in the request, but would show up in the response
66
+ # not expected in the request, but would show up in the response
67
67
  # and vice versa
68
68
  #-----------------------------------------------------------
69
69
  def_param_group :pet_with_id do
@@ -10,7 +10,7 @@ class TwitterExampleController < ApplicationController
10
10
  api :GET, '/twitter_example/lookup', 'Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.'
11
11
  param :screen_name, String, :desc => 'A comma separated list of screen names, up to 100 are allowed in a single request. You are strongly encouraged to use a POST for larger (up to 100 screen names) requests.'
12
12
  param :user_id, Integer, :desc => 'A comma separated list of user IDs, up to 100 are allowed in a single request. You are strongly encouraged to use a POST for larger requests.'
13
- param :include_entities, String, :desc => 'When set to either <code>true</code>, <code>t</code> or <code>1</code>, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
13
+ param :include_entities, String, :desc => 'When set to either <code>true</code>, <code>t</code> or <code>1</code>, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discrete structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
14
14
 
15
15
  description <<-EOS
16
16
  Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. The author's most recent status (if the authenticating user has permission) will be returned inline.
@@ -53,8 +53,8 @@ class TwitterExampleController < ApplicationController
53
53
  api :GET, '/twitter_example/search', 'Runs a search for users similar to Find People button on Twitter.com.'
54
54
  param :q, String, :desc => 'The search query to run against people search.', :required => true
55
55
  param :page, Integer, :desc => 'Specifies the page of results to retrieve.'
56
- param :per_page, Integer, :desc => 'The number of people to retrieve. Maxiumum of 20 allowed per page.'
57
- param :include_entities, String, :desc => 'When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
56
+ param :per_page, Integer, :desc => 'The number of people to retrieve. Maximum of 20 allowed per page.'
57
+ param :include_entities, String, :desc => 'When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discrete structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
58
58
  description <<-EOS
59
59
  Runs a search for users similar to Find People button on Twitter.com. The results returned by people search on Twitter.com are the same as those returned by this API request. Note that unlike GET search, this method does not support any operators.
60
60
 
@@ -188,7 +188,7 @@ describe Apipie::ApipiesController, type: :controller do
188
188
 
189
189
 
190
190
  describe "authenticate user" do
191
- it "authenticate user if an authentication method is setted" do
191
+ it "authenticate user if an authentication method is set" do
192
192
  test = false
193
193
  Apipie.configuration.authenticate = Proc.new do
194
194
  test = true
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Apipie::Extractor do
4
4
  it 'handles routes without (.:format)' do
5
- Apipie::Extractor.apis_from_routes.each do |(controller, action), apis|
5
+ Apipie::Extractor.apis_from_routes.each_value do |apis|
6
6
  apis.each { |api| expect(api[:path]).not_to be_nil }
7
7
  end
8
8
  end
@@ -15,7 +15,7 @@ describe Apipie::FileHandler do
15
15
  it { expect { file_handler.match? path }.to_not raise_error }
16
16
  end
17
17
 
18
- context 'when the path contans an invalid byte sequence in UTF-8' do
18
+ context 'when the path contains an invalid byte sequence in UTF-8' do
19
19
  let(:path) { "%B6" }
20
20
 
21
21
  it { expect(file_handler.match? path).to be_falsy }