apipie-bindings 0.0.11 → 0.0.12
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 +4 -4
- data/doc/release_notes.md +7 -0
- data/lib/apipie_bindings/version.rb +1 -1
- data/test/dummy/.gitignore +12 -0
- data/test/dummy/Gemfile +6 -0
- data/test/dummy/README.md +33 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/comments_controller.rb +9 -0
- data/test/dummy/app/controllers/concerns/dummy_concern.rb +38 -0
- data/test/dummy/app/controllers/posts_controller.rb +9 -0
- data/test/dummy/app/controllers/users_controller.rb +32 -0
- data/test/dummy/app/lib/dummy/store.rb +50 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +37 -0
- data/test/dummy/config/boot.rb +3 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +22 -0
- data/test/dummy/config/environments/production.rb +64 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/apipie.rb +6 -0
- data/test/dummy/config/initializers/session_store.rb +2 -0
- data/test/dummy/config/routes.rb +9 -0
- data/test/dummy/data/example/users/1/posts/1/comments/1/show.json +7 -0
- data/test/dummy/data/example/users/1/posts/1/show.json +7 -0
- data/test/dummy/data/example/users/1/show.json +6 -0
- data/test/dummy/public/index.html +14 -0
- data/test/unit/action_test.rb +8 -8
- data/test/unit/api_test.rb +16 -16
- data/test/unit/data/dummy.json +1 -0
- data/test/unit/resource_test.rb +8 -8
- metadata +62 -22
- data/test/unit/data/architecture.json +0 -191
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c5360234676ffe74c406a3f1db1c9186121f38c
|
4
|
+
data.tar.gz: 2c494b2c5acaad567f49b21af4faa5a15d3425fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebe8bed0ff3b51162576e26f9dd7b272592f3080b1781519cbdcfb9e14217eb9dc5b012bbf6ef195c5ef22da5578aacd9bb48f4dd0fe2bc7f8af7b36e622baf
|
7
|
+
data.tar.gz: c608be1dcb850cab02b6ddf28706775c96b0850fb343eda45be12b361fa9def08746711dc2bd8d9874012f208d63a2f2687714c1924ababc93c33b1980c0590b
|
data/doc/release_notes.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
3
|
|
4
|
+
### 0.0.12 (2015-03-23)
|
5
|
+
* Add readme to the dummy app
|
6
|
+
* Fix ordering issue in tests
|
7
|
+
* Dummy app for testing purposes
|
8
|
+
* Declare 1.8 dependencies in Gemfile for tests
|
9
|
+
* Allow non-friendly 1.8 gems (Newer libraries supports IPv6)
|
10
|
+
|
4
11
|
### 0.0.11 (2014-11-09)
|
5
12
|
* Added lazy loading of credentials ([#7408](http://projects.theforeman.org/issues/7408))
|
6
13
|
* Separate caches for different API versions ([#18](http://github.com/Apipie/apipie-bindings/issues/18))
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
/public/apipie-cache
|
10
|
+
Gemfile.lock
|
11
|
+
/log/*.log
|
12
|
+
/tmp
|
data/test/dummy/Gemfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
A dummy app with apipie definition allows:
|
2
|
+
|
3
|
+
1. easier adding of more complex cases of documentation (no need
|
4
|
+
to craft the json document manually: just change the dummy app
|
5
|
+
and regenerate the json
|
6
|
+
|
7
|
+
1. easier hanlding of next versions of apipie-rails: every change in the json
|
8
|
+
API can be handled easier and issues spotted sooner as well
|
9
|
+
|
10
|
+
1. easier integration testing: the dummy app is responding almost real data
|
11
|
+
that the bindings can be run against to see the results.
|
12
|
+
|
13
|
+
To regenerate the `dummy.json`, from the apipie-bindings root dir, just
|
14
|
+
delete the test/unit/data/dummy.json and it will be generated again on
|
15
|
+
next rake test or explicitly with `rake test/unit/data/dummy.json`
|
16
|
+
|
17
|
+
The dummy app can be used also for testing against real Rails app,
|
18
|
+
as it serves some dummy data (that can be customized by editing the
|
19
|
+
`data` folder:
|
20
|
+
|
21
|
+
1. bundle install
|
22
|
+
1. bundle exec rails s
|
23
|
+
1. `curl http://localhost:3000/users`
|
24
|
+
|
25
|
+
`curl http://localhost:3000/users/1`
|
26
|
+
|
27
|
+
`curl http://localhost:3000/users/1/posts`
|
28
|
+
|
29
|
+
`curl http://localhost:3000/users/1/posts/1`
|
30
|
+
|
31
|
+
`curl http://localhost:3000/users/1/posts/1/comments`
|
32
|
+
|
33
|
+
`curl http://localhost:3000/users/1/posts/1/comments/1`
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Concerns
|
2
|
+
module DummyConcern
|
3
|
+
extend Apipie::DSL::Concern
|
4
|
+
include ActiveSupport::Concern
|
5
|
+
|
6
|
+
api!
|
7
|
+
def index
|
8
|
+
render :json => Dummy::Store.index(base_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
api!
|
12
|
+
def show
|
13
|
+
render :json => Dummy::Store.show("#{base_path}/#{params[:id]}")
|
14
|
+
end
|
15
|
+
|
16
|
+
api!
|
17
|
+
def create
|
18
|
+
render :json => params
|
19
|
+
end
|
20
|
+
|
21
|
+
api!
|
22
|
+
def update
|
23
|
+
render :json => Dummy::Store.show("#{base_path}/#{params[:id]}")
|
24
|
+
end
|
25
|
+
|
26
|
+
api!
|
27
|
+
def destroy
|
28
|
+
render :json => []
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def base_path
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
include Concerns::DummyConcern
|
3
|
+
|
4
|
+
api!
|
5
|
+
example <<-EXAMPLE
|
6
|
+
GET /users
|
7
|
+
200
|
8
|
+
[ {"user":{"name":"John Doe" }} ]
|
9
|
+
EXAMPLE
|
10
|
+
def index
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
api!
|
15
|
+
param :user, Hash do
|
16
|
+
param :name, String, required: true
|
17
|
+
end
|
18
|
+
def create
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
api!
|
23
|
+
param :name, String, required: true
|
24
|
+
def create_unnested
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def base_path
|
30
|
+
'/users'
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Dummy
|
4
|
+
class Store
|
5
|
+
|
6
|
+
class << self
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :instance, :index, :show
|
9
|
+
|
10
|
+
def instance
|
11
|
+
@store ||= Store.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(base_dir = File.join(Rails.root, '/data/example'))
|
16
|
+
@base_dir = base_dir
|
17
|
+
end
|
18
|
+
|
19
|
+
def index(path, data = {})
|
20
|
+
show_files(path).map { |file| load_json(file) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def show(path, data = {})
|
24
|
+
file = real_path("#{path}/show.json")
|
25
|
+
if File.exists?(file)
|
26
|
+
load_json(file)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def show_files(resource_path)
|
33
|
+
Dir.glob(real_path("#{resource_path}/*/show.json"))
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_from_path(abstract_path)
|
37
|
+
load_json(real_path(abstract_path))
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_json(path)
|
41
|
+
JSON.load(File.read(path))
|
42
|
+
end
|
43
|
+
|
44
|
+
def real_path(path)
|
45
|
+
File.join(@base_dir, path)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "action_view/railtie"
|
6
|
+
|
7
|
+
# Require the gems listed in Gemfile, including any gems
|
8
|
+
# you've limited to :test, :development, or :production.
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
|
11
|
+
module Dummy
|
12
|
+
|
13
|
+
class ObserverMiddleware
|
14
|
+
def initialize(app)
|
15
|
+
@app = app
|
16
|
+
end
|
17
|
+
|
18
|
+
def log(msg)
|
19
|
+
puts msg
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
status, headers, body = @app.call(env)
|
24
|
+
if body.respond_to?(:map)
|
25
|
+
log "#{env['REQUEST_METHOD']} #{env['PATH_INFO']} #{status}"
|
26
|
+
log body.map { |l| " #{l}"}.join("\n")
|
27
|
+
end
|
28
|
+
[status, headers, body]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Application < Rails::Application
|
33
|
+
config.autoload_paths += %w[#{config.root}/app/lib]
|
34
|
+
|
35
|
+
config.middleware.insert_before(ActionDispatch::ShowExceptions, ObserverMiddleware)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Print deprecation notices to the Rails logger.
|
17
|
+
config.active_support.deprecation = :log
|
18
|
+
|
19
|
+
|
20
|
+
# Raises error for missing translations
|
21
|
+
# config.action_view.raise_on_missing_translations = true
|
22
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
20
|
+
# NGINX, varnish or squid.
|
21
|
+
# config.action_dispatch.rack_cache = true
|
22
|
+
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
26
|
+
|
27
|
+
|
28
|
+
# Specifies the header that your server uses for sending files.
|
29
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
30
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
31
|
+
|
32
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
33
|
+
# config.force_ssl = true
|
34
|
+
|
35
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
36
|
+
# when problems arise.
|
37
|
+
config.log_level = :debug
|
38
|
+
|
39
|
+
# Prepend all log lines with the following tags.
|
40
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
41
|
+
|
42
|
+
# Use a different logger for distributed setups.
|
43
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
44
|
+
|
45
|
+
# Use a different cache store in production.
|
46
|
+
# config.cache_store = :mem_cache_store
|
47
|
+
|
48
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
49
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
50
|
+
|
51
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
52
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
53
|
+
# config.action_mailer.raise_delivery_errors = false
|
54
|
+
|
55
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
56
|
+
# the I18n.default_locale when a translation cannot be found).
|
57
|
+
config.i18n.fallbacks = true
|
58
|
+
|
59
|
+
# Send deprecation notices to registered listeners.
|
60
|
+
config.active_support.deprecation = :notify
|
61
|
+
|
62
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
63
|
+
config.log_formatter = ::Logger::Formatter.new
|
64
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Randomize the order test cases are executed.
|
30
|
+
config.active_support.test_order = :random
|
31
|
+
|
32
|
+
# Print deprecation notices to the stderr.
|
33
|
+
config.active_support.deprecation = :stderr
|
34
|
+
|
35
|
+
# Raises error for missing translations
|
36
|
+
# config.action_view.raise_on_missing_translations = true
|
37
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Apipie-bindings demo app</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<pre><code>
|
7
|
+
|
8
|
+
This is a demo app to test the apipie-bindings against. The main
|
9
|
+
purpose is to generate up-to-date apipie.json that the apipie-bindings
|
10
|
+
can consume.
|
11
|
+
|
12
|
+
</code></pre>
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/unit/action_test.rb
CHANGED
@@ -3,12 +3,12 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
3
3
|
describe ApipieBindings::Action do
|
4
4
|
|
5
5
|
let(:resource) { ApipieBindings::API.new({:apidoc_cache_dir => 'test/unit/data',
|
6
|
-
:apidoc_cache_name => '
|
6
|
+
:apidoc_cache_name => 'dummy'}).resource(:users) }
|
7
7
|
|
8
8
|
it "should allow user to call the action" do
|
9
9
|
params = { :a => 1 }
|
10
10
|
headers = { :content_type => 'application/json' }
|
11
|
-
ApipieBindings::API.any_instance.expects(:call).with(:
|
11
|
+
ApipieBindings::API.any_instance.expects(:call).with(:users, :index, params, headers, {})
|
12
12
|
resource.action(:index).call(params, headers)
|
13
13
|
end
|
14
14
|
|
@@ -17,11 +17,11 @@ describe ApipieBindings::Action do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should find suitable route" do
|
20
|
-
resource.action(:index).find_route.path.must_equal "/
|
20
|
+
resource.action(:index).find_route.path.must_equal "/users"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should return params" do
|
24
|
-
resource.action(:create).params.map(&:name).must_equal ['
|
24
|
+
resource.action(:create).params.map(&:name).must_equal ['user']
|
25
25
|
end
|
26
26
|
|
27
27
|
# TODO add tests for more find_route cases
|
@@ -43,20 +43,20 @@ describe ApipieBindings::Action do
|
|
43
43
|
|
44
44
|
it "should validate incorrect params" do
|
45
45
|
e = proc do
|
46
|
-
resource.action(:create).validate!({ :
|
46
|
+
resource.action(:create).validate!({ :user => { :foo => "foo" } })
|
47
47
|
end.must_raise(ApipieBindings::MissingArgumentsError)
|
48
48
|
e.message.must_match /: name$/
|
49
49
|
|
50
50
|
e = proc do
|
51
51
|
# completely different sub-hash; should still fail
|
52
|
-
resource.action(:create).validate!({ :
|
52
|
+
resource.action(:create).validate!({ :apple => { :foo => "foo" } })
|
53
53
|
end.must_raise(ApipieBindings::MissingArgumentsError)
|
54
54
|
e.message.must_match /: name$/
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should accept correct params" do
|
58
|
-
resource.action(:create).validate!({:
|
59
|
-
resource.action(:create_unnested).validate!(:name => "
|
58
|
+
resource.action(:create).validate!({:user => { :name => 'John Doe' } })
|
59
|
+
resource.action(:create_unnested).validate!(:name => "John Doe")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should have name visible in puts" do
|
data/test/unit/api_test.rb
CHANGED
@@ -2,64 +2,64 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
2
|
|
3
3
|
describe ApipieBindings::API do
|
4
4
|
|
5
|
-
let(:api) { ApipieBindings::API.new({:apidoc_cache_dir => 'test/unit/data', :apidoc_cache_name => '
|
5
|
+
let(:api) { ApipieBindings::API.new({:apidoc_cache_dir => 'test/unit/data', :apidoc_cache_name => 'dummy'}) }
|
6
6
|
|
7
7
|
it "should provide resource" do
|
8
|
-
result = api.resource(:
|
8
|
+
result = api.resource(:users)
|
9
9
|
result.must_be_kind_of ApipieBindings::Resource
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should test if resource is available" do
|
13
|
-
api.has_resource?(:
|
13
|
+
api.has_resource?(:users).must_equal true
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should list resources" do
|
17
|
-
api.resources.map(&:name).must_equal [:
|
17
|
+
api.resources.map(&:name).sort_by(&:to_s).must_equal [:comments, :posts, :users]
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should call the method" do
|
21
21
|
params = { :a => 1 }
|
22
22
|
headers = { :content_type => 'application/json' }
|
23
|
-
ApipieBindings::API.any_instance.expects(:http_call).with('get', '/
|
24
|
-
api.call(:
|
23
|
+
ApipieBindings::API.any_instance.expects(:http_call).with('get', '/users', params, headers, {})
|
24
|
+
api.call(:users, :index, params, headers)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should call the method and fill in the params" do
|
28
28
|
params = { :id => 1 }
|
29
29
|
headers = { :content_type => 'application/json' }
|
30
|
-
ApipieBindings::API.any_instance.expects(:http_call).with('get', '/
|
31
|
-
api.call(:
|
30
|
+
ApipieBindings::API.any_instance.expects(:http_call).with('get', '/users/1', {}, headers, {})
|
31
|
+
api.call(:users, :show, params, headers)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return values from examples in dry_run mode" do
|
35
35
|
api.dry_run = true
|
36
|
-
result = api.call(:
|
36
|
+
result = api.call(:users, :index)
|
37
37
|
result.must_be_kind_of Array
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should allow to set dry_run mode in config params" do
|
41
41
|
api = ApipieBindings::API.new({
|
42
42
|
:apidoc_cache_dir => 'test/unit/data',
|
43
|
-
:apidoc_cache_name => '
|
43
|
+
:apidoc_cache_name => 'dummy',
|
44
44
|
:dry_run => true })
|
45
|
-
result = api.call(:
|
45
|
+
result = api.call(:users, :index)
|
46
46
|
result.must_be_kind_of Array
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should allow to set fake response in config params" do
|
50
50
|
api = ApipieBindings::API.new({
|
51
51
|
:apidoc_cache_dir => 'test/unit/data',
|
52
|
-
:apidoc_cache_name => '
|
52
|
+
:apidoc_cache_name => 'dummy',
|
53
53
|
:dry_run => true,
|
54
|
-
:fake_params => { [:
|
55
|
-
result = api.call(:
|
54
|
+
:fake_params => { [:users, :index] => {:default => [] } }} )
|
55
|
+
result = api.call(:users, :index)
|
56
56
|
result.must_be_kind_of Array
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should preserve file in args (#2)" do
|
60
60
|
api = ApipieBindings::API.new({
|
61
61
|
:apidoc_cache_dir => 'test/unit/data',
|
62
|
-
:apidoc_cache_name => '
|
62
|
+
:apidoc_cache_name => 'dummy',
|
63
63
|
:dry_run => true})
|
64
64
|
s = StringIO.new; s << 'foo'
|
65
65
|
headers = {:content_type => 'multipart/form-data', :multipart => true}
|
@@ -127,7 +127,7 @@ describe ApipieBindings::API do
|
|
127
127
|
|
128
128
|
it "should load cache and its name from cache dir" do
|
129
129
|
Dir["#{@dir}/*"].each { |f| File.delete(f) }
|
130
|
-
FileUtils.cp('test/unit/data/
|
130
|
+
FileUtils.cp('test/unit/data/dummy.json', File.join(@dir, 'api_cache.json'))
|
131
131
|
api = ApipieBindings::API.new({:apidoc_cache_dir => @dir})
|
132
132
|
api.apidoc_cache_name.must_equal 'api_cache'
|
133
133
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"docs":{"name":"Dummy","info":"Another API description","copyright":null,"doc_url":"./apipie/1.0","api_url":"/","resources":{"users":{"doc_url":"./apipie/1.0/users","api_url":"/","name":"Users","short_description":null,"full_description":null,"version":"1.0","formats":null,"metadata":null,"methods":[{"doc_url":"./apipie/1.0/users/index","name":"index","apis":[{"api_url":"/users","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":["GET /users\n200\n[ {\"user\":{\"name\":\"John Doe\" }} ]\n"],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/users/show","name":"show","apis":[{"api_url":"/users/:id","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/users/create","name":"create","apis":[{"api_url":"/users","http_method":"POST","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"user","full_name":"user","description":"","required":false,"allow_nil":false,"validator":"Must be a Hash","expected_type":"hash","metadata":null,"show":true,"params":[{"name":"name","full_name":"user[name]","description":"","required":true,"allow_nil":false,"validator":"Must be String","expected_type":"string","metadata":null,"show":true}]}],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/users/update","name":"update","apis":[{"api_url":"/users/:id","http_method":"PATCH","short_description":null,"deprecated":null},{"api_url":"/users/:id","http_method":"PUT","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/users/destroy","name":"destroy","apis":[{"api_url":"/users/:id","http_method":"DELETE","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/users/create_unnested","name":"create_unnested","apis":[{"api_url":"/users/create_unnested","http_method":"POST","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"name","full_name":"name","description":"","required":true,"allow_nil":false,"validator":"Must be String","expected_type":"string","metadata":null,"show":true}],"examples":[],"metadata":null,"see":[]}]},"comments":{"doc_url":"./apipie/1.0/comments","api_url":"/","name":"Comments","short_description":null,"full_description":null,"version":"1.0","formats":null,"metadata":null,"methods":[{"doc_url":"./apipie/1.0/comments/index","name":"index","apis":[{"api_url":"/users/:user_id/posts/:post_id/comments","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/comments/show","name":"show","apis":[{"api_url":"/users/:user_id/posts/:post_id/comments/:id","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/comments/create","name":"create","apis":[{"api_url":"/users/:user_id/posts/:post_id/comments","http_method":"POST","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/comments/update","name":"update","apis":[{"api_url":"/users/:user_id/posts/:post_id/comments/:id","http_method":"PATCH","short_description":null,"deprecated":null},{"api_url":"/users/:user_id/posts/:post_id/comments/:id","http_method":"PUT","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/comments/destroy","name":"destroy","apis":[{"api_url":"/users/:user_id/posts/:post_id/comments/:id","http_method":"DELETE","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]}]},"posts":{"doc_url":"./apipie/1.0/posts","api_url":"/","name":"Posts","short_description":null,"full_description":null,"version":"1.0","formats":null,"metadata":null,"methods":[{"doc_url":"./apipie/1.0/posts/index","name":"index","apis":[{"api_url":"/users/:user_id/posts","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/posts/show","name":"show","apis":[{"api_url":"/users/:user_id/posts/:id","http_method":"GET","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/posts/create","name":"create","apis":[{"api_url":"/users/:user_id/posts","http_method":"POST","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/posts/update","name":"update","apis":[{"api_url":"/users/:user_id/posts/:id","http_method":"PATCH","short_description":null,"deprecated":null},{"api_url":"/users/:user_id/posts/:id","http_method":"PUT","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]},{"doc_url":"./apipie/1.0/posts/destroy","name":"destroy","apis":[{"api_url":"/users/:user_id/posts/:id","http_method":"DELETE","short_description":null,"deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[],"examples":[],"metadata":null,"see":[]}]}},"link_extension":".html"}}
|
data/test/unit/resource_test.rb
CHANGED
@@ -3,10 +3,10 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
3
3
|
describe ApipieBindings::Resource do
|
4
4
|
|
5
5
|
let(:resource) { ApipieBindings::API.new({:apidoc_cache_dir => 'test/unit/data',
|
6
|
-
:apidoc_cache_name => '
|
6
|
+
:apidoc_cache_name => 'dummy'}).resource(:users) }
|
7
7
|
|
8
8
|
it "should list actions" do
|
9
|
-
resource.actions.map(&:name).must_equal [:index, :show, :create, :create_unnested]
|
9
|
+
resource.actions.map(&:name).must_equal [:index, :show, :create, :update, :destroy, :create_unnested]
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should test action existence" do
|
@@ -20,30 +20,30 @@ describe ApipieBindings::Resource do
|
|
20
20
|
it "should allow user to call the action" do
|
21
21
|
params = { :a => 1 }
|
22
22
|
headers = { :content_type => 'application/json' }
|
23
|
-
ApipieBindings::API.any_instance.expects(:call).with(:
|
23
|
+
ApipieBindings::API.any_instance.expects(:call).with(:users, :index, params, headers, {})
|
24
24
|
resource.call(:index, params, headers)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should allow user to call the action with minimal params" do
|
28
|
-
ApipieBindings::API.any_instance.expects(:call).with(:
|
28
|
+
ApipieBindings::API.any_instance.expects(:call).with(:users, :index, {}, {}, {})
|
29
29
|
resource.call(:index)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should print name in singular on demand" do
|
33
|
-
resource.singular_name.must_equal '
|
33
|
+
resource.singular_name.must_equal 'user'
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should have name visible in puts" do
|
37
37
|
out, err = capture_io { puts resource }
|
38
|
-
out.must_equal "<Resource :
|
38
|
+
out.must_equal "<Resource :users>\n"
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should have name visible in inspect" do
|
42
|
-
resource.inspect.must_equal "<Resource :
|
42
|
+
resource.inspect.must_equal "<Resource :users>"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should rise error when the resource does no exist" do
|
46
46
|
assert_raises( NameError ){ ApipieBindings::API.new({:apidoc_cache_dir => 'test/unit/data',
|
47
|
-
:apidoc_cache_name => '
|
47
|
+
:apidoc_cache_name => 'dummy'}).resource(:none) }
|
48
48
|
end
|
49
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-bindings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Bačovský
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 1.6.5
|
34
34
|
- - <
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '3.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.6.5
|
44
44
|
- - <
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '3.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: oauth
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +72,6 @@ dependencies:
|
|
72
72
|
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: mime-types
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ~>
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.0'
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ~>
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: rake
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,9 +203,36 @@ files:
|
|
217
203
|
- lib/apipie_bindings/route.rb
|
218
204
|
- lib/apipie_bindings/utilities.rb
|
219
205
|
- lib/apipie_bindings/version.rb
|
206
|
+
- test/dummy/.gitignore
|
207
|
+
- test/dummy/Gemfile
|
208
|
+
- test/dummy/README.md
|
209
|
+
- test/dummy/Rakefile
|
210
|
+
- test/dummy/app/controllers/application_controller.rb
|
211
|
+
- test/dummy/app/controllers/comments_controller.rb
|
212
|
+
- test/dummy/app/controllers/concerns/dummy_concern.rb
|
213
|
+
- test/dummy/app/controllers/posts_controller.rb
|
214
|
+
- test/dummy/app/controllers/users_controller.rb
|
215
|
+
- test/dummy/app/lib/dummy/store.rb
|
216
|
+
- test/dummy/bin/bundle
|
217
|
+
- test/dummy/bin/rails
|
218
|
+
- test/dummy/bin/rake
|
219
|
+
- test/dummy/config.ru
|
220
|
+
- test/dummy/config/application.rb
|
221
|
+
- test/dummy/config/boot.rb
|
222
|
+
- test/dummy/config/environment.rb
|
223
|
+
- test/dummy/config/environments/development.rb
|
224
|
+
- test/dummy/config/environments/production.rb
|
225
|
+
- test/dummy/config/environments/test.rb
|
226
|
+
- test/dummy/config/initializers/apipie.rb
|
227
|
+
- test/dummy/config/initializers/session_store.rb
|
228
|
+
- test/dummy/config/routes.rb
|
229
|
+
- test/dummy/data/example/users/1/posts/1/comments/1/show.json
|
230
|
+
- test/dummy/data/example/users/1/posts/1/show.json
|
231
|
+
- test/dummy/data/example/users/1/show.json
|
232
|
+
- test/dummy/public/index.html
|
220
233
|
- test/unit/action_test.rb
|
221
234
|
- test/unit/api_test.rb
|
222
|
-
- test/unit/data/
|
235
|
+
- test/unit/data/dummy.json
|
223
236
|
- test/unit/example_test.rb
|
224
237
|
- test/unit/indifferent_hash_test.rb
|
225
238
|
- test/unit/inflector_test.rb
|
@@ -240,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
253
|
requirements:
|
241
254
|
- - '>='
|
242
255
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
256
|
+
version: 1.8.7
|
244
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
258
|
requirements:
|
246
259
|
- - '>='
|
@@ -248,14 +261,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
261
|
version: '0'
|
249
262
|
requirements: []
|
250
263
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.
|
264
|
+
rubygems_version: 2.4.4
|
252
265
|
signing_key:
|
253
266
|
specification_version: 4
|
254
267
|
summary: The Ruby bindings for Apipie documented APIs
|
255
268
|
test_files:
|
269
|
+
- test/dummy/.gitignore
|
270
|
+
- test/dummy/Gemfile
|
271
|
+
- test/dummy/README.md
|
272
|
+
- test/dummy/Rakefile
|
273
|
+
- test/dummy/app/controllers/application_controller.rb
|
274
|
+
- test/dummy/app/controllers/comments_controller.rb
|
275
|
+
- test/dummy/app/controllers/concerns/dummy_concern.rb
|
276
|
+
- test/dummy/app/controllers/posts_controller.rb
|
277
|
+
- test/dummy/app/controllers/users_controller.rb
|
278
|
+
- test/dummy/app/lib/dummy/store.rb
|
279
|
+
- test/dummy/bin/bundle
|
280
|
+
- test/dummy/bin/rails
|
281
|
+
- test/dummy/bin/rake
|
282
|
+
- test/dummy/config.ru
|
283
|
+
- test/dummy/config/application.rb
|
284
|
+
- test/dummy/config/boot.rb
|
285
|
+
- test/dummy/config/environment.rb
|
286
|
+
- test/dummy/config/environments/development.rb
|
287
|
+
- test/dummy/config/environments/production.rb
|
288
|
+
- test/dummy/config/environments/test.rb
|
289
|
+
- test/dummy/config/initializers/apipie.rb
|
290
|
+
- test/dummy/config/initializers/session_store.rb
|
291
|
+
- test/dummy/config/routes.rb
|
292
|
+
- test/dummy/data/example/users/1/posts/1/comments/1/show.json
|
293
|
+
- test/dummy/data/example/users/1/posts/1/show.json
|
294
|
+
- test/dummy/data/example/users/1/show.json
|
295
|
+
- test/dummy/public/index.html
|
256
296
|
- test/unit/action_test.rb
|
257
297
|
- test/unit/api_test.rb
|
258
|
-
- test/unit/data/
|
298
|
+
- test/unit/data/dummy.json
|
259
299
|
- test/unit/example_test.rb
|
260
300
|
- test/unit/indifferent_hash_test.rb
|
261
301
|
- test/unit/inflector_test.rb
|
@@ -1,191 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"docs": {
|
3
|
-
"api_url": "/api",
|
4
|
-
"copyright": "",
|
5
|
-
"doc_url": "/apidoc/v2",
|
6
|
-
"info": "Another API description",
|
7
|
-
"name": "Foreman",
|
8
|
-
"resources": {
|
9
|
-
"architectures": {
|
10
|
-
"api_url": "/api",
|
11
|
-
"doc_url": "/apidoc/v2/architectures",
|
12
|
-
"formats": null,
|
13
|
-
"full_description": null,
|
14
|
-
"methods": [
|
15
|
-
{
|
16
|
-
"apis": [
|
17
|
-
{
|
18
|
-
"api_url": "/api/architectures",
|
19
|
-
"http_method": "GET",
|
20
|
-
"short_description": "List all architectures."
|
21
|
-
}
|
22
|
-
],
|
23
|
-
"doc_url": "/apidoc/v2/architectures/index",
|
24
|
-
"errors": [],
|
25
|
-
"examples": [
|
26
|
-
"GET /api/architectures\n200\n[\n {\n \"architecture\": {\n \"name\": \"s390\",\n \"id\": 381564594,\n \"updated_at\": \"2012-12-18T15:24:42Z\",\n \"operatingsystem_ids\": [],\n \"created_at\": \"2012-12-18T15:24:42Z\"\n }\n },\n {\n \"architecture\": {\n \"name\": \"sparc\",\n \"id\": 331892513,\n \"updated_at\": \"2012-12-18T15:24:42Z\",\n \"operatingsystem_ids\": [\n 442321401\n ],\n \"created_at\": \"2012-12-18T15:24:42Z\"\n }\n },\n {\n \"architecture\": {\n \"name\": \"x86_64\",\n \"id\": 501905019,\n \"updated_at\": \"2012-12-18T15:24:42Z\",\n \"operatingsystem_ids\": [\n 331303656,\n 309172073,\n 1073012828\n ],\n \"created_at\": \"2012-12-18T15:24:42Z\"\n }\n }\n]"
|
27
|
-
],
|
28
|
-
"formats": null,
|
29
|
-
"full_description": "",
|
30
|
-
"name": "index",
|
31
|
-
"params": [
|
32
|
-
{
|
33
|
-
"allow_nil": false,
|
34
|
-
"description": "\n<p>filter results</p>\n",
|
35
|
-
"expected_type": "string",
|
36
|
-
"full_name": "search",
|
37
|
-
"name": "search",
|
38
|
-
"required": false,
|
39
|
-
"validator": "Must be String"
|
40
|
-
},
|
41
|
-
{
|
42
|
-
"allow_nil": false,
|
43
|
-
"description": "\n<p>sort results</p>\n",
|
44
|
-
"expected_type": "string",
|
45
|
-
"full_name": "order",
|
46
|
-
"name": "order",
|
47
|
-
"required": false,
|
48
|
-
"validator": "Must be String"
|
49
|
-
},
|
50
|
-
{
|
51
|
-
"allow_nil": false,
|
52
|
-
"description": "\n<p>paginate results</p>\n",
|
53
|
-
"expected_type": "string",
|
54
|
-
"full_name": "page",
|
55
|
-
"name": "page",
|
56
|
-
"required": false,
|
57
|
-
"validator": "Must be String"
|
58
|
-
},
|
59
|
-
{
|
60
|
-
"allow_nil": false,
|
61
|
-
"description": "\n<p>number of entries per request</p>\n",
|
62
|
-
"expected_type": "string",
|
63
|
-
"full_name": "per_page",
|
64
|
-
"name": "per_page",
|
65
|
-
"required": false,
|
66
|
-
"validator": "Must be String"
|
67
|
-
}
|
68
|
-
],
|
69
|
-
"see": []
|
70
|
-
},
|
71
|
-
{
|
72
|
-
"apis": [
|
73
|
-
{
|
74
|
-
"api_url": "/api/architectures/:id",
|
75
|
-
"http_method": "GET",
|
76
|
-
"short_description": "Show an architecture."
|
77
|
-
}
|
78
|
-
],
|
79
|
-
"doc_url": "/apidoc/v2/architectures/show",
|
80
|
-
"errors": [],
|
81
|
-
"examples": [
|
82
|
-
"GET /api/architectures/x86_64\n200\n{\n \"architecture\": {\n \"name\": \"x86_64\",\n \"id\": 501905019,\n \"updated_at\": \"2012-12-18T15:24:42Z\",\n \"operatingsystem_ids\": [\n 309172073,\n 1073012828,\n 331303656\n ],\n \"created_at\": \"2012-12-18T15:24:42Z\"\n }\n}"
|
83
|
-
],
|
84
|
-
"formats": null,
|
85
|
-
"full_description": "",
|
86
|
-
"name": "show",
|
87
|
-
"params": [
|
88
|
-
{
|
89
|
-
"allow_nil": false,
|
90
|
-
"description": "",
|
91
|
-
"expected_type": "string",
|
92
|
-
"full_name": "id",
|
93
|
-
"name": "id",
|
94
|
-
"required": true,
|
95
|
-
"validator": "Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space."
|
96
|
-
}
|
97
|
-
],
|
98
|
-
"see": []
|
99
|
-
},
|
100
|
-
{
|
101
|
-
"apis": [
|
102
|
-
{
|
103
|
-
"api_url": "/api/architectures",
|
104
|
-
"http_method": "POST",
|
105
|
-
"short_description": "Create an architecture."
|
106
|
-
}
|
107
|
-
],
|
108
|
-
"doc_url": "/apidoc/v2/architectures/create",
|
109
|
-
"errors": [],
|
110
|
-
"examples": [
|
111
|
-
"POST /api/architectures\n{\n \"architecture\": {\n \"name\": \"i386\"\n }\n}\n200\n{\n \"architecture\": {\n \"name\": \"i386\",\n \"id\": 501905020,\n \"updated_at\": \"2012-12-18T15:24:43Z\",\n \"operatingsystem_ids\": [],\n \"created_at\": \"2012-12-18T15:24:43Z\"\n }\n}"
|
112
|
-
],
|
113
|
-
"formats": null,
|
114
|
-
"full_description": "",
|
115
|
-
"name": "create",
|
116
|
-
"params": [
|
117
|
-
{
|
118
|
-
"allow_nil": false,
|
119
|
-
"description": "",
|
120
|
-
"expected_type": "hash",
|
121
|
-
"full_name": "architecture",
|
122
|
-
"name": "architecture",
|
123
|
-
"params": [
|
124
|
-
{
|
125
|
-
"allow_nil": false,
|
126
|
-
"description": "",
|
127
|
-
"expected_type": "string",
|
128
|
-
"full_name": "architecture[name]",
|
129
|
-
"name": "name",
|
130
|
-
"required": true,
|
131
|
-
"validator": "Must be String"
|
132
|
-
},
|
133
|
-
{
|
134
|
-
"allow_nil": false,
|
135
|
-
"description": "\n<p>Operatingsystem ID\u2019s</p>\n",
|
136
|
-
"expected_type": "array",
|
137
|
-
"full_name": "architecture[operatingsystem_ids]",
|
138
|
-
"name": "operatingsystem_ids",
|
139
|
-
"required": false,
|
140
|
-
"validator": "Must be Array"
|
141
|
-
}
|
142
|
-
],
|
143
|
-
"required": true,
|
144
|
-
"validator": "Must be a Hash"
|
145
|
-
}
|
146
|
-
],
|
147
|
-
"see": []
|
148
|
-
},
|
149
|
-
{
|
150
|
-
"apis": [
|
151
|
-
{
|
152
|
-
"api_url": "/api/architectures",
|
153
|
-
"http_method": "POST",
|
154
|
-
"short_description": "create an architecture."
|
155
|
-
}
|
156
|
-
],
|
157
|
-
"doc_url": "/apidoc/v2/architectures/create",
|
158
|
-
"errors": [],
|
159
|
-
"examples" : [
|
160
|
-
"same as nested create"
|
161
|
-
],
|
162
|
-
"formats": null,
|
163
|
-
"full_description": "",
|
164
|
-
"name": "create_unnested",
|
165
|
-
"params":[
|
166
|
-
{
|
167
|
-
"allow_nil": false,
|
168
|
-
"description": "",
|
169
|
-
"expected_type": "string",
|
170
|
-
"full_name": "architecture[name]",
|
171
|
-
"name": "name",
|
172
|
-
"required": true,
|
173
|
-
"validator": "Must be String"
|
174
|
-
},
|
175
|
-
{
|
176
|
-
"allow_nil": false,
|
177
|
-
"description": "\n<p>Operatingsystem ID\u2019s</p>\n",
|
178
|
-
"expected_type": "array",
|
179
|
-
"full_name": "architecture[operatingsystem_ids]",
|
180
|
-
"name": "operatingsystem_ids",
|
181
|
-
"required": false,
|
182
|
-
"validator": "Must be Array"
|
183
|
-
}
|
184
|
-
],
|
185
|
-
"see": []
|
186
|
-
}
|
187
|
-
]
|
188
|
-
}
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|