rails_api_documentation 0.2.2 → 0.2.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 +5 -0
- data/app/assets/javascripts/table.js.coffee +8 -3
- data/app/assets/stylesheets/rails_api_doc/application.css +1 -0
- data/app/assets/stylesheets/rails_api_doc/default.sass +31 -0
- data/app/assets/stylesheets/rails_api_doc/side_menu.sass +12 -23
- data/app/assets/stylesheets/rails_api_doc/table.sass +104 -84
- data/app/controllers/rails_api_doc/api_docs_controller.rb +19 -18
- data/app/models/rails_api_doc/api_datum.rb +8 -0
- data/app/views/layouts/rails_api_doc/application.slim +10 -9
- data/app/views/rails_api_doc/api_docs/_request_api_table.slim +4 -3
- data/app/views/rails_api_doc/api_docs/_response_api_table.slim +13 -6
- data/app/views/rails_api_doc/api_docs/index.slim +15 -20
- data/app/views/shared/_param_inputs.slim +8 -0
- data/app/views/shared/_side_menu.slim +9 -0
- data/app/views/shared/_table.slim +37 -17
- data/lib/generators/rails_api_doc/install_generator.rb +23 -0
- data/lib/generators/rails_api_doc/templates/api_datum_migration.rb +15 -0
- data/lib/rails_api_doc/config/validate_ary_object.rb +1 -1
- data/lib/rails_api_doc/config/validate_enum.rb +1 -1
- data/lib/rails_api_doc/config/validate_type.rb +1 -1
- data/lib/rails_api_doc/config/validator.rb +0 -4
- data/lib/rails_api_doc/config.rb +0 -2
- data/lib/rails_api_doc/controller/request/dsl.rb +60 -0
- data/lib/rails_api_doc/controller/request/headers.rb +56 -0
- data/lib/rails_api_doc/controller/request/param.rb +81 -0
- data/lib/rails_api_doc/controller/{parameter → request}/repository.rb +3 -1
- data/lib/rails_api_doc/controller/{response_factory.rb → response/factory.rb} +2 -2
- data/lib/rails_api_doc/controller/response/headers.rb +30 -0
- data/lib/rails_api_doc/controller/response/param.rb +14 -0
- data/lib/rails_api_doc/controller/response/rabl.rb +3 -1
- data/lib/rails_api_doc/controller/response/rabl_compiler.rb +4 -13
- data/lib/rails_api_doc/controller/strong_params/dsl.rb +17 -0
- data/lib/rails_api_doc/controller/strong_params/permitted_params.rb +88 -0
- data/lib/rails_api_doc/engine.rb +0 -12
- data/lib/rails_api_doc/{controller → model}/attribute_parser.rb +1 -1
- data/lib/rails_api_doc/railtie.rb +5 -2
- data/lib/rails_api_doc/version.rb +1 -1
- data/lib/rails_api_doc.rb +48 -1
- metadata +18 -16
- data/app/views/rails_api_doc/api_docs/_edit_field.slim +0 -9
- data/app/views/rails_api_doc/api_docs/_side_menu.slim +0 -9
- data/app/views/rails_api_doc/api_docs/_title.slim +0 -4
- data/app/views/rails_api_doc/api_docs/edit.js.erb +0 -0
- data/app/views/rails_api_doc/api_docs/example.html.erb +0 -32
- data/app/views/rails_api_doc/api_docs/new.js.erb +0 -0
- data/app/views/shared/_response_table.slim +0 -30
- data/lib/rails_api_doc/controller/parameter/repository/param.rb +0 -68
- data/lib/rails_api_doc/controller/parameter.rb +0 -54
- data/lib/rails_api_doc/controller/strong_params.rb +0 -71
- data/lib/rails_api_doc/controller.rb +0 -6
@@ -3,7 +3,7 @@
|
|
3
3
|
class RailsApiDoc::Config::ValidateAryObject
|
4
4
|
|
5
5
|
#
|
6
|
-
# @api_param_data - RailsApiDoc::Controller::
|
6
|
+
# @api_param_data - RailsApiDoc::Controller::Request::Param
|
7
7
|
# @controller_param - ActionController::Parameter
|
8
8
|
#
|
9
9
|
# check validation of current type by given data
|
@@ -4,7 +4,7 @@
|
|
4
4
|
class RailsApiDoc::Config::ValidateEnum
|
5
5
|
|
6
6
|
#
|
7
|
-
# @api_param_data - RailsApiDoc::Controller::
|
7
|
+
# @api_param_data - RailsApiDoc::Controller::Ruquest::Param
|
8
8
|
# @controller_param - ActionController::Parameter
|
9
9
|
#
|
10
10
|
# check validation of current type by given data
|
@@ -4,7 +4,7 @@
|
|
4
4
|
class RailsApiDoc::Config::ValidateType
|
5
5
|
|
6
6
|
#
|
7
|
-
# @api_param_data - RailsApiDoc::Controller::
|
7
|
+
# @api_param_data - RailsApiDoc::Controller::Request::Param
|
8
8
|
# @controller_param - ActionController::Parameter
|
9
9
|
#
|
10
10
|
# check validation of current type by given data
|
data/lib/rails_api_doc/config.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
3
|
+
module RailsApiDoc
|
4
|
+
module Controller
|
5
|
+
module Request
|
6
|
+
module DSL
|
7
|
+
|
8
|
+
VALID_KEYS = [:type, :required, :enum, :model, :desc, :value].freeze #:nodoc:
|
9
|
+
|
10
|
+
# Use parameter in controller to define REQUEST parameter.
|
11
|
+
# Adds it to repository: RailsApiDoc::Controller::Request::Repository
|
12
|
+
def parameter(name, options = {}, &block)
|
13
|
+
raise ArgumentError, 'Parameter already defined.' if repo.key?(name)
|
14
|
+
|
15
|
+
validate_options(options, block_given?)
|
16
|
+
|
17
|
+
define_parameter(name, options, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def validate_options(options, block_given)
|
23
|
+
options.assert_valid_keys(VALID_KEYS)
|
24
|
+
|
25
|
+
RailsApiDoc::Controller::Request::Param.valid_type?(options[:type])
|
26
|
+
end
|
27
|
+
|
28
|
+
# default repo can be reassigned to deal with nested parameters
|
29
|
+
# see nested_parameter
|
30
|
+
def repo
|
31
|
+
@repo || RailsApiDoc::Controller::Request::Repository[self]
|
32
|
+
end
|
33
|
+
|
34
|
+
# adjust parameter values depending on parameter type
|
35
|
+
# 1. if nested - add nested values to parameter_data on :nested key
|
36
|
+
# 2. if enum - transform all values to_s
|
37
|
+
# bcs all incoming controller parameters will be strings and there can be errors
|
38
|
+
def define_parameter(name, parameter_data, &block)
|
39
|
+
if RailsApiDoc::Controller::Request::Param.valid_nested?(parameter_data[:type], block_given?)
|
40
|
+
parameter_data = nested_parameter(parameter_data, &block)
|
41
|
+
elsif RailsApiDoc::Controller::Request::Param.valid_enum?(parameter_data[:type], parameter_data[:enum])
|
42
|
+
parameter_data[:enum].map!(:to_s)
|
43
|
+
end
|
44
|
+
|
45
|
+
repo[name] = RailsApiDoc::Controller::Request::Param.new(name, parameter_data)
|
46
|
+
end
|
47
|
+
|
48
|
+
def nested_parameter(parameter_data)
|
49
|
+
_backup_repo = @repo
|
50
|
+
@repo = {}
|
51
|
+
yield
|
52
|
+
parameter_data.merge(nested: @repo)
|
53
|
+
ensure
|
54
|
+
@repo = _backup_repo
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# :nodoc:
|
2
|
+
module RailsApiDoc
|
3
|
+
module Controller
|
4
|
+
module Request
|
5
|
+
module Headers
|
6
|
+
|
7
|
+
def headers
|
8
|
+
REQUEST_HEADERS
|
9
|
+
end
|
10
|
+
|
11
|
+
REQUEST_HEADERS = {
|
12
|
+
'Parameter' => {
|
13
|
+
value: -> (row_name, row_values) {
|
14
|
+
title = row_name.to_s
|
15
|
+
title += '*' if row_values.required?
|
16
|
+
title
|
17
|
+
},
|
18
|
+
fill_type: :input,
|
19
|
+
param: :name
|
20
|
+
},
|
21
|
+
'Type' => {
|
22
|
+
value: -> (row_name, row_values) {
|
23
|
+
if row_values.nested?
|
24
|
+
(row_values.model || row_values.type).to_s + "(Nested)"
|
25
|
+
else
|
26
|
+
row_values.type
|
27
|
+
end
|
28
|
+
},
|
29
|
+
fill_type: :select,
|
30
|
+
param: :type,
|
31
|
+
values: RailsApiDoc::Controller::Request::Param::ACCEPTED_TYPES
|
32
|
+
},
|
33
|
+
'Special' => {
|
34
|
+
value: -> (row_name, row_values) {
|
35
|
+
case
|
36
|
+
when row_values.enum?
|
37
|
+
row_values[:enum]
|
38
|
+
when row_values.model?
|
39
|
+
row_values[:model]
|
40
|
+
end
|
41
|
+
},
|
42
|
+
fill_type: :input,
|
43
|
+
param: :special
|
44
|
+
},
|
45
|
+
'Desc' => {
|
46
|
+
value: -> (row_name, row_values) {
|
47
|
+
'TODO: description' # if row_values[:desc]
|
48
|
+
},
|
49
|
+
fill_type: :input,
|
50
|
+
param: :desc
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
3
|
+
module RailsApiDoc
|
4
|
+
module Controller
|
5
|
+
module Request
|
6
|
+
class Param
|
7
|
+
|
8
|
+
NESTED_TYPES = [:ary_object, :object, :model, Object].freeze
|
9
|
+
|
10
|
+
STRAIGHT_TYPES = [:bool, :string, :integer, :array, :datetime, :enum, String, Object, Integer, Array, DateTime].freeze
|
11
|
+
|
12
|
+
ACCEPTED_TYPES = (NESTED_TYPES + STRAIGHT_TYPES).freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# @type - type to check
|
16
|
+
#
|
17
|
+
def self.accepted_nested_type?(type)
|
18
|
+
type.in?(NESTED_TYPES)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.valid_type?(type)
|
22
|
+
return if type.nil? || type.in?(ACCEPTED_TYPES)
|
23
|
+
raise ArgumentError, "Wrong type: #{type}. " \
|
24
|
+
"Correct types are: #{ACCEPTED_TYPES}."
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.valid_enum?(type, enum)
|
28
|
+
return false unless type == :enum
|
29
|
+
return if enum.is_a?(Array)
|
30
|
+
raise ArgumentError, 'Enum must be an array.'
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.valid_nested?(type, block_given)
|
34
|
+
return false unless accepted_nested_type?(type)
|
35
|
+
return true if block_given
|
36
|
+
raise ArgumentError, 'Empty object passed.'
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(name, store)
|
40
|
+
@name = name
|
41
|
+
@store = store
|
42
|
+
end
|
43
|
+
|
44
|
+
def nested?
|
45
|
+
self.class.accepted_nested_type?(@store[:type])
|
46
|
+
end
|
47
|
+
|
48
|
+
def required?
|
49
|
+
@store[:required]
|
50
|
+
end
|
51
|
+
|
52
|
+
def method_missing(name, *args)
|
53
|
+
#
|
54
|
+
# define methods responding to each type with '?'
|
55
|
+
# ex: ary_object? array? string?
|
56
|
+
#
|
57
|
+
if name[-1] == '?'
|
58
|
+
type_name = name[0...-1]
|
59
|
+
|
60
|
+
return @store[:type] == type_name.to_sym
|
61
|
+
end
|
62
|
+
|
63
|
+
if @store.key?(name)
|
64
|
+
return @store[name]
|
65
|
+
end
|
66
|
+
|
67
|
+
if respond_to_missing?(name)
|
68
|
+
return @store.public_send(name, *args)
|
69
|
+
end
|
70
|
+
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
74
|
+
def respond_to_missing?(name, *)
|
75
|
+
@store.respond_to?(name) || @store.key?(name)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# author: Vadim Shaveiko <@vshaveyko>
|
3
3
|
# :nodoc:
|
4
|
-
class RailsApiDoc::Controller::
|
4
|
+
class RailsApiDoc::Controller::Request::Repository
|
5
|
+
|
6
|
+
extend RailsApiDoc::Controller::Request::Headers
|
5
7
|
|
6
8
|
@repo = Hash.new { |hsh, key| hsh[key] = Hash.new { |hsh, key| hsh[key] = Param.new(key) } }
|
7
9
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# author: Vadim Shaveiko <@vshaveyko>
|
3
3
|
# :nodoc:
|
4
|
-
class RailsApiDoc::Controller::Response
|
4
|
+
class RailsApiDoc::Controller::Response::Factory
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
@@ -11,7 +11,7 @@ class RailsApiDoc::Controller::Response
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def controllers
|
14
|
-
RailsApiDoc::Controller::
|
14
|
+
RailsApiDoc::Controller::Request::Repository.registered_controllers
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# :nodoc:
|
2
|
+
module RailsApiDoc::Controller::Response::Headers
|
3
|
+
|
4
|
+
RESPONSE_HEADERS = {
|
5
|
+
'Parameter' => {
|
6
|
+
value: -> (row_name, row_values) { row_name },
|
7
|
+
fill_type: :input,
|
8
|
+
param: :name
|
9
|
+
},
|
10
|
+
'Value' => {
|
11
|
+
value: -> (row_name, row_values) {
|
12
|
+
title = row_values.attr.to_s
|
13
|
+
title += '(NESTED)' if row_values.nested?
|
14
|
+
title
|
15
|
+
}
|
16
|
+
},
|
17
|
+
'Desc' => {
|
18
|
+
value: -> (row_name, row_values) {
|
19
|
+
'TODO: description' # if row_values[:desc]
|
20
|
+
},
|
21
|
+
fill_type: :input,
|
22
|
+
param: :desc
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
def headers
|
27
|
+
RESPONSE_HEADERS
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -2,11 +2,13 @@
|
|
2
2
|
# author: Vadim Shaveiko <@vshaveyko>
|
3
3
|
# :nodoc:
|
4
4
|
# :nodoc:
|
5
|
-
|
5
|
+
module RailsApiDoc::Controller::Response
|
6
6
|
|
7
7
|
# :nodoc:
|
8
8
|
class Rabl
|
9
9
|
|
10
|
+
include RailsApiDoc::Controller::Response::Headers
|
11
|
+
|
10
12
|
class << self
|
11
13
|
|
12
14
|
attr_accessor :renderer
|
@@ -1,16 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# author: Vadim Shaveiko <@vshaveyko>
|
3
3
|
# :nodoc:
|
4
|
-
|
5
|
-
class RailsApiDoc::Controller::Response
|
6
|
-
|
7
|
-
class Node < Struct.new(:name, :attr, :nested)
|
8
|
-
|
9
|
-
def nested?
|
10
|
-
!nested.nil?
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
4
|
+
module RailsApiDoc::Controller::Response
|
14
5
|
|
15
6
|
# template struct
|
16
7
|
class CompiledAttributes
|
@@ -36,7 +27,7 @@ class RailsApiDoc::Controller::Response
|
|
36
27
|
n[:name] = "#{n[:name]}(#{n[:attr]})"
|
37
28
|
end
|
38
29
|
|
39
|
-
@nodes[n[:name]] =
|
30
|
+
@nodes[n[:name]] = RailsApiDoc::Controller::Response::Param.new(n[:name], n[:attr], n[:nested])
|
40
31
|
end
|
41
32
|
|
42
33
|
def extends(template)
|
@@ -50,9 +41,9 @@ class RailsApiDoc::Controller::Response
|
|
50
41
|
|
51
42
|
def initialize(file_path, view_path: 'app/views')
|
52
43
|
paths = Dir["#{view_path}/#{file_path}{.json,}.rabl"]
|
53
|
-
file_path = paths.find { |path| File.exist?(path) }
|
44
|
+
@file_path = paths.find { |path| File.exist?(path) }
|
54
45
|
|
55
|
-
@source = _preserve_ivars File.read(file_path)
|
46
|
+
@source = _preserve_ivars File.read(@file_path)
|
56
47
|
rescue
|
57
48
|
end
|
58
49
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# :nodoc:
|
2
|
+
module RailsApiDoc
|
3
|
+
module Controller
|
4
|
+
module ResourceParams
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
include RailsApiDoc::Controller::ResourceParams::PermittedParams # implements params_to_permit
|
8
|
+
|
9
|
+
def resource_params
|
10
|
+
# accepted_params for permit
|
11
|
+
params.permit(params_to_permit)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# author: Vadim Shaveiko <@vshaveyko>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module RailsApiDoc
|
4
|
+
module Controller
|
5
|
+
module ResourceParams
|
6
|
+
module PermittedParams
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def params_to_permit
|
11
|
+
_next_nesting_level(params, param_data: _permitted_params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def _permitted_params
|
15
|
+
::RailsApiDoc::Controller::Request::Repository[self.class]
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# iterate recursively
|
20
|
+
# level_accepted_params initted as [{}] bcs params permit accepts
|
21
|
+
# aray with hash as a last arguments for describing nesting levels
|
22
|
+
#
|
23
|
+
def _next_nesting_level(controller_param, param_data:, current_accepted_params: nil, param_name: nil)
|
24
|
+
level_accepted_params = [{}]
|
25
|
+
|
26
|
+
if param_name && current_accepted_params # no param name and current_accepted_params on first iteration
|
27
|
+
current_accepted_params.last[param_name] = level_accepted_params
|
28
|
+
end
|
29
|
+
|
30
|
+
loop_params(controller_param, param_data, level_accepted_params)
|
31
|
+
|
32
|
+
level_accepted_params
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
#
|
37
|
+
# loop through current level of params and add to permit level if all requirements are met
|
38
|
+
#
|
39
|
+
# requirements are: 1) if required is set - param must be present and not empty => or error is raised
|
40
|
+
# 2) if enum is set - param must equal predefined value => see Config::ValidateEnum
|
41
|
+
# 3) if ary_object => see Config::ValidateAryObject
|
42
|
+
# 3) if config.check_params_type is set - param must be of required type
|
43
|
+
#
|
44
|
+
# @accepted_params = [{}] - array with last member hash for nesting
|
45
|
+
# @params - current nesting level params
|
46
|
+
# @level_permitted_params - data for params permission
|
47
|
+
#
|
48
|
+
def loop_params(params, level_permitted_params, accepted_params)
|
49
|
+
level_permitted_params.each do |param_name, api_param_data|
|
50
|
+
controller_param = params[param_name]
|
51
|
+
|
52
|
+
_check_required(param_name, controller_param, api_param_data) # raise if required and no value
|
53
|
+
|
54
|
+
# no value present && not required => skip
|
55
|
+
next unless controller_param
|
56
|
+
|
57
|
+
# value present but not valid for this type => skip
|
58
|
+
next unless RailsApiDoc::Config::Validator.valid_param?(controller_param, api_param_data)
|
59
|
+
|
60
|
+
if api_param_data.ary_object? # controller_param value should be array of objects
|
61
|
+
controller_param.each do |single_controller_param|
|
62
|
+
_next_nesting_level(single_controller_param,
|
63
|
+
param_data: api_param_data.nested,
|
64
|
+
current_accepted_params: accepted_params,
|
65
|
+
param_name: param_name)
|
66
|
+
|
67
|
+
end
|
68
|
+
elsif api_param_data.nested? # value should be nested object
|
69
|
+
_next_nesting_level(controller_param,
|
70
|
+
param_data: api_param_data.nested,
|
71
|
+
current_accepted_params: accepted_params,
|
72
|
+
param_name: param_name)
|
73
|
+
|
74
|
+
else # all other options
|
75
|
+
accepted_params.unshift(param_name)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def _check_required(param_name, param_data, param_config)
|
81
|
+
return unless param_config.required? && param_data.blank?
|
82
|
+
raise RailsApiDoc::Exception::ParamRequired, param_name
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/rails_api_doc/engine.rb
CHANGED
@@ -4,18 +4,6 @@ require 'jquery-rails' # needed for require in javascript
|
|
4
4
|
|
5
5
|
require_relative 'railtie'
|
6
6
|
|
7
|
-
require_relative 'exception/param_required'
|
8
|
-
|
9
|
-
require_relative 'controller'
|
10
|
-
require_relative 'controller/strong_params'
|
11
|
-
require_relative 'controller/attribute_parser'
|
12
|
-
|
13
|
-
require_relative 'controller/parameter'
|
14
|
-
require_relative 'controller/parameter/repository'
|
15
|
-
require_relative 'controller/parameter/repository/param'
|
16
|
-
|
17
|
-
require_relative 'controller/response_factory'
|
18
|
-
|
19
7
|
# add rabl support
|
20
8
|
begin
|
21
9
|
require 'rabl'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# author: Vadim Shaveiko <@vshaveyko>
|
3
3
|
# :nodoc:
|
4
|
-
class RailsApiDoc::
|
4
|
+
class RailsApiDoc::Model::AttributeParser
|
5
5
|
|
6
6
|
# TODO : Change to I18n. Added on: 08.10.16. Added by: <@vshaveyko>
|
7
7
|
WRONG_NAME_ERROR_STRING = 'Name should consist only of letters\ciphers\underscores'
|
@@ -2,8 +2,11 @@ module RailsApiDoc
|
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer 'api_doc.controller_additions' do
|
4
4
|
ActiveSupport.on_load :action_controller do
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
include RailsApiDoc::Controller::ResourceParams::DSL
|
7
|
+
|
8
|
+
extend RailsApiDoc::Controller::Request::DSL
|
9
|
+
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/rails_api_doc.rb
CHANGED
@@ -1,9 +1,56 @@
|
|
1
1
|
# author: Vadim Shaveiko <@vshaveyko>
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require 'rails_api_doc/config'
|
4
3
|
|
5
4
|
module RailsApiDoc
|
6
5
|
|
6
|
+
module Controller
|
7
|
+
module Response
|
8
|
+
_dir = 'rails_api_doc/controller/response/'
|
9
|
+
|
10
|
+
autoload :Factory, _dir + 'factory'
|
11
|
+
autoload :Headers, _dir + 'headers'
|
12
|
+
autoload :Param, _dir + 'param'
|
13
|
+
end
|
14
|
+
|
15
|
+
module Request
|
16
|
+
_dir = 'rails_api_doc/controller/request/'
|
17
|
+
|
18
|
+
autoload :DSL, _dir + 'dsl'
|
19
|
+
autoload :Param, _dir + 'param'
|
20
|
+
autoload :Headers, _dir + 'headers'
|
21
|
+
autoload :Repository, _dir + 'repository'
|
22
|
+
end
|
23
|
+
|
24
|
+
module ResourceParams
|
25
|
+
_dir = 'rails_api_doc/controller/strong_params/'
|
26
|
+
|
27
|
+
autoload :DSL, _dir + 'dsl'
|
28
|
+
autoload :PermittedParams, _dir + 'permitted_params'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Model
|
33
|
+
_dir = 'rails_api_doc/model/'
|
34
|
+
|
35
|
+
autoload :AttributeParser, _dir + 'attribute_parser'
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'rails_api_doc/config'
|
39
|
+
class Config
|
40
|
+
_dir = 'rails_api_doc/config/'
|
41
|
+
|
42
|
+
autoload :Validator, _dir + 'validator'
|
43
|
+
autoload :ValidateEnum, _dir + 'validate_enum'
|
44
|
+
autoload :ValidateType, _dir + 'validate_type'
|
45
|
+
autoload :ValidateAryObject, _dir + 'validate_ary_object'
|
46
|
+
end
|
47
|
+
|
48
|
+
module Exception
|
49
|
+
_dir = 'rails_api_doc/exception/'
|
50
|
+
|
51
|
+
autoload :ParamRequired, _dir + 'param_required'
|
52
|
+
end
|
53
|
+
|
7
54
|
class << self
|
8
55
|
|
9
56
|
def configure
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,42 +139,44 @@ files:
|
|
139
139
|
- app/assets/javascripts/rails_api_doc/application.js
|
140
140
|
- app/assets/javascripts/table.js.coffee
|
141
141
|
- app/assets/stylesheets/rails_api_doc/application.css
|
142
|
+
- app/assets/stylesheets/rails_api_doc/default.sass
|
142
143
|
- app/assets/stylesheets/rails_api_doc/side_menu.sass
|
143
144
|
- app/assets/stylesheets/rails_api_doc/table.sass
|
144
145
|
- app/controllers/rails_api_doc/api_docs_controller.rb
|
145
146
|
- app/controllers/rails_api_doc/application_controller.rb
|
146
147
|
- app/helpers/rails_api_doc/application_helper.rb
|
148
|
+
- app/models/rails_api_doc/api_datum.rb
|
147
149
|
- app/models/rails_api_doc/application_record.rb
|
148
150
|
- app/views/layouts/rails_api_doc/application.slim
|
149
|
-
- app/views/rails_api_doc/api_docs/_edit_field.slim
|
150
151
|
- app/views/rails_api_doc/api_docs/_request_api_table.slim
|
151
152
|
- app/views/rails_api_doc/api_docs/_response_api_table.slim
|
152
|
-
- app/views/rails_api_doc/api_docs/_side_menu.slim
|
153
|
-
- app/views/rails_api_doc/api_docs/_title.slim
|
154
|
-
- app/views/rails_api_doc/api_docs/edit.js.erb
|
155
|
-
- app/views/rails_api_doc/api_docs/example.html.erb
|
156
153
|
- app/views/rails_api_doc/api_docs/index.slim
|
157
|
-
- app/views/
|
158
|
-
- app/views/shared/
|
154
|
+
- app/views/shared/_param_inputs.slim
|
155
|
+
- app/views/shared/_side_menu.slim
|
159
156
|
- app/views/shared/_table.slim
|
160
157
|
- config/routes.rb
|
158
|
+
- lib/generators/rails_api_doc/install_generator.rb
|
159
|
+
- lib/generators/rails_api_doc/templates/api_datum_migration.rb
|
161
160
|
- lib/rails_api_doc.rb
|
162
161
|
- lib/rails_api_doc/config.rb
|
163
162
|
- lib/rails_api_doc/config/validate_ary_object.rb
|
164
163
|
- lib/rails_api_doc/config/validate_enum.rb
|
165
164
|
- lib/rails_api_doc/config/validate_type.rb
|
166
165
|
- lib/rails_api_doc/config/validator.rb
|
167
|
-
- lib/rails_api_doc/controller.rb
|
168
|
-
- lib/rails_api_doc/controller/
|
169
|
-
- lib/rails_api_doc/controller/
|
170
|
-
- lib/rails_api_doc/controller/
|
171
|
-
- lib/rails_api_doc/controller/
|
166
|
+
- lib/rails_api_doc/controller/request/dsl.rb
|
167
|
+
- lib/rails_api_doc/controller/request/headers.rb
|
168
|
+
- lib/rails_api_doc/controller/request/param.rb
|
169
|
+
- lib/rails_api_doc/controller/request/repository.rb
|
170
|
+
- lib/rails_api_doc/controller/response/factory.rb
|
171
|
+
- lib/rails_api_doc/controller/response/headers.rb
|
172
|
+
- lib/rails_api_doc/controller/response/param.rb
|
172
173
|
- lib/rails_api_doc/controller/response/rabl.rb
|
173
174
|
- lib/rails_api_doc/controller/response/rabl_compiler.rb
|
174
|
-
- lib/rails_api_doc/controller/
|
175
|
-
- lib/rails_api_doc/controller/strong_params.rb
|
175
|
+
- lib/rails_api_doc/controller/strong_params/dsl.rb
|
176
|
+
- lib/rails_api_doc/controller/strong_params/permitted_params.rb
|
176
177
|
- lib/rails_api_doc/engine.rb
|
177
178
|
- lib/rails_api_doc/exception/param_required.rb
|
179
|
+
- lib/rails_api_doc/model/attribute_parser.rb
|
178
180
|
- lib/rails_api_doc/railtie.rb
|
179
181
|
- lib/rails_api_doc/version.rb
|
180
182
|
homepage: https://github.com/vshaveyko/rails_api_doc
|