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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d21488a0b91b4da968d909a9988b67cc7ea427
|
4
|
+
data.tar.gz: 72c1203f43307e203f499879d0739c0adf3fe237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad3a4d03dbb76aa738e0a7cc16fe832967d9db8b8b28fc14932398229ab6837bb3defb2d50fdea137a216b25d2ee62abe8f200ab7a9026ba2110ec67a6e32943
|
7
|
+
data.tar.gz: fdc0c2b103f36ea0443c62399b0f027aa760fd4ec25dd6733708baecb7f3a75cbc236f4abc0804e07851a66db8ac4096b17e49eac46bcf6e88028b0ffd7ce261
|
data/README.md
CHANGED
@@ -28,6 +28,10 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
To display api documentation on route '/api_doc' you need to:
|
30
30
|
|
31
|
+
0. config/application.rb ->
|
32
|
+
```ruby
|
33
|
+
require 'rails_api_doc'
|
34
|
+
```
|
31
35
|
1. config/routes.rb ->
|
32
36
|
```ruby
|
33
37
|
mount RailsApiDoc::Engine => '/api_doc'
|
@@ -55,6 +59,7 @@ To display api documentation on route '/api_doc' you need to:
|
|
55
59
|
|
56
60
|
end
|
57
61
|
```
|
62
|
+
3. go to localhost:3000/api_doc
|
58
63
|
|
59
64
|
## Strong params
|
60
65
|
|
@@ -6,7 +6,7 @@ _side_menu = null
|
|
6
6
|
$ ->
|
7
7
|
$('.next-is-nested').on 'click', (e) ->
|
8
8
|
self = $(this)
|
9
|
-
self.closest('.row').next().
|
9
|
+
self.closest('.row').next().toggleClass('is-shown')
|
10
10
|
|
11
11
|
$('.request-action-title').on 'click', (e) ->
|
12
12
|
self = $(this)
|
@@ -14,11 +14,16 @@ $ ->
|
|
14
14
|
return unless next.hasClass('flex-table')
|
15
15
|
next.toggle()
|
16
16
|
|
17
|
-
$('.
|
17
|
+
$('.flex-table input, .flex-table select').on 'click', (e) ->
|
18
|
+
e.stopPropagation()
|
19
|
+
|
20
|
+
$('.ico').on 'click', (e) ->
|
18
21
|
self = $(this)
|
22
|
+
e.preventDefault()
|
23
|
+
e.stopPropagation()
|
19
24
|
self.closest('.row').toggleClass('is-active')
|
20
25
|
|
21
|
-
_header_height = $('.aside').offset().top
|
26
|
+
# _header_height = $('.aside').offset().top
|
22
27
|
|
23
28
|
_window = $(window)
|
24
29
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@charset "UTF-8"
|
2
|
+
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300,400,700)
|
3
|
+
|
4
|
+
body
|
5
|
+
font-family: 'Open Sans', sans-serif
|
6
|
+
font-weight: 300
|
7
|
+
line-height: 1.42em
|
8
|
+
color: #A7A1AE
|
9
|
+
background-color: #1F2739
|
10
|
+
|
11
|
+
h1.header
|
12
|
+
font-size: 3em
|
13
|
+
font-weight: 300
|
14
|
+
line-height: 1em
|
15
|
+
text-align: center
|
16
|
+
color: #4DC3FA
|
17
|
+
|
18
|
+
.blue
|
19
|
+
color: #185875
|
20
|
+
|
21
|
+
.yellow
|
22
|
+
color: #FFF842
|
23
|
+
|
24
|
+
.content
|
25
|
+
display: flex
|
26
|
+
|
27
|
+
nav
|
28
|
+
flex: 1
|
29
|
+
|
30
|
+
.tables
|
31
|
+
flex: 5
|
@@ -1,30 +1,19 @@
|
|
1
|
-
|
1
|
+
ul
|
2
2
|
list-style-type: none
|
3
3
|
padding: 0
|
4
|
-
font-size: 15px
|
5
4
|
|
6
|
-
|
7
|
-
margin-bottom: 3px
|
5
|
+
.side-menu
|
8
6
|
|
9
|
-
|
10
|
-
margin: 0 2px
|
7
|
+
// position: static
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
font-size: 15px
|
16
|
-
font-weight: 500
|
17
|
-
color: #767676
|
18
|
-
text-decoration: none
|
9
|
+
&.fixed
|
10
|
+
position: fixed
|
11
|
+
top: 0
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
a
|
14
|
+
text-decoration: none
|
15
|
+
border-bottom: 1px solid transparent
|
16
|
+
transition: border-color ease-in-out 0.3s
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
font-weight: 700
|
28
|
-
color: #563d7c
|
29
|
-
background-color: transparent
|
30
|
-
border-left: 2px solid #563d7c
|
18
|
+
&:hover
|
19
|
+
border-color: yellow
|
@@ -2,36 +2,65 @@
|
|
2
2
|
--row-count: 5
|
3
3
|
|
4
4
|
.flex-table
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
padding: 5px
|
11
|
-
box-sizing: border-box
|
12
|
-
background: lightblue
|
13
|
-
|
14
|
-
// border: 1px solid black
|
5
|
+
overflow: hidden
|
6
|
+
width: 100%
|
7
|
+
margin: 0
|
8
|
+
display: table
|
9
|
+
padding: 0 0 0 0
|
15
10
|
|
16
11
|
& &
|
17
|
-
|
12
|
+
visibility: hidden
|
13
|
+
position: absolute
|
14
|
+
opacity: 0
|
15
|
+
|
18
16
|
width: 100%
|
19
|
-
background:
|
17
|
+
background: #185875
|
20
18
|
padding: 20px
|
21
19
|
box-sizing: border-box
|
22
20
|
|
23
21
|
& .flex-table
|
24
22
|
padding-right: 0
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
&.is-shown
|
25
|
+
opacity: 1
|
26
|
+
position: relative
|
27
|
+
visibility: visible
|
28
|
+
transition: visibility 0s, opacity 0.5s linear
|
29
|
+
|
30
|
+
.row
|
31
|
+
font-weight: normal
|
32
|
+
font-size: 0.9em
|
33
|
+
-webkit-box-shadow: 0 2px 2px -2px #0E1119
|
34
|
+
-moz-box-shadow: 0 2px 2px -2px #0E1119
|
35
|
+
box-shadow: 0 2px 2px -2px #0E1119
|
36
|
+
|
37
|
+
input, select, [type="submit"], .exit
|
38
|
+
display: none
|
39
|
+
|
40
|
+
// input, select
|
41
|
+
font-weight: 600
|
42
|
+
color: #fff
|
43
|
+
background-color: black
|
44
|
+
border: 1px solid rgba(0,0,0,0.3)
|
45
|
+
border-radius: 4px
|
46
|
+
box-shadow: inset 0 -5px 45px
|
47
|
+
|
48
|
+
|
49
|
+
.ico
|
50
|
+
cursor: pointer
|
51
|
+
font-size: 20px
|
52
|
+
padding: 1% 2%
|
53
|
+
position: absolute
|
54
|
+
left: 2%
|
55
|
+
|
56
|
+
&:hover
|
57
|
+
background-color: #FFF842
|
58
|
+
color: #403E10
|
59
|
+
|
60
|
+
transition-delay: 0s
|
61
|
+
transition-duration: 0.4s
|
62
|
+
transition-property: all
|
63
|
+
transition-timing-function: line
|
35
64
|
|
36
65
|
.flex-line
|
37
66
|
|
@@ -41,51 +70,49 @@
|
|
41
70
|
border-bottom: 1px solid black
|
42
71
|
|
43
72
|
&:first-child
|
44
|
-
|
73
|
+
color: #FB667A
|
45
74
|
|
46
75
|
background: lightgreen
|
47
76
|
|
48
|
-
// Зачем это ?
|
49
|
-
// display: -webkit-box
|
50
|
-
// display: -moz-box
|
51
|
-
// display: -ms-flexbox
|
52
|
-
// display: -webkit-flex
|
53
|
-
//
|
54
77
|
&.row
|
55
78
|
display: flex
|
56
79
|
|
57
|
-
|
80
|
+
&:hover
|
81
|
+
background-color: #464A52
|
58
82
|
|
59
|
-
|
60
|
-
|
83
|
+
h1
|
84
|
+
margin: 0
|
85
|
+
text-align: center
|
86
|
+
font-weight: bold
|
87
|
+
background-color: #1F2739
|
88
|
+
font-size: 1em
|
61
89
|
|
62
|
-
|
63
|
-
|
64
|
-
// flex-flow: row wrap
|
65
|
-
// justify-content: space-between
|
90
|
+
&:nth-child(odd)
|
91
|
+
background-color: #323C50
|
66
92
|
|
67
|
-
|
68
|
-
|
69
|
-
// ничего не сделало
|
70
|
-
// flex-wrap: nowrap
|
93
|
+
&:nth-child(even)
|
94
|
+
background-color: #2C3446
|
71
95
|
|
72
|
-
|
96
|
+
&.is-active
|
97
|
+
|
98
|
+
input, select, [type="submit"], .exit
|
99
|
+
display: inline-block
|
100
|
+
|
101
|
+
.title, .ico:not(.exit)
|
102
|
+
display: none
|
73
103
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
// align-items: stretch
|
104
|
+
&.column
|
105
|
+
flex: 1
|
106
|
+
flex-flow: column wrap
|
107
|
+
align-content: flex-start
|
79
108
|
|
80
109
|
.flex-item
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
background: tomato
|
86
|
-
padding: 5px
|
110
|
+
padding-bottom: 1%
|
111
|
+
padding-top: 1%
|
112
|
+
position: relative
|
113
|
+
padding-left: 2%
|
87
114
|
|
88
|
-
|
115
|
+
border-right: 2px solid #1F2739
|
89
116
|
text-align: center
|
90
117
|
|
91
118
|
.row &
|
@@ -95,45 +122,38 @@
|
|
95
122
|
&.mod-submit
|
96
123
|
display: none
|
97
124
|
|
98
|
-
input
|
99
|
-
display: none
|
100
|
-
|
101
|
-
// Что я сделал ?? - оно почемуто заработало было flex-grow: 1
|
102
|
-
// В статье написано что это тоже самое, а на практике - не так ?
|
103
|
-
// flex: 1
|
104
|
-
// TODO: need function that will count % from num childs?
|
105
|
-
// магические отступы ))
|
106
|
-
// width: 23%
|
107
|
-
|
108
|
-
// line-height: 150px
|
109
|
-
// color: white
|
110
|
-
// font-weight: bold
|
111
|
-
// font-size: 3em
|
112
|
-
// text-align: center
|
113
|
-
|
114
125
|
.column &
|
115
126
|
width: 100%
|
116
127
|
|
117
|
-
.
|
118
|
-
text-align: center
|
128
|
+
div.flex-item
|
119
129
|
|
120
|
-
|
121
|
-
|
130
|
+
&:hover
|
131
|
+
background-color: #FFF842
|
132
|
+
color: #403E10
|
122
133
|
|
123
|
-
|
124
|
-
|
134
|
+
transition-delay: 0s
|
135
|
+
transition-duration: 0.4s
|
136
|
+
transition-property: all
|
137
|
+
transition-timing-function: line
|
125
138
|
|
126
|
-
|
127
|
-
|
139
|
+
&.next-is-nested
|
140
|
+
cursor: pointer
|
141
|
+
&:hover
|
142
|
+
box-shadow: #7F7C21 -1px 1px, #7F7C21 -2px 2px, #7F7C21 -3px 3px, #7F7C21 -4px 4px, #7F7C21 -5px 5px, #7F7C21 -6px 6px
|
143
|
+
transform: translate3d(6px, -6px, 0)
|
128
144
|
|
129
|
-
|
130
|
-
position: static
|
145
|
+
.response-table
|
131
146
|
|
132
|
-
|
133
|
-
|
134
|
-
top: 0
|
147
|
+
.request-action-title
|
148
|
+
text-align: center
|
135
149
|
|
136
|
-
|
137
|
-
|
150
|
+
&:nth-child(odd)
|
151
|
+
background-color: #323C50
|
152
|
+
|
153
|
+
&:nth-child(even)
|
154
|
+
background-color: #2C3446
|
138
155
|
|
139
|
-
|
156
|
+
p.title
|
157
|
+
text-align: center
|
158
|
+
color: #4DC3FA
|
159
|
+
font-weight: 500
|
@@ -10,42 +10,43 @@ class RailsApiDoc::ApiDocsController < RailsApiDoc::ApplicationController
|
|
10
10
|
# preload controllers for parameters to apply
|
11
11
|
Dir.glob("#{Rails.root}/app/controllers/**/*.rb").each { |file| require_dependency file }
|
12
12
|
|
13
|
-
@
|
14
|
-
types: RailsApiDoc::Controller::Parameter::Repository::Param::ACCEPTED_TYPES.map(&:to_s)
|
15
|
-
}
|
13
|
+
@request_repository = RailsApiDoc::Controller::Request::Repository
|
16
14
|
|
17
|
-
@
|
15
|
+
@registered_controllers = @request_repository.registered_controllers
|
18
16
|
|
19
|
-
@response_repository = RailsApiDoc::Controller::Response.repo
|
17
|
+
@response_repository = RailsApiDoc::Controller::Response::Factory.repo
|
20
18
|
end
|
21
19
|
|
22
20
|
def create
|
23
21
|
attributes = RailsApiDoc::Controller::AttributeParser.parse_attributes(permitted_params)
|
24
|
-
end
|
25
22
|
|
26
|
-
|
27
|
-
pry binding
|
23
|
+
RailsApiDoc::ApiDatum.create!(attributes)
|
28
24
|
end
|
29
25
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
pry binding
|
34
|
-
end
|
26
|
+
def destroy
|
27
|
+
attributes = RailsApiDoc::Controller::AttributeParser.parse_attributes(permitted_params)
|
35
28
|
|
36
|
-
|
37
|
-
|
38
|
-
|
29
|
+
if params[:id]
|
30
|
+
RailsApiDoc::ApiDatum.find(params[:id]).update!(attributes)
|
31
|
+
else
|
32
|
+
RailsApiDoc::ApiDatum.create!(attributes)
|
33
|
+
end
|
39
34
|
end
|
40
35
|
|
41
36
|
def update
|
42
|
-
|
37
|
+
attributes = RailsApiDoc::Controller::AttributeParser.parse_attributes(permitted_params)
|
38
|
+
|
39
|
+
if params[:id]
|
40
|
+
RailsApiDoc::ApiDatum.find(params[:id]).update!(attributes)
|
41
|
+
else
|
42
|
+
RailsApiDoc::ApiDatum.create!(attributes)
|
43
|
+
end
|
43
44
|
end
|
44
45
|
|
45
46
|
private
|
46
47
|
|
47
48
|
def permitted_params
|
48
|
-
params.permit
|
49
|
+
params.permit(:name, :type, :special, :desc)
|
49
50
|
end
|
50
51
|
|
51
52
|
end
|
@@ -9,12 +9,13 @@ html lang="en"
|
|
9
9
|
== stylesheet_link_tag "rails_api_doc/application", :media => "all"
|
10
10
|
== javascript_include_tag "api_doc"
|
11
11
|
== csrf_meta_tags
|
12
|
-
body
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
body.wrap
|
13
|
+
|
14
|
+
h1.header
|
15
|
+
span.blue <
|
16
|
+
span Rails
|
17
|
+
span.blue >
|
18
|
+
span
|
19
|
+
a.yellow[style="text-decoration: none" href="http://github.com/vshaveyko/rails_api_doc"] Api Documentation
|
20
|
+
|
21
|
+
== yield
|
@@ -1,4 +1,5 @@
|
|
1
|
-
-
|
1
|
+
- request_headers = repo.headers
|
2
2
|
|
3
|
-
div[id="#{
|
4
|
-
|
3
|
+
div[id="#{ctrl}.request" style="--row-count: #{request_headers.length}"]
|
4
|
+
|
5
|
+
= render 'shared/table', model: ctrl, rows: repo[ctrl], headers: request_headers, nesting: [], type: :request
|
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
- response_headers = repo.headers
|
2
|
+
|
3
|
+
div.response-table[id="#{ctrl}.response" style="--row-count: #{response_headers.length}"]
|
4
|
+
|
5
|
+
- repo.map[ctrl][:actions].each do |action|
|
3
6
|
// TODO: Nest table in this div for easier jq toggling
|
4
7
|
// add borders to this div
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
|
9
|
+
- if route = repo.action_route(ctrl, action)
|
10
|
+
|
11
|
+
div.request-action-title = route
|
12
|
+
|
13
|
+
- if rows = repo.load_template(ctrl, action)
|
14
|
+
|
15
|
+
= render 'shared/table', model: ctrl, rows: rows, headers: response_headers, nesting: [], type: :response
|
@@ -1,27 +1,22 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
= render 'title'
|
4
|
-
.content
|
5
|
-
div.aside
|
6
|
-
div#side-menu
|
7
|
-
= render 'side_menu', locals: { models: @request_repository.keys }
|
1
|
+
div.content
|
2
|
+
= render 'shared/side_menu', ctrls: @registered_controllers
|
8
3
|
|
9
|
-
|
4
|
+
div.tables
|
10
5
|
|
11
|
-
|
6
|
+
- @registered_controllers.each do |ctrl|
|
12
7
|
|
13
|
-
|
8
|
+
div[id=(ctrl.to_s)]
|
14
9
|
|
15
|
-
|
10
|
+
h2 = ctrl.to_s
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
p.title
|
13
|
+
| Scopes
|
14
|
+
| #{ctrl.scopes_configuration.keys.map { |key| ":#{key}"}.join(', ')}
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
p.title
|
17
|
+
| Request
|
18
|
+
= render 'request_api_table', ctrl: ctrl, repo: @request_repository
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
p.title
|
21
|
+
| Response
|
22
|
+
= render 'response_api_table', ctrl: ctrl, repo: @response_repository
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- value = try(:value)
|
2
|
+
- placeholder = settings[:placeholder] || ''
|
3
|
+
|
4
|
+
- case settings[:fill_type]
|
5
|
+
- when :input
|
6
|
+
= text_field_tag settings[:param], nil, placeholder: placeholder
|
7
|
+
- when :select
|
8
|
+
= select_tag settings[:param], options_for_select(settings[:values], value)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
nav.bs-docs-sidebar.hidden-print.hidden-sm.hidden-xs
|
2
|
+
ul.side-menu.nav.bs-docs-sidenav
|
3
|
+
- ctrls.each do |ctrl|
|
4
|
+
li.yellow
|
5
|
+
a.yellow[href=('#' + ctrl.to_s)] = ctrl.to_s
|
6
|
+
span = '('
|
7
|
+
a.yellow[href=('#' + ctrl.to_s + '.request')] req,
|
8
|
+
a.yellow[href=('#' + ctrl.to_s + '.response')] resp
|
9
|
+
span = ')'
|
@@ -1,20 +1,40 @@
|
|
1
|
-
- nesting =
|
1
|
+
- nesting = nesting + [model] # do not mutate nesting value
|
2
2
|
|
3
3
|
div.flex-table
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
|
5
|
+
/ header row
|
6
|
+
= form_tag(api_doc_url(nesting: nesting, api_type: type), method: :post, remote: true, class: 'flex-line row') do
|
7
|
+
|
8
|
+
- headers.each.with_index do |(header, settings), index|
|
9
|
+
h1.flex-item
|
10
|
+
- if index.zero?
|
11
|
+
span.add.ico +
|
12
|
+
span.exit.ico ❌
|
13
|
+
= submit_tag '✓'
|
14
|
+
|
15
|
+
= render 'shared/param_inputs', settings: settings
|
16
|
+
|
17
|
+
span.title = header
|
18
|
+
|
19
|
+
- rows.each do |row_name, row_values|
|
20
|
+
|
21
|
+
= form_tag(api_doc_url(nesting: nesting, api_type: type), method: :put, remote: true, class: 'flex-line row') do
|
22
|
+
|
23
|
+
- headers.each_value.with_index do |(header_settings), index|
|
24
|
+
|
25
|
+
- param_value = header_settings[:value].call(row_name, row_values)
|
26
|
+
|
27
|
+
div.flex-item[class="#{'next-is-nested' if row_values.nested?}"]
|
28
|
+
|
29
|
+
- if index.zero?
|
30
|
+
span.ico ✏
|
31
|
+
span.exit.ico ❌
|
32
|
+
= submit_tag '✔'
|
33
|
+
|
34
|
+
= render 'shared/param_inputs', settings: header_settings, value: param_value
|
35
|
+
|
36
|
+
span.title = param_value
|
37
|
+
|
19
38
|
- if row_values.nested?
|
20
|
-
|
39
|
+
|
40
|
+
= render 'shared/table', nesting: nesting, model: row_values[:model] || row_name, rows: row_values.nested, headers: headers, type: type
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module RailsApiDoc
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
desc "add the migrations"
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_migrations
|
15
|
+
filename = 'generate_rails_api_documentation_attributes_table'
|
16
|
+
if self.class.migration_exists?('db/migrate', "#{filename}")
|
17
|
+
say_status('skipped', "Migration #{filename}.rb already exists")
|
18
|
+
else
|
19
|
+
migration_template "api_datum_migration.rb", "db/migrate/#{filename}.rb"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class GenerateRailsApiDocumentationAttributesTable < ActiveRecord::Migration[5.0]
|
2
|
+
|
3
|
+
def change
|
4
|
+
create_table :rails_api_doc_api_data do |t|
|
5
|
+
t.string :api_type
|
6
|
+
t.string :type
|
7
|
+
t.string :name
|
8
|
+
t.string :special
|
9
|
+
t.string :desc
|
10
|
+
|
11
|
+
t.text :nesting
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|