try_api 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/try_api/application.js.coffee +2 -2
- data/app/assets/stylesheets/try_api/application.css.sass +41 -21
- data/app/models/try_api/example_response.rb +16 -2
- data/app/models/try_api/method.rb +1 -1
- data/app/models/try_api/project.rb +2 -0
- data/app/views/layouts/try_api/application.html.erb +1 -0
- data/app/views/try_api/pages/index.html +5 -4
- data/lib/generators/try_api/templates/config/try_api.yml +9 -16
- data/lib/try_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14627511634ee5fad98223da11b1720cb558bf5b
|
4
|
+
data.tar.gz: 403b9964183f5e69fb51b3b18e196a443a42d777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42358fedce57083f07b1efa2bd95026369a6d0f41389c114b00106b922ffe328e2c92ebc76a96c7343e1a40b73043f5195279df2e46943bef66d29fdf81bcf8a
|
7
|
+
data.tar.gz: 2b4126286f8370ee76144b6adf5de294bb3486c218843f56bef827b2a60b6c1748990cdacb6be6ab83b29e706ca429280f0522aed3989ff94235b40a5ae85fc4
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#= require try_api/bower_components/bootstrap/dist/js/bootstrap.min.js
|
2
1
|
#= require try_api/bower_components/highlightjs/highlight.pack.min.js
|
2
|
+
#= require try_api/bower_components/angular-bootstrap/ui-bootstrap.js
|
3
3
|
#= require try_api/bower_components/angular-bootstrap/ui-bootstrap-tpls.js
|
4
4
|
#= require try_api/bower_components/angular-highlightjs/angular-highlightjs.min.js
|
5
5
|
#= require try_api/bower_components/ladda/dist/spin.min.js
|
@@ -33,8 +33,8 @@ $ ->
|
|
33
33
|
|
34
34
|
TryApiApp = angular.module('TryApiApp', [
|
35
35
|
'ui.bootstrap'
|
36
|
+
'ngAnimate'
|
36
37
|
'formInput.image'
|
37
|
-
# 'formInput.file'
|
38
38
|
'angular-ladda'
|
39
39
|
'param'
|
40
40
|
'params'
|
@@ -4,6 +4,7 @@
|
|
4
4
|
//= require try_api/bower_components/ladda/dist/ladda.min.css
|
5
5
|
//= require try_api/bower_components/ladda/dist/ladda-themeless.min.css
|
6
6
|
//= require try_api/bower_components/components-font-awesome/css/font-awesome.css
|
7
|
+
//= require try_api/bower_components/angular-bootstrap/ui-bootstrap-csp.css
|
7
8
|
|
8
9
|
body
|
9
10
|
margin: 0
|
@@ -20,28 +21,26 @@ body
|
|
20
21
|
button
|
21
22
|
outline: none !important
|
22
23
|
|
23
|
-
code
|
24
|
-
margin: 6px 0
|
25
|
-
|
26
24
|
.row.is-flex
|
27
|
-
|
28
|
-
display: -webkit-flex
|
29
|
-
display: -ms-flexbox
|
30
|
-
display: flex
|
31
|
-
-webkit-flex-wrap: wrap
|
32
|
-
-ms-flex-wrap: wrap
|
33
|
-
flex-wrap: wrap
|
34
|
-
|
35
|
-
& > [class*='col-']
|
25
|
+
@media (min-width: 1000px)
|
36
26
|
display: -webkit-box
|
37
27
|
display: -webkit-flex
|
38
28
|
display: -ms-flexbox
|
39
29
|
display: flex
|
40
|
-
-webkit-
|
41
|
-
-
|
42
|
-
|
43
|
-
|
44
|
-
|
30
|
+
-webkit-flex-wrap: wrap
|
31
|
+
-ms-flex-wrap: wrap
|
32
|
+
flex-wrap: wrap
|
33
|
+
|
34
|
+
& > [class*='col-']
|
35
|
+
display: -webkit-box
|
36
|
+
display: -webkit-flex
|
37
|
+
display: -ms-flexbox
|
38
|
+
display: flex
|
39
|
+
-webkit-box-orient: vertical
|
40
|
+
-webkit-box-direction: normal
|
41
|
+
-webkit-flex-direction: column
|
42
|
+
-ms-flex-direction: column
|
43
|
+
flex-direction: column
|
45
44
|
|
46
45
|
.try-api
|
47
46
|
&-sidebar
|
@@ -124,7 +123,7 @@ body
|
|
124
123
|
padding: 10px 15px
|
125
124
|
&-code, code
|
126
125
|
color: #b1bdc4
|
127
|
-
margin:
|
126
|
+
margin: 0
|
128
127
|
padding: 20px 40px
|
129
128
|
background: #272b2d
|
130
129
|
border-radius: 5px
|
@@ -136,6 +135,30 @@ body
|
|
136
135
|
font-size: 16px
|
137
136
|
text-transform: uppercase
|
138
137
|
|
138
|
+
&-response
|
139
|
+
margin: 2px 0
|
140
|
+
&-header
|
141
|
+
background-color: #272b2d
|
142
|
+
padding: 3px
|
143
|
+
cursor: pointer
|
144
|
+
border-top-right-radius: 5px
|
145
|
+
border-top-left-radius: 5px
|
146
|
+
position: relative
|
147
|
+
i.fa
|
148
|
+
position: absolute
|
149
|
+
top: 7px
|
150
|
+
right: 5px
|
151
|
+
.label
|
152
|
+
padding: .2em 0.6em 0.16em 0.9em
|
153
|
+
&.collapsed
|
154
|
+
border-bottom-right-radius: 5px
|
155
|
+
border-bottom-left-radius: 5px
|
156
|
+
|
157
|
+
&-body
|
158
|
+
code
|
159
|
+
border-top-left-radius: 0
|
160
|
+
border-top-right-radius: 0
|
161
|
+
|
139
162
|
.error-page
|
140
163
|
margin: auto
|
141
164
|
position: absolute
|
@@ -287,6 +310,3 @@ body
|
|
287
310
|
width: 15px
|
288
311
|
height: 15px
|
289
312
|
cursor: pointer
|
290
|
-
|
291
|
-
|
292
|
-
|
@@ -3,12 +3,14 @@ module TryApi
|
|
3
3
|
typesafe_accessor :code, Integer
|
4
4
|
typesafe_accessor :response, String
|
5
5
|
typesafe_accessor :type, String
|
6
|
+
typesafe_accessor :project, TryApi::Project
|
6
7
|
|
7
8
|
class << self
|
8
|
-
def parse(hash)
|
9
|
+
def parse(hash:, project:)
|
9
10
|
return nil if hash.blank?
|
10
11
|
instance = self.new
|
11
12
|
instance.code = hash[:code]
|
13
|
+
instance.project = project
|
12
14
|
instance.response = hash[:response]
|
13
15
|
instance.type = hash[:type]
|
14
16
|
instance
|
@@ -25,7 +27,7 @@ module TryApi
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def description
|
28
|
-
self.class.descriptions[self.code]
|
30
|
+
self.class.descriptions[self.code].to_s.humanize
|
29
31
|
end
|
30
32
|
|
31
33
|
def color
|
@@ -44,5 +46,17 @@ module TryApi
|
|
44
46
|
'default'
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
def to_json
|
51
|
+
super.merge color: color, description: description, isCollapsed: true
|
52
|
+
end
|
53
|
+
|
54
|
+
def response=(input)
|
55
|
+
if input['var:']
|
56
|
+
@response = self.project.variables[input.gsub('var:', '')]
|
57
|
+
else
|
58
|
+
@response = input
|
59
|
+
end
|
60
|
+
end
|
47
61
|
end
|
48
62
|
end
|
@@ -24,7 +24,7 @@ module TryApi
|
|
24
24
|
instance.example_responses = []
|
25
25
|
if hash[:example_responses].is_a? Array
|
26
26
|
hash[:example_responses].each do |example|
|
27
|
-
instance.example_responses << TryApi::ExampleResponse.parse(example)
|
27
|
+
instance.example_responses << TryApi::ExampleResponse.parse(hash: example, project: project)
|
28
28
|
end
|
29
29
|
else
|
30
30
|
# TODO raise exception ?
|
@@ -5,6 +5,7 @@ module TryApi
|
|
5
5
|
typesafe_accessor :host, String
|
6
6
|
typesafe_accessor :port, Integer
|
7
7
|
typesafe_accessor :api_prefix, String
|
8
|
+
typesafe_accessor :variables, Hash, {}
|
8
9
|
|
9
10
|
class << self
|
10
11
|
def parse(hash)
|
@@ -13,6 +14,7 @@ module TryApi
|
|
13
14
|
instance.host = hash[:host]
|
14
15
|
instance.port = hash[:port]
|
15
16
|
instance.api_prefix = hash[:api_prefix]
|
17
|
+
instance.variables = hash[:variables]
|
16
18
|
instance.menu_items = []
|
17
19
|
hash[:menu_items].each do |category|
|
18
20
|
instance.menu_items << TryApi::MenuItem.parse(hash: category, project: instance)
|
@@ -8,6 +8,7 @@
|
|
8
8
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
9
9
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.8/jquery.slimscroll.min.js"></script>
|
10
10
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js"></script>
|
11
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-animate.js"></script>
|
11
12
|
|
12
13
|
<%= stylesheet_link_tag "try_api/application", :media => "all", :async => false %>
|
13
14
|
<%= javascript_include_tag "try_api/application", :media => "all", :async => false %>
|
@@ -72,14 +72,15 @@
|
|
72
72
|
</div>
|
73
73
|
</div>
|
74
74
|
<div class="col-md-6 method-example"><h1>Example responses</h1>
|
75
|
-
<div ng-repeat="example in method.example_responses">
|
76
|
-
<div class="response">
|
75
|
+
<div ng-repeat="example in method.example_responses" class="method-example-response">
|
76
|
+
<div class="method-example-response-header" ng-click="example.isCollapsed = !example.isCollapsed" ng-class="{ 'collapsed': example.isCollapsed }">
|
77
77
|
<span class="label label-{{ example.color }}">
|
78
78
|
{{ example.code }}
|
79
79
|
</span>
|
80
|
-
{{ example.description }}
|
80
|
+
{{ example.description }}
|
81
|
+
<i class="fa" ng-class=" example.isCollapsed ? 'fa-chevron-left' : 'fa-chevron-down' "></i>
|
81
82
|
</div>
|
82
|
-
<div hljs="" hljs-language="{{ example.type }}" hljs-source="example.response">
|
83
|
+
<div class="method-example-response-body" hljs="" hljs-language="{{ example.type }}" hljs-source="example.response" uib-collapse="example.isCollapsed">
|
83
84
|
|
84
85
|
</div>
|
85
86
|
</div>
|
@@ -2,6 +2,11 @@ project_name: 'My awesome project'
|
|
2
2
|
host: 'http://localhost'
|
3
3
|
port: 3000
|
4
4
|
api_prefix: 'api/v1'
|
5
|
+
variables:
|
6
|
+
access_denied_error: >
|
7
|
+
{
|
8
|
+
"errors": ["Access Denied !"]
|
9
|
+
}
|
5
10
|
menu_items:
|
6
11
|
-
|
7
12
|
title: 'Introduction'
|
@@ -113,10 +118,7 @@ menu_items:
|
|
113
118
|
type: 'json'
|
114
119
|
-
|
115
120
|
code: 401
|
116
|
-
response:
|
117
|
-
{
|
118
|
-
"error": "Access Denied !"
|
119
|
-
}
|
121
|
+
response: var:access_denied_error # You can move repeatable parts to variable
|
120
122
|
type: 'json'
|
121
123
|
-
|
122
124
|
title: 'Registration steps'
|
@@ -178,10 +180,7 @@ menu_items:
|
|
178
180
|
type: 'json'
|
179
181
|
-
|
180
182
|
code: 401
|
181
|
-
response:
|
182
|
-
{
|
183
|
-
"errors": ["Access Denied !"]
|
184
|
-
}
|
183
|
+
response: var:access_denied_error # You can move repeatable parts to variable
|
185
184
|
type: 'json'
|
186
185
|
-
|
187
186
|
code: 422
|
@@ -246,10 +245,7 @@ menu_items:
|
|
246
245
|
type: 'json'
|
247
246
|
-
|
248
247
|
code: 401
|
249
|
-
response:
|
250
|
-
{
|
251
|
-
"errors": ["Access Denied !"]
|
252
|
-
}
|
248
|
+
response: var:access_denied_error # You can move repeatable parts to variable
|
253
249
|
type: 'json'
|
254
250
|
-
|
255
251
|
code: 422
|
@@ -329,10 +325,7 @@ menu_items:
|
|
329
325
|
type: 'json'
|
330
326
|
-
|
331
327
|
code: 401
|
332
|
-
response:
|
333
|
-
{
|
334
|
-
"errors": ["Access Denied !"]
|
335
|
-
}
|
328
|
+
response: var:access_denied_error # You can move repeatable parts to variable
|
336
329
|
type: 'json'
|
337
330
|
-
|
338
331
|
code: 422
|
data/lib/try_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: try_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mykhaylo Skubenych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|