api_canon 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@ module ApiCanon
84
84
  # @see ApiCanon::DocumentedAction#response_code
85
85
  def document_method(method_name, &block)
86
86
  document do |document|
87
- documented_action = ApiCanon::DocumentedAction.new method_name, controller_name
87
+ documented_action = ApiCanon::DocumentedAction.new method_name, controller_path, controller_name
88
88
  documented_action.instance_eval &block if block_given?
89
89
  document.add_action documented_action
90
90
  end
@@ -2,9 +2,10 @@ module ApiCanon
2
2
  class DocumentedAction
3
3
  include ActiveModel::Serialization
4
4
  attr_reader :params, :response_codes, :response_model_name, :description, :action_name,
5
- :controller_name, :http_method
6
- def initialize(action_name, controller_name)
5
+ :controller_name, :controller_path, :http_method
6
+ def initialize(action_name, controller_path, controller_name)
7
7
  @action_name = action_name
8
+ @controller_path = controller_path
8
9
  @controller_name = controller_name
9
10
  @params={}
10
11
  # TODO: This should check routes to see if params[:format] is expected
@@ -22,6 +22,9 @@ module ApiCanon
22
22
  def to_field(f, doco_prefix)
23
23
  # TODO: This doco_prefix thing sucks. Get rid of it.
24
24
  if type == :array
25
+ if form_values.nil?
26
+ raise ArgumentError.new(':values or :example_values must be supplied for :array type params')
27
+ end
25
28
  f.select name, form_values, {:selected => default, :include_blank => true}, {:multiple => multiple?, :class => 'input-block-level', :id => "#{doco_prefix}_#{name}"}
26
29
  elsif type == :boolean
27
30
  f.select name, [true,false], {:selected => default, :include_blank => true}, :class => 'input-block-level', :id => "#{doco_prefix}_#{name}"
@@ -11,7 +11,11 @@ module ApiCanon
11
11
  end
12
12
 
13
13
  # TODO: make :path => 'swagger-doc' customisable
14
- map.resources :path => 'swagger-doc', :controller => 'api_canon/swagger', :only => [:index, :show], :as => :api_canon_swagger_doc
14
+ map.resources :path => 'swagger-doc',
15
+ :controller => 'api_canon/swagger',
16
+ :only => [:index, :show],
17
+ :constraints => { :id => /.+/ },
18
+ :as => :api_canon_swagger_doc
15
19
  end
16
20
  end
17
- end
21
+ end
@@ -28,7 +28,7 @@ module ApiCanon
28
28
 
29
29
  def url_params
30
30
  url_params = {
31
- :controller => object.controller_name,
31
+ :controller => object.controller_path,
32
32
  :action => object.action_name,
33
33
  :only_path => true
34
34
  }
@@ -1,3 +1,3 @@
1
1
  module ApiCanon
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  describe ApiCanon::DocumentedAction do
3
3
 
4
- let(:document) {ApiCanon::DocumentedAction.new :index, 'controller_name'}
4
+ let(:document) {ApiCanon::DocumentedAction.new :index, 'controller_path', 'controller_name'}
5
5
  let(:description) {'ID is the unique identifier of the object'}
6
6
  subject { document }
7
7
  its(:action_name) { should == :index }
@@ -26,6 +26,12 @@ describe ApiCanon::DocumentedParam do
26
26
  fake_form.should_receive(:select).with :format, [:json, :xml], hash_including({:include_blank => true}), hash_including({:id => 'foo_format'})
27
27
  documented_param.to_field fake_form, doco_prefix
28
28
  end
29
+ context 'when form_values returns nil' do
30
+ it 'raises an ArgumentError' do
31
+ subject.stub(:form_values => nil)
32
+ expect { documented_param.to_field fake_form, doco_prefix }.to raise_exception(ArgumentError)
33
+ end
34
+ end
29
35
  end
30
36
  context "boolean-type params" do
31
37
  before(:each) {documented_param.type = :boolean}
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  describe ApiCanon::Swagger::ApiDeclaration do
3
3
 
