apipie-rails 0.5.16 → 0.5.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile.rails41 +1 -0
- data/Gemfile.rails42 +2 -0
- data/Gemfile.rails50 +1 -0
- data/Gemfile.rails51 +2 -0
- data/Gemfile.rails60 +2 -0
- data/lib/apipie-rails.rb +2 -0
- data/lib/apipie/application.rb +7 -4
- data/lib/apipie/core_ext/route.rb +9 -0
- data/lib/apipie/dsl_definition.rb +22 -8
- data/lib/apipie/method_description.rb +2 -1
- data/lib/apipie/routes_formatter.rb +1 -1
- data/lib/apipie/swagger_generator.rb +3 -2
- data/lib/apipie/validator.rb +2 -0
- data/lib/apipie/version.rb +1 -1
- data/spec/controllers/extended_controller_spec.rb +4 -1
- data/spec/controllers/memes_controller_spec.rb +10 -0
- data/spec/controllers/users_controller_spec.rb +12 -0
- data/spec/dummy/app/controllers/concerns/extending_concern.rb +1 -0
- data/spec/dummy/app/controllers/users_controller.rb +1 -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 +1 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855ada05457368ea7521d46865242c73a15c33a33546d7b0dac1d2b90d779c70
|
4
|
+
data.tar.gz: 0cc30d4f4a38a476cab6ed92b6a4a00c45bd2036c8b35fb8373fbb215fb2ea80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0ba79aee65ed21249fa35336166783697719fabc74831816513ea1d0b91162bde342b51fad08121ea38c27f5015bbf196ac524049dcbbc8635dd0a57f13cff
|
7
|
+
data.tar.gz: 0f9f593ee579dba0baf16175e8c9d916dd370eba6a5c37cee4df2a92dea1efe0ea936b2444597274dd327244063000bb3a9cff454413956cd98bd27c5652afc6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Changelog
|
2
2
|
===========
|
3
3
|
|
4
|
+
[v0.5.17](https://github.com/Apipie/apipie-rails/tree/v0.5.17) (2020-01-20)
|
5
|
+
--------
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.16...v0.5.17)
|
8
|
+
|
9
|
+
- Allows update metadata for methods [\#667](https://github.com/Apipie/apipie-rails/pull/667) ([speckins](https://github.com/speckins))
|
10
|
+
|
4
11
|
[v0.5.16](https://github.com/Apipie/apipie-rails/tree/v0.5.16) (2019-05-22)
|
5
12
|
--------
|
6
13
|
|
@@ -208,7 +215,7 @@ v0.3.2
|
|
208
215
|
v0.3.1
|
209
216
|
------
|
210
217
|
|
211
|
-
* Support for ``api!`` keyword in concerns
|
218
|
+
* Support for ``api!`` keyword in concerns
|
212
219
|
[#322](https://github.com/Apipie/apipie-rails/pull/322) [@iNecas][]
|
213
220
|
* More explicit ordering of the static dispatcher middleware
|
214
221
|
[#315](https://github.com/Apipie/apipie-rails/pull/315) [@iNecas][]
|
data/Gemfile.rails41
CHANGED
data/Gemfile.rails42
CHANGED
data/Gemfile.rails50
CHANGED
data/Gemfile.rails51
CHANGED
data/Gemfile.rails60
CHANGED
@@ -10,3 +10,5 @@ gem 'rspec-core', git: 'https://github.com/rspec/rspec-core'
|
|
10
10
|
gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks'
|
11
11
|
gem 'rspec-support', git: 'https://github.com/rspec/rspec-support'
|
12
12
|
gem 'rspec-expectations', git: 'https://github.com/rspec/rspec-expectations'
|
13
|
+
|
14
|
+
gem 'test_engine', path: 'spec/dummy/components/test_engine', group: :test
|
data/lib/apipie-rails.rb
CHANGED
data/lib/apipie/application.rb
CHANGED
@@ -29,7 +29,7 @@ module Apipie
|
|
29
29
|
@controller_to_resource_id[controller] = resource_id
|
30
30
|
end
|
31
31
|
|
32
|
-
def rails_routes(route_set = nil)
|
32
|
+
def rails_routes(route_set = nil, base_url = "")
|
33
33
|
if route_set.nil? && @rails_routes
|
34
34
|
return @rails_routes
|
35
35
|
end
|
@@ -40,10 +40,13 @@ module Apipie
|
|
40
40
|
flatten_routes = []
|
41
41
|
|
42
42
|
route_set.routes.each do |route|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
# This is a hack to workaround a bug in apipie with Rails 4.2.5.1 or newer. See https://github.com/Apipie/apipie-rails/issues/415
|
44
|
+
route_app = Rails::VERSION::STRING.to_f >= 4.2 ? route.app.app : route.app
|
45
|
+
if route_app.respond_to?(:routes) && route_app.routes.is_a?(ActionDispatch::Routing::RouteSet)
|
46
|
+
# recursively go though the mounted engines
|
47
|
+
flatten_routes.concat(rails_routes(route_app.routes, File.join(base_url, route.path.spec.to_s)))
|
46
48
|
else
|
49
|
+
route.base_url = base_url
|
47
50
|
flatten_routes << route
|
48
51
|
end
|
49
52
|
end
|
@@ -488,19 +488,33 @@ module Apipie
|
|
488
488
|
# param_names.each { |p| param p, String }
|
489
489
|
# end
|
490
490
|
# end
|
491
|
-
def
|
491
|
+
def _apipie_update_params(method_desc, dsl_data)
|
492
|
+
params_ordered = dsl_data[:params].map do |args|
|
493
|
+
Apipie::ParamDescription.from_dsl_data(method_desc, args)
|
494
|
+
end
|
495
|
+
ParamDescription.merge(method_desc.params_ordered_self, params_ordered)
|
496
|
+
end
|
497
|
+
|
498
|
+
def _apipie_update_meta(method_desc, dsl_data)
|
499
|
+
return unless dsl_data[:meta] && dsl_data[:meta].is_a?(Hash)
|
500
|
+
|
501
|
+
method_desc.metadata ||= {}
|
502
|
+
method_desc.metadata.merge!(dsl_data[:meta])
|
503
|
+
end
|
504
|
+
|
505
|
+
def apipie_update_methods(methods, *args, &block)
|
492
506
|
methods.each do |method|
|
493
|
-
|
494
|
-
unless
|
507
|
+
method_desc = Apipie.get_method_description(self, method)
|
508
|
+
unless method_desc
|
495
509
|
raise "Could not find method description for #{self}##{method}. Was the method defined?"
|
496
510
|
end
|
497
511
|
dsl_data = _apipie_eval_dsl(*args, &block)
|
498
|
-
|
499
|
-
|
500
|
-
end
|
501
|
-
ParamDescription.merge(method_description.params_ordered_self, params_ordered)
|
512
|
+
_apipie_update_params(method_desc, dsl_data)
|
513
|
+
_apipie_update_meta(method_desc, dsl_data)
|
502
514
|
end
|
503
515
|
end
|
516
|
+
# backwards compatibility
|
517
|
+
alias_method :apipie_update_params, :apipie_update_methods
|
504
518
|
|
505
519
|
def _apipie_concern_subst
|
506
520
|
@_apipie_concern_subst ||= {:controller_path => self.controller_path,
|
@@ -550,7 +564,7 @@ module Apipie
|
|
550
564
|
controller._apipie_define_validators(description)
|
551
565
|
end
|
552
566
|
_apipie_concern_update_api_blocks.each do |(methods, block)|
|
553
|
-
controller.
|
567
|
+
controller.apipie_update_methods(methods, &block)
|
554
568
|
end
|
555
569
|
end
|
556
570
|
|
@@ -17,7 +17,8 @@ module Apipie
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :
|
20
|
+
attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :headers, :show
|
21
|
+
attr_accessor :metadata
|
21
22
|
|
22
23
|
def initialize(method, resource, dsl_data)
|
23
24
|
@method = method.to_s
|
@@ -651,14 +651,15 @@ module Apipie
|
|
651
651
|
|
652
652
|
def add_headers_from_hash(swagger_params_array, headers)
|
653
653
|
swagger_headers = headers.map do |header|
|
654
|
-
{
|
654
|
+
header_hash = {
|
655
655
|
name: header[:name],
|
656
656
|
in: 'header',
|
657
657
|
required: header[:options][:required],
|
658
658
|
description: header[:description],
|
659
659
|
type: header[:options][:type] || 'string'
|
660
660
|
}
|
661
|
-
|
661
|
+
header_hash[:default] = header[:options][:default] if header[:options][:default]
|
662
|
+
header_hash
|
662
663
|
end
|
663
664
|
swagger_params_array.push(*swagger_headers)
|
664
665
|
end
|
data/lib/apipie/validator.rb
CHANGED
data/lib/apipie/version.rb
CHANGED
@@ -7,5 +7,8 @@ describe ExtendedController do
|
|
7
7
|
user_param = Apipie["extended#create"].params[:user]
|
8
8
|
expect(user_param.validator.params_ordered.map(&:name)).to eq [:name, :password, :from_concern]
|
9
9
|
end
|
10
|
-
end
|
11
10
|
|
11
|
+
it 'should include updated metadata' do
|
12
|
+
expect(Apipie['extended#create'].metadata).to eq metadata: 'data'
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TestEngine::MemesController do
|
4
|
+
|
5
|
+
describe "#index" do
|
6
|
+
it "should have the full mounted path of engine" do
|
7
|
+
Apipie.routes_for_action(TestEngine::MemesController, :index, {}).first[:path].should eq("/test/memes")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -488,12 +488,24 @@ describe UsersController do
|
|
488
488
|
}
|
489
489
|
end
|
490
490
|
|
491
|
+
let(:expected_header_with_default) do
|
492
|
+
{
|
493
|
+
name: :HeaderNameWithDefaultValue,
|
494
|
+
description: 'Header with default value',
|
495
|
+
options: {
|
496
|
+
required: true,
|
497
|
+
default: 'default value'
|
498
|
+
}
|
499
|
+
}
|
500
|
+
end
|
501
|
+
|
491
502
|
it 'contains all headers description in method doc' do
|
492
503
|
headers = Apipie.get_method_description(UsersController, :action_with_headers).headers
|
493
504
|
expect(headers).to be_an(Array)
|
494
505
|
|
495
506
|
compare_hashes headers[0], expected_required_header
|
496
507
|
compare_hashes headers[1], expected_optional_header
|
508
|
+
compare_hashes headers[2], expected_header_with_default
|
497
509
|
end
|
498
510
|
end
|
499
511
|
|
@@ -292,6 +292,7 @@ class UsersController < ApplicationController
|
|
292
292
|
api :GET, '/users/action_with_headers'
|
293
293
|
header :RequredHeaderName, 'Required header description', required: true
|
294
294
|
header :OptionalHeaderName, 'Optional header description', required: false, type: 'string'
|
295
|
+
header :HeaderNameWithDefaultValue, 'Header with default value', required: true, default: 'default value'
|
295
296
|
def action_with_headers
|
296
297
|
end
|
297
298
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module TestEngine
|
2
|
+
class MemesController < TestEngine::ApplicationController
|
3
|
+
api! 'Returns a list of all good memes on Twitter'
|
4
|
+
param :api_token, String, required: true, desc: 'Your Twitter API token'
|
5
|
+
def index
|
6
|
+
render json: []
|
7
|
+
end
|
8
|
+
|
9
|
+
api! 'Shows info about a particular meme on Twitter'
|
10
|
+
param :id, :number, required: true, desc: 'ID of the meme'
|
11
|
+
def show
|
12
|
+
render json: {id: params[:id]}
|
13
|
+
end
|
14
|
+
|
15
|
+
api! 'Create a new meme on Twitter'
|
16
|
+
param :api_token, String, required: true, desc: 'Your Twitter API token'
|
17
|
+
param :name, String, required: true, desc: 'Name of your meme'
|
18
|
+
param :src_url, String, required: true, desc: 'URL for your meme'
|
19
|
+
def create
|
20
|
+
render json: {name: params[:name], src_url: params[:src_url]}, status: :created
|
21
|
+
end
|
22
|
+
|
23
|
+
api! 'Update a meme on Twitter'
|
24
|
+
param :api_token, String, required: true, desc: 'Your Twitter API token'
|
25
|
+
param :name, String, required: false, desc: 'Name of your meme'
|
26
|
+
param :src_url, String, required: false, desc: 'URL for your meme'
|
27
|
+
def update
|
28
|
+
render json: {name: params[:name], src_url: params[:src_url]}
|
29
|
+
end
|
30
|
+
|
31
|
+
api! 'Delete a meme on Twitter'
|
32
|
+
param :id, :number, required: true, desc: 'ID of the meme'
|
33
|
+
def destroy
|
34
|
+
head :ok
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
# Describe your gem and declare its dependencies:
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'test_engine'
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.summary = 'Test Engine'
|
8
|
+
s.authors = 'Test Author'
|
9
|
+
|
10
|
+
s.files = Dir['{app,config,db,lib}/**/*']
|
11
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pokorny
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/apipie/apipie_module.rb
|
209
209
|
- lib/apipie/application.rb
|
210
210
|
- lib/apipie/configuration.rb
|
211
|
+
- lib/apipie/core_ext/route.rb
|
211
212
|
- lib/apipie/dsl_definition.rb
|
212
213
|
- lib/apipie/error_description.rb
|
213
214
|
- lib/apipie/errors.rb
|
@@ -247,6 +248,7 @@ files:
|
|
247
248
|
- spec/controllers/apipies_controller_spec.rb
|
248
249
|
- spec/controllers/concerns_controller_spec.rb
|
249
250
|
- spec/controllers/extended_controller_spec.rb
|
251
|
+
- spec/controllers/memes_controller_spec.rb
|
250
252
|
- spec/controllers/users_controller_spec.rb
|
251
253
|
- spec/dummy/Rakefile
|
252
254
|
- spec/dummy/app/controllers/api/base_controller.rb
|
@@ -271,6 +273,13 @@ files:
|
|
271
273
|
- spec/dummy/app/controllers/twitter_example_controller.rb
|
272
274
|
- spec/dummy/app/controllers/users_controller.rb
|
273
275
|
- spec/dummy/app/views/layouts/application.html.erb
|
276
|
+
- spec/dummy/components/test_engine/Gemfile
|
277
|
+
- spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb
|
278
|
+
- spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb
|
279
|
+
- spec/dummy/components/test_engine/config/routes.rb
|
280
|
+
- spec/dummy/components/test_engine/db/.gitkeep
|
281
|
+
- spec/dummy/components/test_engine/lib/test_engine.rb
|
282
|
+
- spec/dummy/components/test_engine/test_engine.gemspec
|
274
283
|
- spec/dummy/config.ru
|
275
284
|
- spec/dummy/config/application.rb
|
276
285
|
- spec/dummy/config/boot.rb
|
@@ -333,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
333
342
|
version: '0'
|
334
343
|
requirements: []
|
335
344
|
rubyforge_project:
|
336
|
-
rubygems_version: 2.7.
|
345
|
+
rubygems_version: 2.7.10
|
337
346
|
signing_key:
|
338
347
|
specification_version: 4
|
339
348
|
summary: Rails REST API documentation tool
|
@@ -344,6 +353,7 @@ test_files:
|
|
344
353
|
- spec/controllers/apipies_controller_spec.rb
|
345
354
|
- spec/controllers/concerns_controller_spec.rb
|
346
355
|
- spec/controllers/extended_controller_spec.rb
|
356
|
+
- spec/controllers/memes_controller_spec.rb
|
347
357
|
- spec/controllers/users_controller_spec.rb
|
348
358
|
- spec/dummy/Rakefile
|
349
359
|
- spec/dummy/app/controllers/api/base_controller.rb
|
@@ -368,6 +378,13 @@ test_files:
|
|
368
378
|
- spec/dummy/app/controllers/twitter_example_controller.rb
|
369
379
|
- spec/dummy/app/controllers/users_controller.rb
|
370
380
|
- spec/dummy/app/views/layouts/application.html.erb
|
381
|
+
- spec/dummy/components/test_engine/Gemfile
|
382
|
+
- spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb
|
383
|
+
- spec/dummy/components/test_engine/app/controllers/test_engine/memes_controller.rb
|
384
|
+
- spec/dummy/components/test_engine/config/routes.rb
|
385
|
+
- spec/dummy/components/test_engine/db/.gitkeep
|
386
|
+
- spec/dummy/components/test_engine/lib/test_engine.rb
|
387
|
+
- spec/dummy/components/test_engine/test_engine.gemspec
|
371
388
|
- spec/dummy/config.ru
|
372
389
|
- spec/dummy/config/application.rb
|
373
390
|
- spec/dummy/config/boot.rb
|