apipie-rails-jq 1.4.3.pre.beta.pre.jq.1
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 +7 -0
- data/.github/workflows/build.yml +32 -0
- data/.github/workflows/rubocop-challenger.yml +26 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.rubocop.yml +132 -0
- data/.rubocop_todo.yml +1967 -0
- data/.vscode/settings.json +3 -0
- data/APACHE-LICENSE-2.0 +202 -0
- data/CHANGELOG.md +693 -0
- data/Gemfile +19 -0
- data/MIT-LICENSE +20 -0
- data/NOTICE +4 -0
- data/PROPOSAL_FOR_RESPONSE_DESCRIPTIONS.md +244 -0
- data/README.md +2088 -0
- data/Rakefile +8 -0
- data/apipie-rails.gemspec +44 -0
- data/app/controllers/apipie/apipies_controller.rb +184 -0
- data/app/helpers/apipie_helper.rb +10 -0
- data/app/public/apipie/javascripts/apipie.js +6 -0
- data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +167 -0
- data/app/public/apipie/javascripts/bundled/bootstrap.js +2280 -0
- data/app/public/apipie/javascripts/bundled/jquery.js +2 -0
- data/app/public/apipie/javascripts/bundled/prettify.js +28 -0
- data/app/public/apipie/stylesheets/application.css +7 -0
- data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +9 -0
- data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +9 -0
- data/app/public/apipie/stylesheets/bundled/prettify.css +30 -0
- data/app/views/apipie/apipies/_deprecation.html.erb +16 -0
- data/app/views/apipie/apipies/_disqus.html.erb +13 -0
- data/app/views/apipie/apipies/_errors.html.erb +23 -0
- data/app/views/apipie/apipies/_headers.html.erb +26 -0
- data/app/views/apipie/apipies/_languages.erb +6 -0
- data/app/views/apipie/apipies/_metadata.erb +1 -0
- data/app/views/apipie/apipies/_method_detail.erb +63 -0
- data/app/views/apipie/apipies/_params.html.erb +49 -0
- data/app/views/apipie/apipies/_params_plain.html.erb +21 -0
- data/app/views/apipie/apipies/apipie_404.html.erb +17 -0
- data/app/views/apipie/apipies/apipie_checksum.json.erb +1 -0
- data/app/views/apipie/apipies/getting_started.html.erb +6 -0
- data/app/views/apipie/apipies/index.html.erb +56 -0
- data/app/views/apipie/apipies/method.html.erb +41 -0
- data/app/views/apipie/apipies/plain.html.erb +77 -0
- data/app/views/apipie/apipies/resource.html.erb +80 -0
- data/app/views/apipie/apipies/static.html.erb +103 -0
- data/app/views/layouts/apipie/apipie.html.erb +27 -0
- data/config/locales/de.yml +28 -0
- data/config/locales/en.yml +41 -0
- data/config/locales/es.yml +28 -0
- data/config/locales/fr.yml +31 -0
- data/config/locales/it.yml +41 -0
- data/config/locales/ja.yml +31 -0
- data/config/locales/ko.yml +32 -0
- data/config/locales/pl.yml +28 -0
- data/config/locales/pt-BR.yml +28 -0
- data/config/locales/ru.yml +28 -0
- data/config/locales/tr.yml +28 -0
- data/config/locales/zh-CN.yml +28 -0
- data/config/locales/zh-TW.yml +28 -0
- data/gemfiles/Gemfile.tools +9 -0
- data/images/screenshot-1.png +0 -0
- data/images/screenshot-2.png +0 -0
- data/lib/apipie/apipie_module.rb +83 -0
- data/lib/apipie/application.rb +499 -0
- data/lib/apipie/configuration.rb +196 -0
- data/lib/apipie/core_ext/route.rb +9 -0
- data/lib/apipie/dsl_definition.rb +630 -0
- data/lib/apipie/error_description.rb +46 -0
- data/lib/apipie/errors.rb +86 -0
- data/lib/apipie/extractor/collector.rb +116 -0
- data/lib/apipie/extractor/recorder.rb +193 -0
- data/lib/apipie/extractor/writer.rb +454 -0
- data/lib/apipie/extractor.rb +181 -0
- data/lib/apipie/generator/config.rb +12 -0
- data/lib/apipie/generator/generator.rb +2 -0
- data/lib/apipie/generator/swagger/computed_interface_id.rb +23 -0
- data/lib/apipie/generator/swagger/config.rb +80 -0
- data/lib/apipie/generator/swagger/context.rb +38 -0
- data/lib/apipie/generator/swagger/method_description/api_decorator.rb +20 -0
- data/lib/apipie/generator/swagger/method_description/api_schema_service.rb +89 -0
- data/lib/apipie/generator/swagger/method_description/decorator.rb +22 -0
- data/lib/apipie/generator/swagger/method_description/parameters_service.rb +139 -0
- data/lib/apipie/generator/swagger/method_description/response_schema_service.rb +46 -0
- data/lib/apipie/generator/swagger/method_description/response_service.rb +71 -0
- data/lib/apipie/generator/swagger/method_description.rb +2 -0
- data/lib/apipie/generator/swagger/operation_id.rb +51 -0
- data/lib/apipie/generator/swagger/param_description/builder.rb +114 -0
- data/lib/apipie/generator/swagger/param_description/composite.rb +119 -0
- data/lib/apipie/generator/swagger/param_description/description.rb +15 -0
- data/lib/apipie/generator/swagger/param_description/in.rb +37 -0
- data/lib/apipie/generator/swagger/param_description/name.rb +18 -0
- data/lib/apipie/generator/swagger/param_description/path_params_composite.rb +61 -0
- data/lib/apipie/generator/swagger/param_description/referenced_composite.rb +36 -0
- data/lib/apipie/generator/swagger/param_description/type.rb +132 -0
- data/lib/apipie/generator/swagger/param_description.rb +18 -0
- data/lib/apipie/generator/swagger/path_decorator.rb +36 -0
- data/lib/apipie/generator/swagger/referenced_definitions.rb +17 -0
- data/lib/apipie/generator/swagger/resource_description_collection.rb +30 -0
- data/lib/apipie/generator/swagger/resource_description_composite.rb +56 -0
- data/lib/apipie/generator/swagger/schema.rb +63 -0
- data/lib/apipie/generator/swagger/swagger.rb +2 -0
- data/lib/apipie/generator/swagger/type.rb +16 -0
- data/lib/apipie/generator/swagger/type_extractor.rb +51 -0
- data/lib/apipie/generator/swagger/warning.rb +74 -0
- data/lib/apipie/generator/swagger/warning_writer.rb +54 -0
- data/lib/apipie/helpers.rb +73 -0
- data/lib/apipie/markup.rb +52 -0
- data/lib/apipie/method_description/api.rb +12 -0
- data/lib/apipie/method_description/apis_service.rb +82 -0
- data/lib/apipie/method_description.rb +230 -0
- data/lib/apipie/middleware/checksum_in_headers.rb +35 -0
- data/lib/apipie/param_description/deprecation.rb +24 -0
- data/lib/apipie/param_description.rb +313 -0
- data/lib/apipie/railtie.rb +9 -0
- data/lib/apipie/resource_description.rb +152 -0
- data/lib/apipie/response_description.rb +157 -0
- data/lib/apipie/response_description_adapter.rb +202 -0
- data/lib/apipie/routes_formatter.rb +33 -0
- data/lib/apipie/routing.rb +16 -0
- data/lib/apipie/rspec/response_validation_helper.rb +194 -0
- data/lib/apipie/see_description.rb +39 -0
- data/lib/apipie/static_dispatcher.rb +75 -0
- data/lib/apipie/swagger_generator.rb +45 -0
- data/lib/apipie/tag_list_description.rb +11 -0
- data/lib/apipie/validator.rb +552 -0
- data/lib/apipie/version.rb +3 -0
- data/lib/apipie-rails.rb +60 -0
- data/lib/generators/apipie/install/README +6 -0
- data/lib/generators/apipie/install/install_generator.rb +25 -0
- data/lib/generators/apipie/install/templates/initializer.rb.erb +7 -0
- data/lib/generators/apipie/views_generator.rb +11 -0
- data/lib/tasks/apipie.rake +355 -0
- data/rel-eng/gem_release.ipynb +398 -0
- data/rel-eng/packages/.readme +3 -0
- data/rel-eng/packages/rubygem-apipie-rails +1 -0
- data/rel-eng/tito.props +5 -0
- data/spec/controllers/api/v1/architectures_controller_spec.rb +29 -0
- data/spec/controllers/api/v2/architectures_controller_spec.rb +19 -0
- data/spec/controllers/api/v2/empty_middle_controller_spec.rb +23 -0
- data/spec/controllers/api/v2/nested/resources_controller_spec.rb +27 -0
- data/spec/controllers/api/v2/sub/footguns_controller_spec.rb +19 -0
- data/spec/controllers/concerns_controller_spec.rb +42 -0
- data/spec/controllers/extended_controller_spec.rb +14 -0
- data/spec/controllers/included_param_group_controller_spec.rb +13 -0
- data/spec/controllers/pets_controller_spec.rb +98 -0
- data/spec/controllers/users_controller_spec.rb +794 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/api/base_controller.rb +4 -0
- data/spec/dummy/app/controllers/api/v1/architectures_controller.rb +43 -0
- data/spec/dummy/app/controllers/api/v1/base_controller.rb +11 -0
- data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +31 -0
- data/spec/dummy/app/controllers/api/v2/base_controller.rb +17 -0
- data/spec/dummy/app/controllers/api/v2/empty_middle_controller.rb +14 -0
- data/spec/dummy/app/controllers/api/v2/nested/architectures_controller.rb +32 -0
- data/spec/dummy/app/controllers/api/v2/nested/resources_controller.rb +33 -0
- data/spec/dummy/app/controllers/api/v2/sub/footguns_controller.rb +30 -0
- data/spec/dummy/app/controllers/application_controller.rb +18 -0
- data/spec/dummy/app/controllers/concerns_controller.rb +8 -0
- data/spec/dummy/app/controllers/extended_controller.rb +14 -0
- data/spec/dummy/app/controllers/extending_concern.rb +10 -0
- data/spec/dummy/app/controllers/files_controller.rb +5 -0
- data/spec/dummy/app/controllers/included_param_group_controller.rb +19 -0
- data/spec/dummy/app/controllers/overridden_concerns_controller.rb +31 -0
- data/spec/dummy/app/controllers/pets_controller.rb +408 -0
- data/spec/dummy/app/controllers/pets_using_auto_views_controller.rb +73 -0
- data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +95 -0
- data/spec/dummy/app/controllers/sample_controller.rb +39 -0
- data/spec/dummy/app/controllers/tagged_cats_controller.rb +32 -0
- data/spec/dummy/app/controllers/tagged_dogs_controller.rb +15 -0
- data/spec/dummy/app/controllers/twitter_example_controller.rb +307 -0
- data/spec/dummy/app/controllers/users_controller.rb +310 -0
- data/spec/dummy/app/helpers/random_param_group.rb +8 -0
- data/spec/dummy/app/views/layouts/application.html.erb +21 -0
- data/spec/dummy/components/test_engine/Gemfile +6 -0
- data/spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb +4 -0
- data/spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb +37 -0
- data/spec/dummy/components/test_engine/config/routes.rb +3 -0
- data/spec/dummy/components/test_engine/db/.gitkeep +0 -0
- data/spec/dummy/components/test_engine/lib/test_engine.rb +7 -0
- data/spec/dummy/components/test_engine/test_engine.gemspec +11 -0
- data/spec/dummy/config/application.rb +47 -0
- data/spec/dummy/config/boot.rb +12 -0
- data/spec/dummy/config/database.yml +21 -0
- data/spec/dummy/config/environment.rb +8 -0
- data/spec/dummy/config/environments/development.rb +25 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +33 -0
- data/spec/dummy/config/initializers/apipie.rb +110 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +61 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/doc/apipie_examples.json +1 -0
- data/spec/dummy/doc/users/desc_from_file.md +1 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/lib/apipie/apipies_controller_spec.rb +345 -0
- data/spec/lib/apipie/application_spec.rb +62 -0
- data/spec/lib/apipie/configuration_spec.rb +38 -0
- data/spec/lib/apipie/extractor/collector_spec.rb +57 -0
- data/spec/lib/apipie/extractor/recorder/middleware_spec.rb +44 -0
- data/spec/lib/apipie/extractor/recorder_spec.rb +77 -0
- data/spec/lib/apipie/extractor/writer_spec.rb +112 -0
- data/spec/lib/apipie/extractor_spec.rb +9 -0
- data/spec/lib/apipie/file_handler_spec.rb +25 -0
- data/spec/lib/apipie/generator/swagger/config_spec.rb +19 -0
- data/spec/lib/apipie/generator/swagger/context_spec.rb +56 -0
- data/spec/lib/apipie/generator/swagger/method_description/api_schema_service_spec.rb +119 -0
- data/spec/lib/apipie/generator/swagger/method_description/response_schema_service_spec.rb +105 -0
- data/spec/lib/apipie/generator/swagger/method_description/response_service_spec.rb +62 -0
- data/spec/lib/apipie/generator/swagger/operation_id_spec.rb +63 -0
- data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +245 -0
- data/spec/lib/apipie/generator/swagger/param_description/composite_spec.rb +95 -0
- data/spec/lib/apipie/generator/swagger/param_description/description_spec.rb +79 -0
- data/spec/lib/apipie/generator/swagger/param_description/in_spec.rb +86 -0
- data/spec/lib/apipie/generator/swagger/param_description/name_spec.rb +81 -0
- data/spec/lib/apipie/generator/swagger/param_description/type_spec.rb +210 -0
- data/spec/lib/apipie/generator/swagger/param_description_spec.rb +28 -0
- data/spec/lib/apipie/generator/swagger/path_decorator_spec.rb +57 -0
- data/spec/lib/apipie/generator/swagger/referenced_definitions_spec.rb +35 -0
- data/spec/lib/apipie/generator/swagger/resource_description_composite_spec.rb +37 -0
- data/spec/lib/apipie/generator/swagger/resource_descriptions_collection_spec.rb +57 -0
- data/spec/lib/apipie/generator/swagger/schema_spec.rb +89 -0
- data/spec/lib/apipie/generator/swagger/type_extractor_spec.rb +38 -0
- data/spec/lib/apipie/generator/swagger/warning_spec.rb +51 -0
- data/spec/lib/apipie/generator/swagger/warning_writer_spec.rb +71 -0
- data/spec/lib/apipie/method_description/apis_service_spec.rb +60 -0
- data/spec/lib/apipie/method_description_spec.rb +133 -0
- data/spec/lib/apipie/no_documented_method_spec.rb +17 -0
- data/spec/lib/apipie/param_description/deprecation_spec.rb +31 -0
- data/spec/lib/apipie/param_description_spec.rb +671 -0
- data/spec/lib/apipie/param_group_spec.rb +61 -0
- data/spec/lib/apipie/resource_description_spec.rb +91 -0
- data/spec/lib/apipie/response_description/response_object_spec.rb +22 -0
- data/spec/lib/apipie/response_description_spec.rb +56 -0
- data/spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb +35 -0
- data/spec/lib/apipie/swagger_generator_spec.rb +94 -0
- data/spec/lib/apipie/validator_spec.rb +149 -0
- data/spec/lib/rake_spec.rb +69 -0
- data/spec/lib/swagger/openapi_2_0_schema.json +1614 -0
- data/spec/lib/swagger/rake_swagger_spec.rb +159 -0
- data/spec/lib/swagger/swagger_dsl_spec.rb +664 -0
- data/spec/lib/validators/array_validator_spec.rb +85 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/support/custom_bool_validator.rb +17 -0
- data/spec/support/rake.rb +21 -0
- data/spec/test_engine/memes_controller_spec.rb +10 -0
- metadata +499 -0
@@ -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 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
|
+
|
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, %w[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. 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
|
+
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, %w[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
|
@@ -0,0 +1,310 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
|
3
|
+
resource_description do
|
4
|
+
short 'Site members'
|
5
|
+
path '/users'
|
6
|
+
formats ['json']
|
7
|
+
param :id, Integer, :desc => "User ID", :required => false
|
8
|
+
param :legacy_param, Hash, :desc => 'Deprecated parameter not documented', :show => false, :required => false do
|
9
|
+
param :resource_param, Hash, :desc => 'Param description for all methods' do
|
10
|
+
param :ausername, String, :desc => "Username for login", :required => true
|
11
|
+
param :apassword, String, :desc => "Password for login", :required => true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
api_version "development"
|
15
|
+
error 404, "Missing", :meta => {:some => "metadata"}
|
16
|
+
error 500, "Server crashed for some <%= reason %>"
|
17
|
+
meta :new_style => true, :author => { :name => 'John', :surname => 'Doe' }
|
18
|
+
description <<-EOS
|
19
|
+
== Long description
|
20
|
+
|
21
|
+
Example resource for rest api documentation
|
22
|
+
|
23
|
+
These can now be accessed in <tt>shared/header</tt> with:
|
24
|
+
|
25
|
+
Headline: <%= headline %>
|
26
|
+
First name: <%= person.first_name %>
|
27
|
+
|
28
|
+
If you need to find out whether a certain local variable has been assigned a value in a particular render call,
|
29
|
+
you need to use the following pattern:
|
30
|
+
|
31
|
+
<% if local_assigns.has_key? :headline %>
|
32
|
+
Headline: <%= headline %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
|
36
|
+
|
37
|
+
=== Template caching
|
38
|
+
|
39
|
+
By default, Rails will compile each template to a method in order to render it. When you alter a template,
|
40
|
+
Rails will check the file's modification time and recompile it in development mode.
|
41
|
+
EOS
|
42
|
+
header :CommonHeader, 'Common header description', required: true
|
43
|
+
end
|
44
|
+
|
45
|
+
description <<-eos
|
46
|
+
= Action View Base
|
47
|
+
|
48
|
+
Action View templates can be written in several ways. If the template file has a <tt>.erb</tt> extension then it uses a mixture of ERb
|
49
|
+
(included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then Jim Weirich's Builder::XmlMarkup library is used.
|
50
|
+
|
51
|
+
== ERB
|
52
|
+
|
53
|
+
You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
|
54
|
+
following loop for names:
|
55
|
+
|
56
|
+
<b>Names of all the people</b>
|
57
|
+
<% @people.each do |person| %>
|
58
|
+
Name: <%= person.name %><br/>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this
|
62
|
+
is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
|
63
|
+
|
64
|
+
<%# WRONG %>
|
65
|
+
Hi, Mr. <% puts "Frodo" %>
|
66
|
+
|
67
|
+
If you absolutely must write from within a function use +concat+.
|
68
|
+
|
69
|
+
<%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
|
70
|
+
|
71
|
+
=== Using sub templates
|
72
|
+
|
73
|
+
Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
|
74
|
+
classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
|
75
|
+
|
76
|
+
<%= render "shared/header" %>
|
77
|
+
Something really specific and terrific
|
78
|
+
<%= render "shared/footer" %>
|
79
|
+
|
80
|
+
As you see, we use the output embeddings for the render methods. The render call itself will just return a string holding the
|
81
|
+
result of the rendering. The output embedding writes it to the current template.
|
82
|
+
|
83
|
+
But you don't have to restrict yourself to static includes. Templates can share variables amongst themselves by using instance
|
84
|
+
variables defined using the regular embedding tags. Like this:
|
85
|
+
|
86
|
+
<% @page_title = "A Wonderful Hello" %>
|
87
|
+
<%= render "shared/header" %>
|
88
|
+
|
89
|
+
Now the header can pick up on the <tt>@page_title</tt> variable and use it for outputting a title tag:
|
90
|
+
|
91
|
+
<title><%= @page_title %></title>
|
92
|
+
|
93
|
+
=== Passing local variables to sub templates
|
94
|
+
|
95
|
+
You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
|
96
|
+
|
97
|
+
<%= render "shared/header", { :headline => "Welcome", :person => person } %>
|
98
|
+
|
99
|
+
These can now be accessed in <tt>shared/header</tt> with:
|
100
|
+
|
101
|
+
Headline: <%= headline %>
|
102
|
+
First name: <%= person.first_name %>
|
103
|
+
|
104
|
+
If you need to find out whether a certain local variable has been assigned a value in a particular render call,
|
105
|
+
you need to use the following pattern:
|
106
|
+
|
107
|
+
<% if local_assigns.has_key? :headline %>
|
108
|
+
Headline: <%= headline %>
|
109
|
+
<% end %>
|
110
|
+
|
111
|
+
Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
|
112
|
+
|
113
|
+
=== Template caching
|
114
|
+
|
115
|
+
By default, Rails will compile each template to a method in order to render it. When you alter a template,
|
116
|
+
Rails will check the file's modification time and recompile it in development mode.
|
117
|
+
|
118
|
+
== Builder
|
119
|
+
|
120
|
+
Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object
|
121
|
+
named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
|
122
|
+
|
123
|
+
Here are some basic examples:
|
124
|
+
|
125
|
+
xml.em("emphasized") # => <em>emphasized</em>
|
126
|
+
xml.em { xml.b("emph & bold") } # => <em><b>emph & bold</b></em>
|
127
|
+
xml.a("A Link", "href" => "http://onestepback.org") # => <a href="http://onestepback.org">A Link</a>
|
128
|
+
xml.target("name" => "compile", "option" => "fast") # => <target option="fast" name="compile"\>
|
129
|
+
# NOTE: order of attributes is not specified.
|
130
|
+
|
131
|
+
Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following:
|
132
|
+
|
133
|
+
xml.div do
|
134
|
+
xml.h1(@person.name)
|
135
|
+
xml.p(@person.bio)
|
136
|
+
end
|
137
|
+
|
138
|
+
would produce something like:
|
139
|
+
|
140
|
+
<div>
|
141
|
+
<h1>David Heinemeier Hansson</h1>
|
142
|
+
<p>A product of Danish Design during the Winter of '79...</p>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
A full-length RSS example actually used on Basecamp:
|
146
|
+
|
147
|
+
xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
|
148
|
+
xml.channel do
|
149
|
+
xml.title(@feed_title)
|
150
|
+
xml.link(@url)
|
151
|
+
xml.description "Basecamp: Recent items"
|
152
|
+
xml.language "en-us"
|
153
|
+
xml.ttl "40"
|
154
|
+
|
155
|
+
@recent_items.each do |item|
|
156
|
+
xml.item do
|
157
|
+
xml.title(item_title(item))
|
158
|
+
xml.description(item_description(item)) if item_description(item)
|
159
|
+
xml.pubDate(item_pubDate(item))
|
160
|
+
xml.guid(@person.firm.account.url + @recent_items.url(item))
|
161
|
+
xml.link(@person.firm.account.url + @recent_items.url(item))
|
162
|
+
|
163
|
+
xml.tag!("dc:creator", item.author_name) if item_has_creator?(item)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
More builder documentation can be found at http://builder.rubyforge.org.
|
170
|
+
eos
|
171
|
+
api :GET, "/users/:id", "Show user profile"
|
172
|
+
show false
|
173
|
+
formats %w[json jsonp]
|
174
|
+
error 401, "Unauthorized"
|
175
|
+
error :code => 404, :description => "Not Found"
|
176
|
+
param :id, Integer, :desc => "user id", :required => true
|
177
|
+
param :session, String, :desc => "user is logged in", :required => true, :missing_message => lambda { "session_parameter_is_required" }
|
178
|
+
param :regexp_param, /^[0-9]* years/, :desc => "regexp param"
|
179
|
+
param :regexp2, /\b[A-Z0-9._%+-=]+@[A-Z0-9.-]+.[A-Z]{2,}\b/i, :desc => "email regexp"
|
180
|
+
param :array_param, %w[100 one two 1 2], :desc => "array validator"
|
181
|
+
param :boolean_param, [true, false], :desc => "array validator with boolean"
|
182
|
+
param :proc_param, lambda { |val|
|
183
|
+
val == "param value" ? true : "The only good value is 'param value'."
|
184
|
+
}, :desc => "proc validator"
|
185
|
+
param :briefer_dsl, String, "You dont need :desc => from now"
|
186
|
+
param :meta_param, String, :desc => "A parameter with some additional metadata", :meta => [:some, :more, :info]
|
187
|
+
meta :success_message => "Some message"
|
188
|
+
param :hash_param, Hash, :desc => "Hash param" do
|
189
|
+
param :dummy_hash, Hash do
|
190
|
+
param :dummy_2, String, :required => true
|
191
|
+
end
|
192
|
+
end
|
193
|
+
def show
|
194
|
+
unless params[:session] == "secret_hash"
|
195
|
+
render :plain => "Not authorized", :status => 401
|
196
|
+
return
|
197
|
+
end
|
198
|
+
|
199
|
+
unless params[:id].to_i == 5
|
200
|
+
render :plain => "Not Found", :status => 404 and return
|
201
|
+
end
|
202
|
+
|
203
|
+
render :plain => "OK"
|
204
|
+
end
|
205
|
+
|
206
|
+
def_param_group :credentials do
|
207
|
+
param :name, String, :desc => "Username for login", :required => true
|
208
|
+
param :pass, String, :desc => "Password for login", :required => true
|
209
|
+
end
|
210
|
+
|
211
|
+
def_param_group :user do
|
212
|
+
param :user, Hash, :desc => "User info", :required => true, :action_aware => true do
|
213
|
+
param_group :credentials
|
214
|
+
param :membership, %w[standard premium], :desc => "User membership", :allow_nil => false
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
api :POST, "/users", "Create user"
|
219
|
+
param_group :user
|
220
|
+
param :user, Hash do
|
221
|
+
param :permalink, String
|
222
|
+
end
|
223
|
+
param :facts, Hash, :desc => "Additional optional facts about the user", :allow_nil => true
|
224
|
+
param :age, :number, :desc => "Age is just a number", :allow_blank => true
|
225
|
+
error :unprocessable_entity, 'Unprocessable Entity'
|
226
|
+
def create
|
227
|
+
render :plain => "OK #{params.inspect}"
|
228
|
+
end
|
229
|
+
|
230
|
+
api :PUT, "/users/:id", "Update an user"
|
231
|
+
param_group :user
|
232
|
+
param :comments, Array do
|
233
|
+
param :comment, String
|
234
|
+
end
|
235
|
+
def update
|
236
|
+
render :plain => "OK #{params.inspect}"
|
237
|
+
end
|
238
|
+
|
239
|
+
api :POST, "/users/admin", "Create admin user"
|
240
|
+
param_group :user, :as => :create
|
241
|
+
def admin_create
|
242
|
+
render :plain => "OK #{params.inspect}"
|
243
|
+
end
|
244
|
+
|
245
|
+
api :GET, "/users", "List users"
|
246
|
+
error :code => 401, :desc => "Unauthorized"
|
247
|
+
error :code => 404, :desc => "Not Found"
|
248
|
+
desc "List all users."
|
249
|
+
param :oauth, nil,
|
250
|
+
:desc => "Hide this global param (eg dont need auth here)"
|
251
|
+
def index
|
252
|
+
render :plain => "List of users"
|
253
|
+
end
|
254
|
+
|
255
|
+
api :GET, '/company_users', 'Get company users'
|
256
|
+
api :GET, '/company/:id/users', 'Get users working in given company'
|
257
|
+
param :id, Integer, :desc => "Company ID"
|
258
|
+
def two_urls
|
259
|
+
render :plain => 'List of users'
|
260
|
+
end
|
261
|
+
|
262
|
+
api :GET, '/users/see_another', 'Boring method'
|
263
|
+
show false
|
264
|
+
see 'development#users#create'
|
265
|
+
see 'development#users#index', "very interesting method reference"
|
266
|
+
desc 'This method is boring, look at users#create. It is hidden from documentation.'
|
267
|
+
def see_another
|
268
|
+
render :plain => 'This is very similar to create action'
|
269
|
+
end
|
270
|
+
|
271
|
+
api :GET, '/users/by_department', 'show users from a specific department'
|
272
|
+
param :department, %w[finance operations sales marketing HR], required: false, default_value: "sales"
|
273
|
+
def get_by_department
|
274
|
+
render :plain => 'nothing to see here'
|
275
|
+
end
|
276
|
+
|
277
|
+
api :GET, '/users/in_departments', 'show users from specific departments'
|
278
|
+
param :departments, Array, in: %w[finance operations sales marketing HR], default_value: ['sales']
|
279
|
+
def get_in_departments
|
280
|
+
render :plain => 'nothing to see here'
|
281
|
+
end
|
282
|
+
|
283
|
+
api :GET, '/users/desc_from_file', 'desc from file'
|
284
|
+
document 'users/desc_from_file.md'
|
285
|
+
def desc_from_file
|
286
|
+
render :plain => 'document from file action'
|
287
|
+
end
|
288
|
+
|
289
|
+
api! 'Create user'
|
290
|
+
param_group :user
|
291
|
+
param :user, Hash do
|
292
|
+
param :permalink, String
|
293
|
+
end
|
294
|
+
param :facts, Hash, :desc => "Additional optional facts about the user", :allow_nil => true
|
295
|
+
def create_route
|
296
|
+
end
|
297
|
+
|
298
|
+
api :GET, '/users/action_with_headers'
|
299
|
+
header :RequredHeaderName, 'Required header description', required: true
|
300
|
+
header :OptionalHeaderName, 'Optional header description', required: false, type: 'string'
|
301
|
+
header :HeaderNameWithDefaultValue, 'Header with default value', required: true, default: 'default value'
|
302
|
+
def action_with_headers
|
303
|
+
end
|
304
|
+
|
305
|
+
api :GET, '/users/multiple_required_params'
|
306
|
+
param :required_param1, String, required: true
|
307
|
+
param :required_param2, String, required: true
|
308
|
+
def multiple_required_params
|
309
|
+
end
|
310
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy API</title>
|
5
|
+
<%= Apipie.include_stylesheets %>
|
6
|
+
</head>
|
7
|
+
<body style='background-color: #F5F6F7;'>
|
8
|
+
<div class="container">
|
9
|
+
<div class="row">
|
10
|
+
<div id='container' style='background-color: white;padding:10px;box-shadow:0px 0px 10px rgba(68,68,68,0.6);'>
|
11
|
+
<%= yield %>
|
12
|
+
<%= render 'disqus' if Apipie.configuration.use_disqus? %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<hr>
|
16
|
+
<footer><%= yield :apipie_footer %></footer>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%= Apipie.include_javascripts %>
|
20
|
+
</body>
|
21
|
+
</html>
|