apipierails3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +17 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +27 -0
  5. data/APACHE-LICENSE-2.0 +202 -0
  6. data/CHANGELOG.md +469 -0
  7. data/Gemfile +1 -0
  8. data/Gemfile.rails32 +6 -0
  9. data/Gemfile.rails41 +6 -0
  10. data/Gemfile.rails42 +11 -0
  11. data/Gemfile.rails50 +6 -0
  12. data/Gemfile.rails51 +7 -0
  13. data/MIT-LICENSE +20 -0
  14. data/NOTICE +4 -0
  15. data/PROPOSAL_FOR_RESPONSE_DESCRIPTIONS.md +244 -0
  16. data/README.rst +1874 -0
  17. data/Rakefile +13 -0
  18. data/apipierails3.gemspec +27 -0
  19. data/app/controllers/apipie/apipies_controller.rb +199 -0
  20. data/app/helpers/apipie_helper.rb +10 -0
  21. data/app/public/apipie/javascripts/apipie.js +6 -0
  22. data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +138 -0
  23. data/app/public/apipie/javascripts/bundled/bootstrap.js +1726 -0
  24. data/app/public/apipie/javascripts/bundled/jquery.js +5 -0
  25. data/app/public/apipie/javascripts/bundled/prettify.js +28 -0
  26. data/app/public/apipie/stylesheets/application.css +7 -0
  27. data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +12 -0
  28. data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +689 -0
  29. data/app/public/apipie/stylesheets/bundled/prettify.css +30 -0
  30. data/app/views/apipie/apipies/_disqus.html.erb +13 -0
  31. data/app/views/apipie/apipies/_errors.html.erb +23 -0
  32. data/app/views/apipie/apipies/_headers.html.erb +26 -0
  33. data/app/views/apipie/apipies/_languages.erb +6 -0
  34. data/app/views/apipie/apipies/_metadata.erb +1 -0
  35. data/app/views/apipie/apipies/_method_detail.erb +61 -0
  36. data/app/views/apipie/apipies/_params.html.erb +42 -0
  37. data/app/views/apipie/apipies/_params_plain.html.erb +20 -0
  38. data/app/views/apipie/apipies/apipie_404.html.erb +17 -0
  39. data/app/views/apipie/apipies/apipie_checksum.json.erb +1 -0
  40. data/app/views/apipie/apipies/getting_started.html.erb +6 -0
  41. data/app/views/apipie/apipies/index.html.erb +56 -0
  42. data/app/views/apipie/apipies/method.html.erb +41 -0
  43. data/app/views/apipie/apipies/plain.html.erb +77 -0
  44. data/app/views/apipie/apipies/resource.html.erb +80 -0
  45. data/app/views/apipie/apipies/static.html.erb +103 -0
  46. data/app/views/layouts/apipie/apipie.html.erb +27 -0
  47. data/config/locales/de.yml +28 -0
  48. data/config/locales/en.yml +32 -0
  49. data/config/locales/es.yml +28 -0
  50. data/config/locales/fr.yml +31 -0
  51. data/config/locales/it.yml +31 -0
  52. data/config/locales/ja.yml +31 -0
  53. data/config/locales/pl.yml +28 -0
  54. data/config/locales/pt-BR.yml +28 -0
  55. data/config/locales/ru.yml +28 -0
  56. data/config/locales/tr.yml +28 -0
  57. data/config/locales/zh-CN.yml +28 -0
  58. data/config/locales/zh-TW.yml +28 -0
  59. data/images/screenshot-1.png +0 -0
  60. data/images/screenshot-2.png +0 -0
  61. data/lib/apipie/apipie_module.rb +83 -0
  62. data/lib/apipie/application.rb +462 -0
  63. data/lib/apipie/configuration.rb +186 -0
  64. data/lib/apipie/dsl_definition.rb +607 -0
  65. data/lib/apipie/error_description.rb +44 -0
  66. data/lib/apipie/errors.rb +86 -0
  67. data/lib/apipie/extractor.rb +177 -0
  68. data/lib/apipie/extractor/collector.rb +117 -0
  69. data/lib/apipie/extractor/recorder.rb +166 -0
  70. data/lib/apipie/extractor/writer.rb +454 -0
  71. data/lib/apipie/helpers.rb +73 -0
  72. data/lib/apipie/markup.rb +48 -0
  73. data/lib/apipie/method_description.rb +273 -0
  74. data/lib/apipie/middleware/checksum_in_headers.rb +35 -0
  75. data/lib/apipie/param_description.rb +280 -0
  76. data/lib/apipie/railtie.rb +9 -0
  77. data/lib/apipie/resource_description.rb +124 -0
  78. data/lib/apipie/response_description.rb +131 -0
  79. data/lib/apipie/response_description_adapter.rb +200 -0
  80. data/lib/apipie/routes_formatter.rb +33 -0
  81. data/lib/apipie/routing.rb +16 -0
  82. data/lib/apipie/rspec/response_validation_helper.rb +192 -0
  83. data/lib/apipie/see_description.rb +39 -0
  84. data/lib/apipie/static_dispatcher.rb +69 -0
  85. data/lib/apipie/swagger_generator.rb +707 -0
  86. data/lib/apipie/tag_list_description.rb +11 -0
  87. data/lib/apipie/validator.rb +526 -0
  88. data/lib/apipie/version.rb +3 -0
  89. data/lib/apipierails3.rb +25 -0
  90. data/lib/generators/apipie/install/README +6 -0
  91. data/lib/generators/apipie/install/install_generator.rb +25 -0
  92. data/lib/generators/apipie/install/templates/initializer.rb.erb +7 -0
  93. data/lib/generators/apipie/views_generator.rb +11 -0
  94. data/lib/tasks/apipie.rake +345 -0
  95. data/rel-eng/packages/.readme +3 -0
  96. data/rel-eng/packages/rubygem-apipie-rails +1 -0
  97. data/rel-eng/tito.props +5 -0
  98. data/spec/controllers/api/v1/architectures_controller_spec.rb +29 -0
  99. data/spec/controllers/api/v2/architectures_controller_spec.rb +12 -0
  100. data/spec/controllers/api/v2/nested/resources_controller_spec.rb +11 -0
  101. data/spec/controllers/apipies_controller_spec.rb +273 -0
  102. data/spec/controllers/concerns_controller_spec.rb +42 -0
  103. data/spec/controllers/extended_controller_spec.rb +11 -0
  104. data/spec/controllers/users_controller_spec.rb +740 -0
  105. data/spec/dummy/Rakefile +7 -0
  106. data/spec/dummy/app/controllers/api/base_controller.rb +4 -0
  107. data/spec/dummy/app/controllers/api/v1/architectures_controller.rb +43 -0
  108. data/spec/dummy/app/controllers/api/v1/base_controller.rb +11 -0
  109. data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +30 -0
  110. data/spec/dummy/app/controllers/api/v2/base_controller.rb +11 -0
  111. data/spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb +32 -0
  112. data/spec/dummy/app/controllers/api/v2/nested/resources_controller.rb +33 -0
  113. data/spec/dummy/app/controllers/application_controller.rb +18 -0
  114. data/spec/dummy/app/controllers/concerns/extending_concern.rb +11 -0
  115. data/spec/dummy/app/controllers/concerns/sample_controller.rb +41 -0
  116. data/spec/dummy/app/controllers/concerns_controller.rb +8 -0
  117. data/spec/dummy/app/controllers/extended_controller.rb +14 -0
  118. data/spec/dummy/app/controllers/files_controller.rb +5 -0
  119. data/spec/dummy/app/controllers/overridden_concerns_controller.rb +31 -0
  120. data/spec/dummy/app/controllers/pets_controller.rb +408 -0
  121. data/spec/dummy/app/controllers/pets_using_auto_views_controller.rb +73 -0
  122. data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +95 -0
  123. data/spec/dummy/app/controllers/tagged_cats_controller.rb +32 -0
  124. data/spec/dummy/app/controllers/tagged_dogs_controller.rb +15 -0
  125. data/spec/dummy/app/controllers/twitter_example_controller.rb +307 -0
  126. data/spec/dummy/app/controllers/users_controller.rb +297 -0
  127. data/spec/dummy/app/views/layouts/application.html.erb +21 -0
  128. data/spec/dummy/config.ru +4 -0
  129. data/spec/dummy/config/application.rb +49 -0
  130. data/spec/dummy/config/boot.rb +10 -0
  131. data/spec/dummy/config/database.yml +21 -0
  132. data/spec/dummy/config/environment.rb +8 -0
  133. data/spec/dummy/config/environments/development.rb +28 -0
  134. data/spec/dummy/config/environments/production.rb +52 -0
  135. data/spec/dummy/config/environments/test.rb +38 -0
  136. data/spec/dummy/config/initializers/apipie.rb +110 -0
  137. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  138. data/spec/dummy/config/initializers/inflections.rb +10 -0
  139. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  140. data/spec/dummy/config/initializers/secret_token.rb +8 -0
  141. data/spec/dummy/config/initializers/session_store.rb +8 -0
  142. data/spec/dummy/config/locales/en.yml +5 -0
  143. data/spec/dummy/config/routes.rb +51 -0
  144. data/spec/dummy/db/.gitkeep +0 -0
  145. data/spec/dummy/doc/apipie_examples.json +1 -0
  146. data/spec/dummy/doc/users/desc_from_file.md +1 -0
  147. data/spec/dummy/public/404.html +26 -0
  148. data/spec/dummy/public/422.html +26 -0
  149. data/spec/dummy/public/500.html +26 -0
  150. data/spec/dummy/public/favicon.ico +0 -0
  151. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  152. data/spec/dummy/script/rails +6 -0
  153. data/spec/lib/application_spec.rb +49 -0
  154. data/spec/lib/extractor/extractor_spec.rb +9 -0
  155. data/spec/lib/extractor/middleware_spec.rb +44 -0
  156. data/spec/lib/extractor/writer_spec.rb +110 -0
  157. data/spec/lib/file_handler_spec.rb +18 -0
  158. data/spec/lib/method_description_spec.rb +98 -0
  159. data/spec/lib/param_description_spec.rb +345 -0
  160. data/spec/lib/param_group_spec.rb +60 -0
  161. data/spec/lib/rake_spec.rb +71 -0
  162. data/spec/lib/resource_description_spec.rb +48 -0
  163. data/spec/lib/swagger/openapi_2_0_schema.json +1607 -0
  164. data/spec/lib/swagger/rake_swagger_spec.rb +139 -0
  165. data/spec/lib/swagger/response_validation_spec.rb +104 -0
  166. data/spec/lib/swagger/swagger_dsl_spec.rb +658 -0
  167. data/spec/lib/validator_spec.rb +113 -0
  168. data/spec/lib/validators/array_validator_spec.rb +85 -0
  169. data/spec/spec_helper.rb +109 -0
  170. data/spec/support/rake.rb +21 -0
  171. metadata +415 -0
