apipony 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/app/assets/stylesheets/apipony/styles.scss +62 -1
- data/app/views/apipony/application/index.html.haml +74 -50
- data/app/views/layouts/apipony/application.html.haml +2 -2
- data/lib/apipony.rb +1 -0
- data/lib/apipony/parameter.rb +10 -0
- data/lib/apipony/request.rb +6 -0
- data/lib/apipony/version.rb +1 -1
- data/lib/generators/apipony/install/templates/initializer.rb +9 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86b81077625eb78efec26c41c96c30e832ef5c02
|
4
|
+
data.tar.gz: d05befea092568084df3b920dfbc5ed4ea64f17d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fe9cdb7e1cfea04e9d4bac98aee904753b87750048da48fc4c37c826b9232bf709c17d1ed58f9c5c146b50f22915abc3cb91e054d85bd2c0c220d4c354c522c
|
7
|
+
data.tar.gz: 2b756e4a6ec30fe410c96d8fa6d609dac9d73284b8c7f7b3bb594427d178873c97c857ce60a6d022d5ed629d6bea18aba6527a03f37d7b379b1a5961e6fbc698
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
$dark_color: #111;
|
2
2
|
$medium_color: #888;
|
3
3
|
$light_color: #eee;
|
4
|
+
$brand_color: #5E147D;
|
5
|
+
|
6
|
+
@import url(https://fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic);
|
4
7
|
|
5
8
|
* {
|
6
9
|
margin: 0;
|
@@ -66,7 +69,6 @@ ul {
|
|
66
69
|
.container {
|
67
70
|
width: 940px;
|
68
71
|
margin: 0 auto;
|
69
|
-
padding: 40px 0;
|
70
72
|
position: relative;
|
71
73
|
}
|
72
74
|
|
@@ -90,6 +92,39 @@ ul {
|
|
90
92
|
}
|
91
93
|
}
|
92
94
|
|
95
|
+
header {
|
96
|
+
background: $brand_color;
|
97
|
+
height: 60px;
|
98
|
+
line-height: 60px;
|
99
|
+
.title {
|
100
|
+
font-family: 'Cuprum';
|
101
|
+
font-weight: bold;
|
102
|
+
font-size: 20px;
|
103
|
+
color: #fff;
|
104
|
+
}
|
105
|
+
.back {
|
106
|
+
float: right;
|
107
|
+
color: #fff;
|
108
|
+
opacity: .7;
|
109
|
+
font-size: 12px;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
main {
|
114
|
+
padding: 40px 0;
|
115
|
+
}
|
116
|
+
|
117
|
+
footer {
|
118
|
+
height: 60px;
|
119
|
+
line-height: 60px;
|
120
|
+
border-top: 1px solid $light_color;
|
121
|
+
text-align: right;
|
122
|
+
font-size: 12px;
|
123
|
+
a {
|
124
|
+
color: $medium_color;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
93
128
|
.section {
|
94
129
|
&:not(:last-child) {
|
95
130
|
padding-bottom: 40px;
|
@@ -152,3 +187,29 @@ ul {
|
|
152
187
|
background: #C0392B;
|
153
188
|
}
|
154
189
|
}
|
190
|
+
|
191
|
+
.param {
|
192
|
+
.name {
|
193
|
+
color: $brand_color;
|
194
|
+
font-weight: bold;
|
195
|
+
}
|
196
|
+
.type {
|
197
|
+
color: $medium_color;
|
198
|
+
font-style: italic;
|
199
|
+
}
|
200
|
+
.required {
|
201
|
+
text-align: center;
|
202
|
+
.fa {
|
203
|
+
color: $medium_color;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
.table {
|
209
|
+
padding: 8px 0;
|
210
|
+
tr {
|
211
|
+
td {
|
212
|
+
padding: 2px 10px;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
@@ -1,50 +1,74 @@
|
|
1
|
-
|
2
|
-
.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
%header
|
2
|
+
.container
|
3
|
+
= link_to @documentation.title, root_path, class: 'title'
|
4
|
+
- if main_app.root_path
|
5
|
+
= link_to 'Back to site', main_app.root_path, class: 'back'
|
6
|
+
%main
|
7
|
+
.container
|
8
|
+
.row
|
9
|
+
.col-3
|
10
|
+
- @documentation.sections.each do |section|
|
11
|
+
%h4= section.title
|
12
|
+
%ul
|
13
|
+
- section.endpoints.each do |endpoint|
|
14
|
+
%li
|
15
|
+
%h5
|
16
|
+
= link_to root_path(:anchor => endpoint.id) do
|
17
|
+
%span.method{ :class => endpoint.method }<
|
18
|
+
= endpoint.method
|
19
|
+
= endpoint.url
|
20
|
+
.col-9
|
21
|
+
- @documentation.sections.each do |section|
|
22
|
+
.section
|
23
|
+
%h2= section.title
|
24
|
+
- section.endpoints.each do |endpoint|
|
25
|
+
.endpoint{ :id => endpoint.id }
|
26
|
+
%h3
|
27
|
+
%span.method{ :class => endpoint.method }<
|
28
|
+
= endpoint.method
|
29
|
+
= endpoint.url
|
30
|
+
- if endpoint.description
|
31
|
+
.description= endpoint.description
|
32
|
+
- if endpoint.request || endpoint.response
|
33
|
+
- if endpoint.request
|
34
|
+
.request
|
35
|
+
%h4 Request:
|
36
|
+
- if endpoint.request.params
|
37
|
+
.panel
|
38
|
+
.title Parameters
|
39
|
+
%table.table
|
40
|
+
- endpoint.request.params.each do |param|
|
41
|
+
%tr.param
|
42
|
+
%td.name
|
43
|
+
= param.name
|
44
|
+
%td.type
|
45
|
+
= param.type
|
46
|
+
%td.required
|
47
|
+
- if param.required
|
48
|
+
%i.fa.fa-check-square-o{ :title => 'Required' }
|
49
|
+
- else
|
50
|
+
%i.fa.fa-square-o{ :title => 'Optional' }
|
51
|
+
%td.example
|
52
|
+
= param.example
|
53
|
+
- if endpoint.request.headers
|
54
|
+
.panel
|
55
|
+
.title Headers
|
56
|
+
%pre.code= JSON.pretty_generate(endpoint.request.headers)
|
57
|
+
- if endpoint.response
|
58
|
+
.response
|
59
|
+
%h4
|
60
|
+
Response:
|
61
|
+
= endpoint.response.status
|
62
|
+
- if endpoint.response.body
|
63
|
+
.panel
|
64
|
+
.title Body
|
65
|
+
%pre.code= JSON.pretty_generate(endpoint.response.body)
|
66
|
+
- if endpoint.response.headers
|
67
|
+
.panel
|
68
|
+
.title Headers
|
69
|
+
%pre.code= JSON.pretty_generate(endpoint.response.headers)
|
70
|
+
%footer
|
71
|
+
.container
|
72
|
+
= link_to 'https://github.com/droptheplot/apipony' do
|
73
|
+
%i.fa.fa-github
|
74
|
+
Apipony
|
@@ -3,10 +3,10 @@
|
|
3
3
|
%head
|
4
4
|
%title Apipony
|
5
5
|
%link{ :href => '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/styles/github.min.css', :rel => 'stylesheet' }/
|
6
|
+
%link{ :href => 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', :rel => 'stylesheet' }/
|
6
7
|
= stylesheet_link_tag 'apipony/application', media: 'all'
|
7
8
|
%script{ :src => '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js' }
|
8
9
|
= javascript_include_tag 'apipony/application'
|
9
10
|
= csrf_meta_tags
|
10
11
|
%body
|
11
|
-
|
12
|
-
= yield
|
12
|
+
= yield
|
data/lib/apipony.rb
CHANGED
data/lib/apipony/request.rb
CHANGED
@@ -2,6 +2,12 @@ class Apipony::Request < Apipony::Base
|
|
2
2
|
attr_accessor :params, :headers
|
3
3
|
|
4
4
|
def initialize(&block)
|
5
|
+
@params = []
|
6
|
+
|
5
7
|
instance_eval(&block)
|
6
8
|
end
|
9
|
+
|
10
|
+
def param(name, example: '', type: :string, required: false)
|
11
|
+
@params << Apipony::Parameter.new(name, example, type, required)
|
12
|
+
end
|
7
13
|
end
|
data/lib/apipony/version.rb
CHANGED
@@ -9,9 +9,7 @@ Apipony::Documentation.define do
|
|
9
9
|
e.description = 'Find ponies'
|
10
10
|
|
11
11
|
request_with do
|
12
|
-
|
13
|
-
:name => :applejack
|
14
|
-
}
|
12
|
+
param :name, example: :applejack, required: true
|
15
13
|
end
|
16
14
|
|
17
15
|
response_with 200 do
|
@@ -28,12 +26,10 @@ Apipony::Documentation.define do
|
|
28
26
|
e.description = 'Create pony'
|
29
27
|
|
30
28
|
request_with do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
:occupation => :caretaker
|
36
|
-
}
|
29
|
+
param :name, example: :fluttershy
|
30
|
+
param :kind, example: :pegasus
|
31
|
+
param :sex, example: :female
|
32
|
+
param :occupation, example: :caretaker
|
37
33
|
end
|
38
34
|
|
39
35
|
response_with 200
|
@@ -43,12 +39,10 @@ Apipony::Documentation.define do
|
|
43
39
|
e.description = 'Update pony id'
|
44
40
|
|
45
41
|
request_with do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:occupation => :singer
|
51
|
-
}
|
42
|
+
param :name
|
43
|
+
param :kind
|
44
|
+
param :sex
|
45
|
+
param :occupation
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/apipony/documentation.rb
|
185
185
|
- lib/apipony/endpoint.rb
|
186
186
|
- lib/apipony/engine.rb
|
187
|
+
- lib/apipony/parameter.rb
|
187
188
|
- lib/apipony/request.rb
|
188
189
|
- lib/apipony/response.rb
|
189
190
|
- lib/apipony/section.rb
|