4
4
  let(:documented_action) {
5
- documented_action = ApiCanon::DocumentedAction.new('action_name', 'controller_name')
5
+ documented_action = ApiCanon::DocumentedAction.new('action_name', 'controller_path', 'controller_name')
6
6
  documented_action.describe 'description'
7
7
  documented_action.response_class 'Thing'
8
8
  documented_action.response_code '404', 'reason'
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Cameron Walsh
@@ -10,39 +11,44 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-08-21 00:00:00.000000000 Z
14
+ date: 2013-09-11 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rails
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - '>='
21
+ - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
23
  version: 2.3.17
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
- - - '>='
29
+ - - ! '>='
27
30
  - !ruby/object:Gem::Version
28
31
  version: 2.3.17
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: active_model_serializers
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
- - - '>='
37
+ - - ! '>='
34
38
  - !ruby/object:Gem::Version
35
39
  version: '0'
36
40
  type: :runtime
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
- - - '>='
45
+ - - ! '>='
41
46
  - !ruby/object:Gem::Version
42
47
  version: '0'
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: rspec
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
53
  - - ~>
48
54
  - !ruby/object:Gem::Version
@@ -50,6 +56,7 @@ dependencies:
50
56
  type: :development
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
61
  - - ~>
55
62
  - !ruby/object:Gem::Version
@@ -57,173 +64,186 @@ dependencies:
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: rspec-rails
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
- - - '>='
69
+ - - ! '>='
62
70
  - !ruby/object:Gem::Version
63
71
  version: '0'
64
72
  type: :development
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
- - - '>='
77
+ - - ! '>='
69
78
  - !ruby/object:Gem::Version
70
79
  version: '0'
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: json_spec
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
- - - '>='
85
+ - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  type: :development
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
- - - '>='
93
+ - - ! '>='
83
94
  - !ruby/object:Gem::Version
84
95
  version: '0'
85
96
  - !ruby/object:Gem::Dependency
86
97
  name: rake
87
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
88
100
  requirements:
89
- - - '>='
101
+ - - ! '>='
90
102
  - !ruby/object:Gem::Version
91
103
  version: '0'
92
104
  type: :development
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
95
108
  requirements:
96
- - - '>='
109
+ - - ! '>='
97
110
  - !ruby/object:Gem::Version
98
111
  version: '0'
99
112
  - !ruby/object:Gem::Dependency
100
113
  name: yard
101
114
  requirement: !ruby/object:Gem::Requirement
115
+ none: false
102
116
  requirements:
103
- - - '>='
117
+ - - ! '>='
104
118
  - !ruby/object:Gem::Version
105
119
  version: '0'
106
120
  type: :development
107
121
  prerelease: false
108
122
  version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
109
124
  requirements:
110
- - - '>='
125
+ - - ! '>='
111
126
  - !ruby/object:Gem::Version
112
127
  version: '0'
113
128
  - !ruby/object:Gem::Dependency
114
129
  name: pry
115
130
  requirement: !ruby/object:Gem::Requirement
131
+ none: false
116
132
  requirements:
117
- - - '>='
133
+ - - ! '>='
118
134
  - !ruby/object:Gem::Version
119
135
  version: '0'
120
136
  type: :development
121
137
  prerelease: false
122
138
  version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
123
140
  requirements:
124
- - - '>='
141
+ - - ! '>='
125
142
  - !ruby/object:Gem::Version
126
143
  version: '0'
127
144
  - !ruby/object:Gem::Dependency
128
145
  name: combustion
129
146
  requirement: !ruby/object:Gem::Requirement
147
+ none: false
130
148
  requirements:
131
- - - '>='
149
+ - - ! '>='
132
150
  - !ruby/object:Gem::Version
133
151
  version: '0'
134
152
  type: :development
135
153
  prerelease: false
136
154
  version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
137
156
  requirements:
138
- - - '>='
157
+ - - ! '>='
139
158
  - !ruby/object:Gem::Version
140
159
  version: '0'
141
- description: |-
142
- api_canon is a declarative documentation generator
143
- for APIs. Declare the parameters and response codes,
144
- describe them, and give some example values. api_canon
145
- handles the rest for you.
160
+ description: ! "api_canon is a declarative documentation generator\n for
161
+ APIs. Declare the parameters and response codes,\n describe
162
+ them, and give some example values. api_canon\n handles the
163
+ rest for you."
146
164
  email:
147
165
  - cameron.walsh@gmail.com
148
166
  - leon@leondewey.com
149
167
  - ben.tillman@gmail.com
168
+ - doperations@au.westfield.com
150
169
  executables: []
151
170
  extensions: []
152
171
  extra_rdoc_files: []
153
172
  files:
154
- - app/views/api_canon/api_canon.html.erb
155
- - app/views/api_canon/_form.html.erb
173
+ - app/controllers/api_canon_controller.rb
174
+ - app/controllers/swagger_controller.rb
175
+ - app/helpers/api_canon/api_canon_view_helper.rb
156
176
  - app/views/api_canon/_api_canon.html.erb
177
+ - app/views/api_canon/_form.html.erb
157
178
  - app/views/api_canon/_rails_2_form.html.erb
179
+ - app/views/api_canon/api_canon.html.erb
158
180
  - app/views/application/index.html.erb
159
181
  - app/views/layouts/api_canon.html.erb
160
- - app/controllers/swagger_controller.rb
161
- - app/controllers/api_canon_controller.rb
162
- - app/helpers/api_canon/api_canon_view_helper.rb
163
- - lib/api_canon/documented_param.rb
164
- - lib/api_canon/documented_model.rb
165
- - lib/api_canon/version.rb
166
- - lib/api_canon/documented_action.rb
167
- - lib/api_canon/documentation_store.rb
168
182
  - lib/api_canon/app.rb
169
- - lib/api_canon/swagger/base.rb
170
- - lib/api_canon/swagger/api_declaration.rb
171
- - lib/api_canon/swagger/resource_listing.rb
172
183
  - lib/api_canon/document.rb
184
+ - lib/api_canon/documentation_store.rb
185
+ - lib/api_canon/documented_action.rb
186
+ - lib/api_canon/documented_model.rb
187
+ - lib/api_canon/documented_param.rb
173
188
  - lib/api_canon/routes.rb
174
- - lib/tasks/api_canon_tasks.rake
189
+ - lib/api_canon/swagger/api_declaration.rb
190
+ - lib/api_canon/swagger/base.rb
191
+ - lib/api_canon/swagger/resource_listing.rb
192
+ - lib/api_canon/version.rb
175
193
  - lib/api_canon.rb
194
+ - lib/tasks/api_canon_tasks.rake
176
195
  - MIT-LICENSE
177
196
  - Rakefile
178
197
  - README.md
179
- - spec/spec_helper.rb
180
- - spec/lib/api_canon/documented_param_spec.rb
198
+ - spec/internal/config/database.yml
199
+ - spec/internal/config/routes.rb
200
+ - spec/internal/db/schema.rb
201
+ - spec/internal/log/test.log
202
+ - spec/internal/public/favicon.ico
203
+ - spec/lib/api_canon/documented_action_spec.rb
181
204
  - spec/lib/api_canon/documented_model_spec.rb
205
+ - spec/lib/api_canon/documented_param_spec.rb
182
206
  - spec/lib/api_canon/swagger_spec/api_declaration_spec.rb
183
207
  - spec/lib/api_canon/swagger_spec/resource_listing_spec.rb
184
- - spec/lib/api_canon/documented_action_spec.rb
185
208
  - spec/lib/api_canon_spec.rb
186
- - spec/internal/public/favicon.ico
187
- - spec/internal/db/schema.rb
188
- - spec/internal/config/database.yml
189
- - spec/internal/config/routes.rb
190
- - spec/internal/log/test.log
209
+ - spec/spec_helper.rb
191
210
  homepage: http://github.com/westfield/api_canon
192
211
  licenses:
193
212
  - MIT
194
- metadata: {}
195
213
  post_install_message:
196
214
  rdoc_options: []
197
215
  require_paths:
198
216
  - app
199
217
  - lib
200
218
  required_ruby_version: !ruby/object:Gem::Requirement
219
+ none: false
201
220
  requirements:
202
- - - '>='
221
+ - - ! '>='
203
222
  - !ruby/object:Gem::Version
204
223
  version: '0'
205
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
+ none: false
206
226
  requirements:
207
- - - '>='
227
+ - - ! '>='
208
228
  - !ruby/object:Gem::Version
209
229
  version: '0'
210
230
  requirements: []
211
231
  rubyforge_project:
212
- rubygems_version: 2.0.3
232
+ rubygems_version: 1.8.25
213
233
  signing_key:
214
- specification_version: 4
234
+ specification_version: 3
215
235
  summary: Declarative documentation generator for APIs.
216
236
  test_files:
217
- - spec/spec_helper.rb
218
- - spec/lib/api_canon/documented_param_spec.rb
237
+ - spec/internal/config/database.yml
238
+ - spec/internal/config/routes.rb
239
+ - spec/internal/db/schema.rb
240
+ - spec/internal/log/test.log
241
+ - spec/internal/public/favicon.ico
242
+ - spec/lib/api_canon/documented_action_spec.rb
219
243
  - spec/lib/api_canon/documented_model_spec.rb
244
+ - spec/lib/api_canon/documented_param_spec.rb
220
245
  - spec/lib/api_canon/swagger_spec/api_declaration_spec.rb
221
246
  - spec/lib/api_canon/swagger_spec/resource_listing_spec.rb
222
- - spec/lib/api_canon/documented_action_spec.rb
223
247
  - spec/lib/api_canon_spec.rb
224
- - spec/internal/public/favicon.ico
225
- - spec/internal/db/schema.rb
226
- - spec/internal/config/database.yml
227
- - spec/internal/config/routes.rb
228
- - spec/internal/log/test.log
248
+ - spec/spec_helper.rb
229
249
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 47daa06eee0e9801cdd6d0476a52006585b96e87
4
- data.tar.gz: d424093588fe923332278cbd7d8f2515abdcf704
5
- SHA512:
6
- metadata.gz: 0826027c44ce02123906d4f9c42cf1fade9c6908043ae9fe428bd562eae832202b515932035882fe9017844721d9808bf07036cd03d1dc119d02952a31e64dfd
7
- data.tar.gz: 54c41a3748d0443521fea10d78c9b11545fcb9899510c0022b9df100f8062d37971a0f7de4f62a7222bcdfbe4a5ec463c0b646f6c0449c94055999b5f450ddda