@@ -0,0 +1,73 @@
1
+ #
2
+ # demonstration of how the 'describe_own_properties' method can be used
3
+ # to integrate Apipie response descriptions with view generation packages
4
+ # such as, for example, Grape::Entity
5
+ #
6
+
7
+ # Consider a hypothetical SelfDocumentingView class (a stand-in for Grape::Entity
8
+ # for demonstrational purposes). This is an abstract class, supporting the implementation
9
+ # of actual views as subclasses of SelfDocumentingView.
10
+ #
11
+ # A user of SelfDocumentingView would implement a subclass for each desired view. Each such
12
+ # view definition would include, for each field that should be returned in the JSON response,
13
+ # an instance method called v_<name>__<type>.
14
+ #
15
+ # SelfDocumentingView would then scan the subclass for such fields and:
16
+ # 1. Given an id: fetch the matching model and generated a view from it using the field definitions
17
+ # 2. Describe the structure of such views to Apipie using self.describe_own_properties
18
+ #
19
+ # (see the controller implementation below for how such a class might be used)
20
+
21
+ class SelfDocumentingView
22
+ # self.describe_own_properties (a class method) generates the meta-data
23
+ # (i.e., the type description) for the subclass.
24
+ def self.describe_own_properties
25
+ (self.instance_methods - self.class.instance_methods).map{|m|
26
+ if matchdata = /^v_(\w+)__(\w+)$/.match(m)
27
+ Apipie::prop(matchdata[1], matchdata[2])
28
+ end
29
+ }.compact
30
+ end
31
+
32
+ # to_json (an instance method) generates the actual view
33
+ def to_json
34
+ { note: "in an actual implementation of SelfDocumentingView, this method
35
+ would call each v_<name>__<type> method and include its output
36
+ in the response as a (<name>: <value>) pair"
37
+ }
38
+ end
39
+
40
+ def initialize(id)
41
+ load_from_model(id)
42
+ end
43
+
44
+ def load_from_model(id)
45
+ # in a real implementation of SelfDocumentingView, this
46
+ # method would load the fields to be displayed from the model
47
+ # instance identified by 'id'
48
+ end
49
+ end
50
+
51
+
52
+ #
53
+ # ViewOfPet extends SelfDocumentingView to include specific fields
54
+ #
55
+ class ViewOfPet < SelfDocumentingView
56
+ attr_accessor :v_pet_name__string
57
+ attr_accessor :v_animal_type__string
58
+ attr_accessor :v_age__number
59
+ end
60
+
61
+
62
+ class PetsUsingAutoViewsController < ApplicationController
63
+ #-----------------------------------------------------------
64
+ # Method returning an array of AutomatedViewOfPet (where
65
+ # AutomatedViewOfPet is an auto-generated self-describing class)
66
+ # -----------------------------------------------------------
67
+ api :GET, "/pet_described_using_automated_view/:id", "Get the measurements of a single pet"
68
+ param :id, String
69
+ returns ViewOfPet, :desc => "like Pet, but different"
70
+ def pet_described_using_automated_view
71
+ render :plain => ViewOfPet.new(params.id).to_json
72
+ end
73
+ end
@@ -0,0 +1,95 @@
1
+ #----------------------------------------------------------------------------------------------------
2
+ # A "self-describing class" is a class that respond_to? :describe_own_properties
3
+ # and returns an array of Property Descriptions.
4
+ # (The simple way to create Property Description objects is using the Apipie::prop helper function,
5
+ # which is a factory for Apipie::ResponseDescriptionAdapter::PropDesc instances)
6
+ #
7
+ #----------------------------------------------------------------------------------------------------
8
+
9
+
10
+ # in this example, Pet is a self-describing class with only two properties.
11
+ # In a real implementation, the Pet class would actually do something with these properties.
12
+ # Here, the class is defined to only include the describe_own_properties method.
13
+ class Pet
14
+ def self.describe_own_properties
15
+ [
16
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
17
+ Apipie::prop(:animal_type, 'string', {:description => 'Type of pet', :values => ["dog", "cat", "iguana", "kangaroo"]}),
18
+ Apipie::additional_properties(false)
19
+ ]
20
+ end
21
+ end
22
+
23
+ #
24
+ # PetWithMeasurements is a self-describing class with an embedded object
25
+ #
26
+ class PetWithMeasurements
27
+ def self.describe_own_properties
28
+ [
29
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
30
+ Apipie::prop('animal_type', 'string', {:description => 'Type of pet', :values => ["dog", "cat", "iguana", "kangaroo"]}),
31
+ Apipie::prop(:pet_measurements, 'object', {}, [
32
+ Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
33
+ Apipie::prop(:height, 'number', {:description => "Height in inches" }),
34
+ Apipie::prop(:num_legs, 'number', {:description => "Number of legs", :required => false }),
35
+ Apipie::additional_properties(false)
36
+ ])
37
+ ]
38
+ end
39
+ end
40
+
41
+ #
42
+ # PetWithManyMeasurements is a self-describing class with an embedded object
43
+ #
44
+ class PetWithManyMeasurements
45
+ def self.describe_own_properties
46
+ [
47
+ Apipie::prop(:pet_name, 'string', {:description => 'Name of pet', :required => false}),
48
+ Apipie::prop(:many_pet_measurements, 'object', {is_array: true}, [
49
+ Apipie::prop(:weight, 'number', {:description => "Weight in pounds" }),
50
+ Apipie::prop(:height, 'number', {:description => "Height in inches" }),
51
+ ])
52
+ ]
53
+ end
54
+ end
55
+
56
+
57
+
58
+ class PetsUsingSelfDescribingClassesController < ApplicationController
59
+ resource_description do
60
+ description 'A controller to test "returns" using self-describing classes'
61
+ short 'Pets'
62
+ path '/pets2'
63
+ end
64
+
65
+ #-----------------------------------------------------------
66
+ # Method returning an array of Pet (a self-describing class)
67
+ # -----------------------------------------------------------
68
+ api :GET, "/pets_described_as_class", "Get all pets"
69
+ returns :array_of => Pet, :desc => "list of pets"
70
+ def pets_described_as_class
71
+ render :plain => "all pets"
72
+ end
73
+
74
+ #-----------------------------------------------------------
75
+ # Method returning an array of PetWithMeasurements (a self-describing class)
76
+ # -----------------------------------------------------------
77
+ api :GET, "/pets_with_measurements_described_as_class/:id", "Get the measurements of a single pet"
78
+ param :id, String
79
+ returns PetWithMeasurements, :desc => "measurements of the pet"
80
+ def pets_with_measurements_described_as_class
81
+ render :plain => "all pets"
82
+ end
83
+
84
+ #-----------------------------------------------------------
85
+ # Method returning an array of PetWithManyMeasurements (a self-describing class with array field)
86
+ # -----------------------------------------------------------
87
+ api :GET, "/pets_with_many_measurements_as_class/:id", "Get the measurements of a single pet"
88
+ param :id, String
89
+ returns PetWithManyMeasurements, :desc => "measurements of the pet"
90
+ def pets_with_many_measurements_as_class
91
+ render :plain => "all pets"
92
+ end
93
+
94
+ end
95
+
@@ -0,0 +1,32 @@
1
+ #
2
+ # The TagsController defined here provides an example of a resource_description
3
+ # defining a set of tags for the contained methods to include.
4
+ #
5
+
6
+ class TaggedCatsController < ActionController::Base
7
+ resource_description do
8
+ description 'A controller to test "returns"'
9
+ short 'Pets'
10
+ path '/pets'
11
+
12
+ tags(%w[Dogs Pets])
13
+ end
14
+
15
+ #-----------------------------------------------------------
16
+ # simple 'returns' example: a method that returns a cat record
17
+ #-----------------------------------------------------------
18
+ api :GET, "/pets/:id/as_properties", "Get a cat record"
19
+ tags(%w[Animals])
20
+ def show_as_properties
21
+ render :plain => "showing pet properties"
22
+ end
23
+
24
+ #-----------------------------------------------------------
25
+ # simple 'returns' example: a method that returns another cat record
26
+ #-----------------------------------------------------------
27
+ api :GET, "/pets/:id/as_same_properties", "Get a cat record"
28
+ tags("Puma", "Animals")
29
+ def show_as_same_properties
30
+ render :plain => "showing pet properties"
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ #
2
+ # The TagsController defined here provides an example of a
3
+ # tags call without a resource description.
4
+ #
5
+
6
+ class TaggedDogsController < ActionController::Base
7
+ #-----------------------------------------------------------
8
+ # simple 'returns' example: a method that returns a cat record
9
+ #-----------------------------------------------------------
10
+ api :GET, "/pets/:id/as_properties", "Get a dog record"
11
+ tags(%w[Dogs Wolves])
12
+ def show_as_properties
13
+ render :plain => "showing pet properties"
14
+ end
15
+ end
@@ -0,0 +1,307 @@
1
+ class TwitterExampleController < ApplicationController
2
+
3
+ resource_description do
4
+ name 'TwitterUsers'
5
+ short_description 'Users are at the center of everything Twitter: they follow, they favorite, and tweet & retweet.'
6
+ path '/twitter_example/'
7
+ description "Long description of this resource."
8
+ end
9
+
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
+ 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
+ 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.'
14
+
15
+ description <<-EOS
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.
17
+
18
+ This method is crucial for consumers of the {Streaming API}[link:https://dev.twitter.com/pages/streaming_api]. It's also well suited for use in tandem with friends/ids[link:https://dev.twitter.com/doc/get/friends/ids] and followers/ids[link:https://dev.twitter.com/doc/get/followers/ids].
19
+
20
+ === Extended description
21
+ There are a few things to note when using this method.
22
+
23
+ * You must be following a protected user to be able to see their most recent status update. If you don't follow a protected user their status will be removed.
24
+ * The order of user IDs or screen names may not match the order of users in the returned array.
25
+ * If a requested user is unknown, suspended, or deleted, then that user will not be returned in the results list.
26
+ * You are strongly encouraged to use a POST for larger requests.
27
+ EOS
28
+ def lookup
29
+ render :text => "lookup"
30
+ end
31
+
32
+ api :GET, '/twitter_example/profile_image/:screen_name', 'Access the profile image in various sizes for the user with the indicated screen_name.'
33
+ param :screen_name, String, :required => true, :desc => 'The screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.'
34
+ param :size, ['bigger','normal','mini','original'], :desc => <<-EOS
35
+ Specifies the size of image to fetch. Not specifying a size will give the default, normal size of 48px by 48px. Valid options include:
36
+
37
+ * bigger - 73px by 73px
38
+ * normal - 48px by 48px
39
+ * mini - 24px by 24px
40
+ * original - undefined. This will be the size the image was originally uploaded in. The filesize of original images can be very big so use this parameter with caution.
41
+ EOS
42
+ description <<-EOS
43
+ Access the profile image in various sizes for the user with the indicated screen_name. If no size is provided the normal image is returned.
44
+
45
+ This resource does not return JSON or XML, but instead returns a 302 redirect to the actual image resource.
46
+
47
+ This method should only be used by application developers to lookup or check the profile image URL for a user. This method must not be used as the image source URL presented to users of your application.
48
+ EOS
49
+ def profile_image
50
+ render :text => "profile_image of '#{params[:screen_name]}'"
51
+ end
52
+
53
+ api :GET, '/twitter_example/search', 'Runs a search for users similar to Find People button on Twitter.com.'
54
+ param :q, String, :desc => 'The search query to run against people search.', :required => true
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.'
58
+ description <<-EOS
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
+
61
+ Only the first 1000 matches are available.
62
+
63
+ === Extended description
64
+ This method has a feature-specific rate limit of 60 calls per hour that is applied in conjunction with the main REST API rate limit. Calls to this method will count against the feature-specific rate limit and the main REST API rate limit. If either limit is exhausted, the request will fail. You can monitor the status of the feature-specific rate limit by inspecting the HTTP response headers <tt>X-FeatureRateLimit-Limit</tt>, <tt>X-FeatureRateLimit-Remaining</tt>, and <tt>X-FeatureRateLimit-Reset</tt>. These headers correspond to the <tt>X-RateLimit</tt> headers provided by the main REST API limit.
65
+ EOS
66
+
67
+ example <<-EDOC
68
+ [
69
+ {
70
+ "name": "Twitter API",
71
+ "profile_sidebar_border_color": "87bc44",
72
+ "profile_background_tile": false,
73
+ "profile_sidebar_fill_color": "e0ff92",
74
+ "location": "San Francisco, CA",
75
+ "profile_image_url": "http://a3.twimg.com/profile_images/689684365/api_normal.png",
76
+ "created_at": "Wed May 23 06:01:13 +0000 2007",
77
+ "profile_link_color": "0000ff",
78
+ "favourites_count": 2,
79
+ "url": "http://apiwiki.twitter.com",
80
+ "contributors_enabled": true,
81
+ "utc_offset": -28800,
82
+ "id": 6253282,
83
+ "profile_use_background_image": true,
84
+ "profile_text_color": "000000",
85
+ "protected": false,
86
+ "followers_count": 160753,
87
+ "lang": "en",
88
+ "verified": true,
89
+ "profile_background_color": "c1dfee",
90
+ "geo_enabled": true,
91
+ "notifications": null,
92
+ "description": "The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",
93
+ "time_zone": "Pacific Time (US & Canada)",
94
+ "friends_count": 19,
95
+ "statuses_count": 1858,
96
+ "profile_background_image_url": "http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",
97
+ "status": {
98
+ "coordinates": null,
99
+ "favorited": false,
100
+ "created_at": "Tue Jun 22 16:53:28 +0000 2010",
101
+ "truncated": false,
102
+ "text": "@Demonicpagan possible some part of your signature generation is incorrect & fails for real reasons.. follow up on the list if you suspect",
103
+ "contributors": null,
104
+ "id": 16783999399,
105
+ "geo": null,
106
+ "in_reply_to_user_id": 6339722,
107
+ "place": null,
108
+ "source": "<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>",
109
+ "in_reply_to_screen_name": "Demonicpagan",
110
+ "in_reply_to_status_id": 16781827477
111
+ },
112
+ "screen_name": "twitterapi",
113
+ "following": null
114
+ },
115
+ ...
116
+ {
117
+ "name": "twitterAPI",
118
+ "profile_sidebar_border_color": "87bc44",
119
+ "profile_background_tile": false,
120
+ "profile_sidebar_fill_color": "e0ff92",
121
+ "location": null,
122
+ "profile_image_url": "http://s.twimg.com/a/1277162817/images/default_profile_6_normal.png",
123
+ "created_at": "Fri Jun 04 12:07:25 +0000 2010",
124
+ "profile_link_color": "0000ff",
125
+ "favourites_count": 0,
126
+ "url": null,
127
+ "contributors_enabled": false,
128
+ "utc_offset": null,
129
+ "id": 151851125,
130
+ "profile_use_background_image": true,
131
+ "profile_text_color": "000000",
132
+ "protected": false,
133
+ "followers_count": 0,
134
+ "lang": "ja",
135
+ "verified": false,
136
+ "profile_background_color": "9ae4e8",
137
+ "geo_enabled": false,
138
+ "notifications": false,
139
+ "description": null,
140
+ "time_zone": null,
141
+ "friends_count": 0,
142
+ "statuses_count": 0,
143
+ "profile_background_image_url": "http://s.twimg.com/a/1277162817/images/themes/theme1/bg.png",
144
+ "screen_name": "popoAPI",
145
+ "following": false
146
+ }
147
+ ]
148
+ EDOC
149
+ def search
150
+ render :text => 'search'
151
+ end
152
+
153
+ api :GET, '/twitter_example/:id', 'Returns extended information of a given user, specified by ID or screen name as per the required id parameter.'
154
+ param :id, :number, :required => true, :desc => <<-EOS
155
+ The ID of the user for whom to return results for. Either an id or screen_name is required for this method.
156
+ EOS
157
+ param :screen_name, String, :desc => 'The screen name of the user for...'
158
+ description <<-EDOC
159
+ Returns extended information of a given user, specified by ID or screen name as per the required id parameter. The author's most recent status will be returned inline.
160
+ EDOC
161
+ def show
162
+ render :text => "show #{params}"
163
+ end
164
+
165
+ api :GET, '/twitter_example/contributors', 'Returns an array of users who can contribute to the specified account.'
166
+ param :user_id, Integer, :desc => 'The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.'
167
+ param :screen_name, String, :desc => 'The screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.'
168
+ param :include_entities, String
169
+ param :skip_status, ['t','true','1'],
170
+ :description => 'When set to either true, t or 1 statuses will not be included in the returned user objects.'
171
+
172
+ description "Look at examples."
173
+
174
+ example <<-EDOC
175
+ GET https://api.twitter.com/1/twitter_example/contributors.json?screen_name=twitterapi&include_entities=true&skip_status=true
176
+ [
177
+ {
178
+ "profile_sidebar_border_color": "C0DEED",
179
+ "profile_background_tile": false,
180
+ "name": "Matt Harris",
181
+ "profile_sidebar_fill_color": "DDEEF6",
182
+ "expanded_url": "http://themattharris.com",
183
+ "created_at": "Sat Feb 17 20:49:54 +0000 2007",
184
+ "location": "SFO/LHR/YVR/JAX/IAD/AUS",
185
+ "profile_image_url": "http://a1.twimg.com/profile_images/554181350/matt_normal.jpg",
186
+ "follow_request_sent": false,
187
+ "is_translator": false,
188
+ "profile_link_color": "0084B4",
189
+ "id_str": "777925",
190
+ "entities": {
191
+ "urls": [
192
+
193
+ ],
194
+ "hashtags": [
195
+
196
+ ],
197
+ "user_mentions": [
198
+ {
199
+ "name": "Cindy Li",
200
+ "id_str": "29733",
201
+ "id": 29733,
202
+ "indices": [
203
+ 45,
204
+ 53
205
+ ],
206
+ "screen_name": "cindyli"
207
+ }
208
+ ]
209
+ },
210
+ "default_profile": true,
211
+ "url": "http://t.co/292MnqA",
212
+ "contributors_enabled": false,
213
+ "favourites_count": 120,
214
+ "id": 777925,
215
+ "utc_offset": -28800,
216
+ "listed_count": 271,
217
+ "profile_use_background_image": true,
218
+ "followers_count": 6242,
219
+ "lang": "en",
220
+ "protected": false,
221
+ "profile_text_color": "333333",
222
+ "profile_background_color": "C0DEED",
223
+ "time_zone": "Pacific Time (US & Canada)",
224
+ "geo_enabled": true,
225
+ "description": "Developer Advocate at Twitter and married to @cindyli. NASA enthusiast, British expat and all around geek living in San Francisco.",
226
+ "notifications": false,
227
+ "verified": false,
228
+ "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png",
229
+ "statuses_count": 3835,
230
+ "display_url": "themattharris.com",
231
+ "friends_count": 360,
232
+ "default_profile_image": false,
233
+ "following": false,
234
+ "show_all_inline_media": false,
235
+ "screen_name": "themattharris"
236
+ },
237
+ ...
238
+ ]
239
+ EDOC
240
+ example <<-EDOC
241
+ Another example...
242
+ {
243
+ "profile_sidebar_border_color": "547980",
244
+ "profile_background_tile": true,
245
+ "name": "Ryan Sarver",
246
+ "profile_sidebar_fill_color": "F8FCF2",
247
+ "expanded_url": "http://sarver.org",
248
+ "created_at": "Mon Feb 26 18:05:55 +0000 2007",
249
+ "location": "San Francisco, CA",
250
+ "profile_image_url": "http://a2.twimg.com/profile_images/644997837/ryan_sarver_twitter_big_normal.jpg",
251
+ "follow_request_sent": false,
252
+ "is_translator": false,
253
+ "profile_link_color": "547980",
254
+ "id_str": "795649",
255
+ "entities": {
256
+ "urls": [
257
+
258
+ ],
259
+ "hashtags": [
260
+
261
+ ],
262
+ "user_mentions": [
263
+
264
+ ]
265
+ },
266
+ "default_profile": false,
267
+ "contributors_enabled": true,
268
+ "url": "http://t.co/Lzsetyk",
269
+ "favourites_count": 246,
270
+ "id": 795649,
271
+ "utc_offset": -28800,
272
+ "profile_use_background_image": true,
273
+ "listed_count": 1384,
274
+ "followers_count": 280756,
275
+ "lang": "en",
276
+ "protected": false,
277
+ "profile_text_color": "594F4F",
278
+ "profile_background_color": "45ADA8",
279
+ "time_zone": "Pacific Time (US & Canada)",
280
+ "geo_enabled": true,
281
+ "description": "platform/api at twitter",
282
+ "notifications": false,
283
+ "verified": false,
284
+ "friends_count": 1022,
285
+ "profile_background_image_url": "http://a0.twimg.com/profile_background_images/113854313/xa60e82408188860c483d73444d53e21.png",
286
+ "display_url": "sarver.org",
287
+ "default_profile_image": false,
288
+ "statuses_count": 7031,
289
+ "following": false,
290
+ "show_all_inline_media": true,
291
+ "screen_name": "rsarver"
292
+ }
293
+ EDOC
294
+ def contributors
295
+ render :text => 'contributors'
296
+ end
297
+
298
+ def index
299
+ render :text => 'twitter example'
300
+ end
301
+
302
+ api :GET, '/twitter_example/{id}/followers', 'Find the followers for the given screen name'
303
+ tags %w[following index search]
304
+ def followers
305
+ render :text => 'followers'
306
+ end
307
+ end