rails_api_documentation 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +115 -109
- data/lib/rails_api_doc/config.rb +6 -1
- data/lib/rails_api_doc/controller/request/dsl.rb +30 -2
- data/lib/rails_api_doc/controller/strong_params/dsl.rb +0 -3
- data/lib/rails_api_doc/controller/strong_params/permitted_params.rb +25 -10
- data/lib/rails_api_doc/model/attribute_parser.rb +1 -1
- data/lib/rails_api_doc/params/dsl.rb +29 -0
- data/lib/rails_api_doc/params/finder.rb +34 -0
- data/lib/rails_api_doc/params/main.rb +9 -0
- data/lib/rails_api_doc/railtie.rb +5 -1
- data/lib/rails_api_doc/version.rb +1 -1
- data/lib/rails_api_doc.rb +14 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa57f61a95e060eff72a6089f4e5806d7246bfe9
|
4
|
+
data.tar.gz: 6cafddf29e9049a7a3e75b5817f4bdc95a600c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a340764a01562dc0417d0289b66c0cfa7cbaa6cae3ca057adbc1fdffb93c35fc35e44b2f785e5c7de4273b11846cd460c8b5251013603e007c278ddf468e0c70
|
7
|
+
data.tar.gz: 23fb0e13df0227c92ef22498055b03278e63e3903b849c6951a4204b6d17bd49835d031830c366982355f85b89c60e6dee48ca4b8d60a537676ae7991d1179f5
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# RailsApiDoc
|
1
|
+
# RailsApiDoc [![CircleCI](https://circleci.com/gh/vshaveyko/rails_api_doc/tree/master.svg?style=svg&circle-token=cc544085bb94b3f8613cfab79e9618bf20ce7138)](https://circleci.com/gh/vshaveyko/rails_api_doc/tree/master)
|
3
2
|
|
4
3
|
## Installation
|
5
4
|
|
@@ -19,159 +18,166 @@ Or install it yourself as:
|
|
19
18
|
|
20
19
|
## Features
|
21
20
|
|
22
|
-
+
|
21
|
+
+ Displaying application api if used in one of the correct ways.
|
23
22
|
![alt tag](https://raw.githubusercontent.com/vshaveyko/rails_api_doc/master/preview.png)
|
24
|
-
+ Integration with Rabl if it is bundled
|
25
|
-
+
|
23
|
+
+ Integration with Rabl if it is bundled.
|
24
|
+
+ `strong_params` method that will filter incoming params for you.
|
26
25
|
|
27
26
|
## Usage
|
28
27
|
|
29
28
|
To display api documentation on route '/api_doc' you need to:
|
30
29
|
|
31
|
-
|
30
|
+
1. config/application.rb ->
|
31
|
+
```ruby
|
32
|
+
require 'rails_api_doc'
|
33
|
+
```
|
34
|
+
|
35
|
+
2. config/routes.rb ->
|
32
36
|
```ruby
|
33
|
-
|
37
|
+
mount RailsApiDoc::Engine => '/api_doc'
|
34
38
|
```
|
35
|
-
1. config/routes.rb ->
|
36
|
-
```ruby
|
37
|
-
mount RailsApiDoc::Engine => '/api_doc'
|
38
|
-
```
|
39
|
-
|
40
|
-
2. define request parameters. Example:
|
41
|
-
```ruby
|
42
|
-
class AuthorsController < ApplicationController
|
43
|
-
|
44
|
-
has_scope :article_id, :name
|
45
|
-
|
46
|
-
# Define parameters with type and nested options
|
47
|
-
# Article and Datum are usual ActiveRecord models
|
48
|
-
parameter :age, type: :integer
|
49
|
-
parameter :name, type: :string, required: true
|
50
|
-
parameter :articles_attributes, type: :ary_object, model: 'Article' do
|
51
|
-
parameter :title, type: :string
|
52
|
-
parameter :body, type: :string, required: true
|
53
|
-
parameter :rating, type: :enum, enum: [1, 2, 3]
|
54
|
-
parameter :data_attributes, type: :object, model: 'Datum' do
|
55
|
-
parameter :creation_date, type: :datetime
|
56
|
-
parameter :comment, type: :string
|
57
|
-
end
|
58
|
-
end
|
59
|
-
parameter :test, type: :string, required: true
|
60
|
-
|
61
|
-
parameter({
|
62
|
-
articles_attributes: { model: 'Article', type: :ary_object },
|
63
|
-
data_attributes: { model: 'Datum' },
|
64
|
-
comments_attributes: { model: 'Comment', type: :ary_object }
|
65
|
-
}, type: :object) do
|
66
|
-
parameter :id
|
67
|
-
parameter :name
|
68
|
-
end
|
69
39
|
|
40
|
+
3. define request parameters. Example:
|
41
|
+
```ruby
|
42
|
+
class AuthorsController < ApplicationController
|
43
|
+
|
44
|
+
has_scope :article_id, :name
|
45
|
+
|
46
|
+
# Define parameters with type and nested options
|
47
|
+
# Article and Datum are usual ActiveRecord models
|
48
|
+
parameter :age, type: :integer
|
49
|
+
parameter :name, type: :string, required: true
|
50
|
+
parameter :articles_attributes, type: :ary_object, model: 'Article' do
|
51
|
+
parameter :title, type: :string
|
52
|
+
parameter :body, type: :string, required: true
|
53
|
+
parameter :rating, type: :enum, enum: [1, 2, 3]
|
54
|
+
parameter :data_attributes, type: :object, model: 'Datum' do
|
55
|
+
parameter :creation_date, type: :datetime
|
56
|
+
parameter :comment, type: :string
|
70
57
|
end
|
71
|
-
|
72
|
-
|
58
|
+
end
|
59
|
+
parameter :test, type: :string, required: true
|
60
|
+
|
61
|
+
parameter({
|
62
|
+
articles_attributes: { model: 'Article', type: :ary_object },
|
63
|
+
data_attributes: { model: 'Datum' },
|
64
|
+
comments_attributes: { model: 'Comment', type: :ary_object }
|
65
|
+
}, type: :object) do
|
66
|
+
parameter :id
|
67
|
+
parameter :name
|
68
|
+
end
|
73
69
|
|
74
|
-
|
70
|
+
end
|
71
|
+
```
|
75
72
|
|
76
|
-
|
77
|
-
Usually we use something like `params.permit(:name, :age)`, but no more!
|
78
|
-
With this gem bundled you can do this:
|
73
|
+
4. go to localhost:3000/api_doc
|
79
74
|
|
80
|
-
|
75
|
+
## Strong params
|
81
76
|
|
82
|
-
|
83
|
-
|
77
|
+
You may want to use your defined request api to filter incoming parameters.
|
78
|
+
Usually we use something like `params.permit(:name, :age)`, but no more!
|
79
|
+
With this gem bundled you can do this:
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
81
|
+
```ruby
|
82
|
+
parameter :body, type: :string
|
83
|
+
parameter :title, type: :string
|
89
84
|
|
90
|
-
|
85
|
+
# controller action
|
86
|
+
def create
|
87
|
+
Comment.create!(strong_params)
|
88
|
+
end
|
89
|
+
```
|
91
90
|
|
92
|
-
|
91
|
+
and if request is `POST '/comments', params: { body: 'Comment body', title: 'Comment title', age: 34 }`
|
93
92
|
|
94
|
-
|
93
|
+
Comment will be created with: `Comment(body='Comment body', title='Comment title', age=nil)`
|
95
94
|
|
96
95
|
## Value
|
97
96
|
|
98
|
-
|
97
|
+
You can pass optional value argument to every parameter:
|
99
98
|
|
100
|
-
|
101
|
-
|
102
|
-
|
99
|
+
```ruby
|
100
|
+
parameter :val, type: :integer, value: -> (request_value) { 5 }
|
101
|
+
```
|
103
102
|
|
104
|
-
|
103
|
+
on every matching request value in this field will be overriden by value returned by proc.
|
105
104
|
|
106
|
-
|
105
|
+
value field expecting anything that will respond to `:call` and can accept one argument(param value from request)
|
107
106
|
|
108
|
-
|
107
|
+
you should expect that value passed can be `nil`
|
109
108
|
|
110
|
-
|
109
|
+
This can be used to force values on some fields, or modify values passed to request in some ways.
|
111
110
|
|
112
|
-
|
111
|
+
E.g. you want to force current_user_id on model creation instead of passing it from frontend.
|
113
112
|
|
114
113
|
## Enum
|
115
114
|
|
116
|
-
|
115
|
+
When you defined parameter type as `:enum` you can pass `enum:` option. This will filter parameter by values provided.
|
117
116
|
|
118
|
-
|
117
|
+
E.g.:
|
119
118
|
|
120
|
-
|
119
|
+
```ruby
|
120
|
+
parameter :rating, type: :enum, enum: [1, 2, 3]
|
121
|
+
```
|
121
122
|
|
122
|
-
|
123
|
-
parameter({
|
124
|
-
articles_attributes: { model: 'Article', type: :ary_object },
|
125
|
-
data_attributes: { model: 'Datum' },
|
126
|
-
comments_attributes: { model: 'Comment', type: :ary_object }
|
127
|
-
}, type: :object) do
|
128
|
-
parameter :id
|
129
|
-
parameter :name
|
130
|
-
end
|
131
|
-
```
|
123
|
+
All enum values are parsed as strings, since controller params are always strings. Still you may write them as you want. Every member of enum array will be replaced with `&:to_s` version.
|
132
124
|
|
133
|
-
|
134
|
-
All nesting parameters are applied to elements in blocks.
|
125
|
+
## Group common blocks
|
135
126
|
|
136
|
-
|
127
|
+
You can define parameters that have common fields this way:
|
137
128
|
|
138
|
-
|
139
|
-
|
140
|
-
|
129
|
+
```ruby
|
130
|
+
parameter({
|
131
|
+
articles_attributes: { model: 'Article', type: :ary_object },
|
132
|
+
data_attributes: { model: 'Datum' },
|
133
|
+
comments_attributes: { model: 'Comment', type: :ary_object }
|
134
|
+
}, type: :object) do
|
135
|
+
parameter :id
|
136
|
+
parameter :name
|
137
|
+
end
|
138
|
+
```
|
141
139
|
|
142
|
-
|
140
|
+
Pass common values as last optional arguments and uniq definitions as hash value.
|
141
|
+
All nesting parameters are applied to elements in blocks.
|
143
142
|
|
144
|
-
|
143
|
+
Something with same type can be defined like this:
|
145
144
|
|
146
|
-
|
145
|
+
```ruby
|
146
|
+
parameter :name, :desc, type: :string
|
147
|
+
```
|
147
148
|
|
148
|
-
|
149
|
-
:bool - Boolean type, accepts true, false, 'true', 'false'
|
150
|
-
:string - will accept anything beside nested type
|
151
|
-
:integer - accepts numbers as string value, and usual numbers
|
152
|
-
:array - array of atomic values (integer, strings, etc)
|
153
|
-
:datetime - string with some datetime representation accepted by DateTime.parse
|
154
|
-
:enum - one of predefined values of enum: option (only atomic types)
|
149
|
+
## Types
|
155
150
|
|
156
|
-
|
157
|
-
:object - usual nested type. comes very handy with rails nested_attributes feature
|
158
|
-
:ary_object - array of :object type, rails nested_attributes on has_many
|
151
|
+
Parameter type may be one of these:
|
159
152
|
|
160
|
-
|
153
|
+
```ruby
|
154
|
+
# Non nested
|
155
|
+
:bool - Boolean type, accepts true, false, 'true', 'false'
|
156
|
+
:string - will accept anything beside nested type
|
157
|
+
:integer - accepts numbers as string value, and usual numbers
|
158
|
+
:array - array of atomic values (integer, strings, etc)
|
159
|
+
:datetime - string with some datetime representation accepted by DateTime.parse
|
160
|
+
:enum - one of predefined values of enum: option (only atomic types)
|
161
|
+
:model - model reference e.g. :author_id, add model value as model: 'Author' after this
|
162
|
+
|
163
|
+
# nested
|
164
|
+
:object - usual nested type. comes very handy with rails nested_attributes feature
|
165
|
+
:ary_object - array of :object type, rails nested_attributes on has_many
|
166
|
+
```
|
161
167
|
|
162
168
|
## TODO's
|
163
169
|
+ type for id reference with model field to display associated model and CONTROLLER in params for linking
|
164
170
|
|
165
171
|
+ native DSL for defining response
|
166
172
|
```ruby
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
end
|
173
|
+
action :show do
|
174
|
+
response :age, type: Integer
|
175
|
+
response :name, type String
|
176
|
+
response :data, type: :model, model: Datum do
|
177
|
+
response :creation_date, type: DateTime
|
178
|
+
response :comment, type: String
|
174
179
|
end
|
180
|
+
end
|
175
181
|
```
|
176
182
|
+ native DSL for defining scopes
|
177
183
|
```ruby
|
@@ -179,9 +185,9 @@ scope :age, desc: 'Filters authors by given age'
|
|
179
185
|
```
|
180
186
|
+ dsl for extending response parameters
|
181
187
|
```ruby
|
182
|
-
|
183
|
-
|
184
|
-
|
188
|
+
response :data, type: :model, model: Datum do
|
189
|
+
extends DataController, action: :show
|
190
|
+
end
|
185
191
|
```
|
186
192
|
+ dsl for extending request parameters
|
187
193
|
```ruby
|
data/lib/rails_api_doc/config.rb
CHANGED
@@ -23,6 +23,8 @@ module RailsApiDoc
|
|
23
23
|
#
|
24
24
|
# 3. parameter :name, :code, type: :string
|
25
25
|
#
|
26
|
+
# 4. param :name, :string, model: 'Name'
|
27
|
+
#
|
26
28
|
def parameter(*arguments, &block)
|
27
29
|
options = arguments.extract_options!
|
28
30
|
|
@@ -30,6 +32,9 @@ module RailsApiDoc
|
|
30
32
|
|
31
33
|
validate_options(options, block_given?)
|
32
34
|
|
35
|
+
# 4)
|
36
|
+
return if second_argument_type_def(options, arguments)
|
37
|
+
|
33
38
|
arguments.each do |param|
|
34
39
|
# 2)
|
35
40
|
if param.is_a?(Hash)
|
@@ -44,6 +49,9 @@ module RailsApiDoc
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
52
|
+
alias param parameter
|
53
|
+
alias req parameter
|
54
|
+
|
47
55
|
private
|
48
56
|
|
49
57
|
def validate_options(options, _block_given)
|
@@ -73,12 +81,32 @@ module RailsApiDoc
|
|
73
81
|
end
|
74
82
|
|
75
83
|
def nested_parameter(parameter_data)
|
76
|
-
|
84
|
+
backup_repo = @repo
|
77
85
|
@repo = {}
|
78
86
|
yield
|
79
87
|
parameter_data.merge(nested: @repo)
|
80
88
|
ensure
|
81
|
-
@repo =
|
89
|
+
@repo = backup_repo
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Checks whetjher parameters can be defined by type 4)
|
94
|
+
# if possible - do it
|
95
|
+
# otherwise pass next
|
96
|
+
#
|
97
|
+
def second_argument_type_def(options, args)
|
98
|
+
is_ok = second_argument_is_type?(args)
|
99
|
+
|
100
|
+
return false unless is_ok
|
101
|
+
param = args[0]
|
102
|
+
options[:type] = args[1]
|
103
|
+
|
104
|
+
define_parameter(param, options, &block)
|
105
|
+
true
|
106
|
+
end
|
107
|
+
|
108
|
+
def second_argument_is_type?(args)
|
109
|
+
RailsApiDoc::ACCEPTED_TYPES.include?(args[1]&.to_sym)
|
82
110
|
end
|
83
111
|
|
84
112
|
end
|
@@ -8,9 +8,6 @@ module RailsApiDoc
|
|
8
8
|
include RailsApiDoc::Controller::ResourceParams::PermittedParams # implements params_to_permit
|
9
9
|
|
10
10
|
def strong_params(pars = params)
|
11
|
-
#
|
12
|
-
# accepted_params for permit
|
13
|
-
#
|
14
11
|
permitted = params_to_permit(pars)
|
15
12
|
|
16
13
|
pars.permit(permitted)
|
@@ -5,12 +5,15 @@ module RailsApiDoc
|
|
5
5
|
module ResourceParams
|
6
6
|
module PermittedParams
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
#
|
9
|
+
# accepted_params for permit
|
10
|
+
#
|
10
11
|
def params_to_permit(pars = params)
|
11
12
|
_next_nesting_level(pars, param_data: _permitted_params)
|
12
13
|
end
|
13
14
|
|
15
|
+
private
|
16
|
+
|
14
17
|
def _permitted_params
|
15
18
|
::RailsApiDoc::Controller::Request::Repository[self.class]
|
16
19
|
end
|
@@ -24,7 +27,9 @@ module RailsApiDoc
|
|
24
27
|
level_accepted_params = [{}]
|
25
28
|
|
26
29
|
if param_name && current_accepted_params # no param name and current_accepted_params on first iteration
|
27
|
-
current_accepted_params.last[param_name]
|
30
|
+
current_accepted_params.last[param_name] ||= level_accepted_params
|
31
|
+
|
32
|
+
level_accepted_params = current_accepted_params.last[param_name]
|
28
33
|
end
|
29
34
|
|
30
35
|
loop_params(controller_param, param_data, level_accepted_params)
|
@@ -46,33 +51,43 @@ module RailsApiDoc
|
|
46
51
|
#
|
47
52
|
def loop_params(params, level_permitted_params, accepted_params)
|
48
53
|
level_permitted_params.each do |param_name, api_param_data|
|
54
|
+
next if accepted_params.include?(param_name) || accepted_params.last.key?(param_name)
|
55
|
+
|
49
56
|
if api_param_data.value&.respond_to?(:call)
|
50
|
-
params[param_name] = api_param_data.value
|
57
|
+
params[param_name] = instance_eval(&api_param_data.value)
|
51
58
|
end
|
52
59
|
|
53
60
|
controller_param = params[param_name]
|
54
61
|
|
55
62
|
_check_required(param_name, controller_param, api_param_data) # raise if required and no value
|
56
63
|
|
64
|
+
#
|
57
65
|
# no value present && not required => skip
|
58
|
-
|
66
|
+
#
|
67
|
+
# nil value is still ok params.key?(param_key) returns true if we have params = { param_key => nil }
|
68
|
+
#
|
69
|
+
next unless params.key?(param_name)
|
59
70
|
|
60
71
|
# value present but not valid for this type => skip
|
61
72
|
next unless RailsApiDoc::Config::Validator.valid_param?(controller_param, api_param_data)
|
62
73
|
|
63
74
|
if api_param_data.ary_object? # controller_param value should be array of objects
|
64
|
-
controller_param
|
75
|
+
controller_param&.each do |single_controller_param|
|
65
76
|
_next_nesting_level(single_controller_param,
|
66
77
|
param_data: api_param_data.nested,
|
67
78
|
current_accepted_params: accepted_params,
|
68
79
|
param_name: param_name)
|
69
80
|
end
|
70
81
|
elsif api_param_data.nested? # value should be nested object
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
82
|
+
if controller_param
|
83
|
+
_next_nesting_level(controller_param,
|
84
|
+
param_data: api_param_data.nested,
|
85
|
+
current_accepted_params: accepted_params,
|
86
|
+
param_name: param_name)
|
87
|
+
end
|
75
88
|
|
89
|
+
elsif api_param_data.array?
|
90
|
+
accepted_params.last[param_name] = []
|
76
91
|
else # all other options
|
77
92
|
accepted_params.unshift(param_name)
|
78
93
|
end
|
@@ -54,7 +54,7 @@ class RailsApiDoc::Model::AttributeParser
|
|
54
54
|
def parse_special(type, special)
|
55
55
|
return unless special.present? && type
|
56
56
|
|
57
|
-
if type == :enum
|
57
|
+
if type.to_sym == :enum
|
58
58
|
parse_enum(special) # parse as enum array value
|
59
59
|
elsif RailsApiDoc::NESTED_TYPES.include?(type.to_sym)
|
60
60
|
special.capitalize # parse as model name
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
3
|
+
# :nodoc:
|
4
|
+
module RailsApiDoc::Params::DSL
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
#:nodoc:
|
11
|
+
module ClassMethods
|
12
|
+
def parameter_class=(value)
|
13
|
+
@parameter_class = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def parameter_class
|
17
|
+
@parameter_class ||= RailsApiDoc::Params::Finder.new(self).call
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ctrl_strong_params
|
22
|
+
@ctrl_strong_params ||= ctrl_parameters.strong_params(params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ctrl_parameters
|
26
|
+
@ctrl_parameters ||= self.class.parameter_class.new
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
3
|
+
# :nodoc:
|
4
|
+
class RailsApiDoc::Params::Finder
|
5
|
+
|
6
|
+
SUFFIX = 'Parameter'
|
7
|
+
|
8
|
+
def initialize(object)
|
9
|
+
@object = object
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
klass = find_class_name(@object).name.sub(/Ctrl$/, '')
|
14
|
+
|
15
|
+
"#{klass}#{SUFFIX}".constantize
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_class_name(subject)
|
21
|
+
if subject.respond_to?(:model_name)
|
22
|
+
subject.model_name
|
23
|
+
elsif subject.class.respond_to?(:model_name)
|
24
|
+
subject.class.model_name
|
25
|
+
elsif subject.is_a?(Class)
|
26
|
+
subject
|
27
|
+
elsif subject.is_a?(Symbol)
|
28
|
+
subject.to_s.camelize
|
29
|
+
else
|
30
|
+
subject.class
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -1,13 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
1
3
|
module RailsApiDoc
|
2
4
|
class Railtie < Rails::Railtie
|
5
|
+
|
3
6
|
initializer 'api_doc.controller_additions' do
|
4
7
|
ActiveSupport.on_load :action_controller do
|
5
|
-
|
6
8
|
include RailsApiDoc::Controller::ResourceParams::DSL
|
7
9
|
|
8
10
|
extend RailsApiDoc::Controller::Request::DSL
|
9
11
|
|
12
|
+
include RailsApiDoc::Params::DSL
|
10
13
|
end
|
11
14
|
end
|
15
|
+
|
12
16
|
end
|
13
17
|
end
|
data/lib/rails_api_doc.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# author: Vadim Shaveiko <@vshaveyko>
|
2
2
|
# frozen_string_literal: true
|
3
3
|
module RailsApiDoc
|
4
|
-
|
4
|
+
|
5
5
|
NESTED_TYPES = [:ary_object, :object, :json].freeze
|
6
6
|
|
7
7
|
STRAIGHT_TYPES = [:bool, :string, :integer, :array, :datetime, :enum, :model].freeze
|
8
8
|
|
9
9
|
ACCEPTED_TYPES = (NESTED_TYPES + STRAIGHT_TYPES).freeze
|
10
10
|
|
11
|
+
_dir = 'rails_api_doc/'
|
12
|
+
|
11
13
|
module Controller
|
12
14
|
_dir = 'rails_api_doc/controller/'
|
13
15
|
|
@@ -42,6 +44,16 @@ module RailsApiDoc
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
47
|
+
require _dir + 'params/main'
|
48
|
+
class Params
|
49
|
+
|
50
|
+
_dir = 'rails_api_doc/params/'
|
51
|
+
|
52
|
+
autoload :DSL, _dir + 'dsl'
|
53
|
+
autoload :Finder, _dir + 'finder'
|
54
|
+
|
55
|
+
end
|
56
|
+
|
45
57
|
module Model
|
46
58
|
_dir = 'rails_api_doc/model/'
|
47
59
|
|
@@ -49,7 +61,7 @@ module RailsApiDoc
|
|
49
61
|
autoload :AttributeParser, _dir + 'attribute_parser'
|
50
62
|
end
|
51
63
|
|
52
|
-
require '
|
64
|
+
require _dir + 'config'
|
53
65
|
class Config
|
54
66
|
|
55
67
|
_dir = 'rails_api_doc/config/'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_api_documentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,6 +184,9 @@ files:
|
|
184
184
|
- lib/rails_api_doc/exception/param_required.rb
|
185
185
|
- lib/rails_api_doc/model/attribute_merger.rb
|
186
186
|
- lib/rails_api_doc/model/attribute_parser.rb
|
187
|
+
- lib/rails_api_doc/params/dsl.rb
|
188
|
+
- lib/rails_api_doc/params/finder.rb
|
189
|
+
- lib/rails_api_doc/params/main.rb
|
187
190
|
- lib/rails_api_doc/railtie.rb
|
188
191
|
- lib/rails_api_doc/version.rb
|
189
192
|
homepage: https://github.com/vshaveyko/rails_api_doc
|
@@ -193,7 +196,7 @@ metadata: {}
|
|
193
196
|
post_install_message:
|
194
197
|
rdoc_options: []
|
195
198
|
require_paths:
|
196
|
-
- lib
|
199
|
+
- lib/rails_api_doc.rb
|
197
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
198
201
|
requirements:
|
199
202
|
- - ">="
|
@@ -206,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
209
|
version: '0'
|
207
210
|
requirements: []
|
208
211
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.6.8
|
210
213
|
signing_key:
|
211
214
|
specification_version: 4
|
212
215
|
summary: Nice API doc.
|