try_api 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/try_api/application.js.coffee +133 -56
- data/app/assets/javascripts/try_api/param.directive.js.coffee +2 -2
- data/app/assets/javascripts/try_api/paramsarray.directive.js.coffee +8 -2
- data/app/assets/javascripts/try_api/scrollspy.directive.js +88 -0
- data/app/assets/stylesheets/try_api/application.css.sass +20 -2
- data/app/controllers/try_api/application_controller.rb +5 -1
- data/app/models/try_api/base.rb +7 -6
- data/app/models/try_api/cookie.rb +7 -0
- data/app/models/try_api/example_response.rb +2 -2
- data/app/models/try_api/method.rb +6 -3
- data/app/views/layouts/try_api/application.html.erb +2 -1
- data/app/views/try_api/pages/index.html +64 -12
- data/lib/try_api/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b641b5c9910f77e6b1e5d868f239beb51c0ec683
|
4
|
+
data.tar.gz: 7f0ea527339f494fb08251956aeee9e587b86c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b9d29e9eaaae990098ad0b101d9495aaa6697aeb13de00ed11262d619f58bc71cc4a5339103e085d31c23871eeab860ca91f01954f3202dd05a803bb36fee45
|
7
|
+
data.tar.gz: 8a75f8800385d097391acccf07438f4b6719266148820bef3aa39e58c88329a5955da1c2c67d36603b6ebda05a93c37b826bd846d861eacb8d5d160fe8a1dc36
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#= require try_api/paramsarray.directive
|
4
4
|
#= require try_api/image.directive
|
5
5
|
#= require try_api/url.directive
|
6
|
+
#= require try_api/scrollspy.directive
|
6
7
|
|
7
8
|
$ ->
|
8
9
|
$('pre code').each (i, block) ->
|
@@ -28,9 +29,11 @@ $ ->
|
|
28
29
|
TryApiApp = angular.module('TryApiApp', [
|
29
30
|
'ui.bootstrap'
|
30
31
|
'ngAnimate'
|
32
|
+
'ngCookies'
|
31
33
|
'TryApi'
|
32
34
|
'angular-ladda'
|
33
35
|
'hljs'
|
36
|
+
'tryApiScrollSpy.directives'
|
34
37
|
])
|
35
38
|
TryApiApp.config [
|
36
39
|
'$httpProvider'
|
@@ -49,8 +52,9 @@ TryApiApp.controller 'HomeController', [
|
|
49
52
|
'$scope'
|
50
53
|
'$timeout'
|
51
54
|
'$sce'
|
52
|
-
'$http'
|
53
|
-
|
55
|
+
'$http',
|
56
|
+
'$cookies'
|
57
|
+
($scope, $timeout, $sce, $http, $cookies) ->
|
54
58
|
|
55
59
|
|
56
60
|
$scope.getHtml = (html) ->
|
@@ -73,6 +77,64 @@ TryApiApp.controller 'HomeController', [
|
|
73
77
|
$scope.global_headers = {}
|
74
78
|
$scope.params = []
|
75
79
|
|
80
|
+
$scope.methodSubmit = (method) ->
|
81
|
+
method.pending = true
|
82
|
+
headers = {'Content-Type': undefined}
|
83
|
+
|
84
|
+
$.each method.headers, (i)->
|
85
|
+
header = this
|
86
|
+
headers[header.name] = header.value
|
87
|
+
|
88
|
+
path = method.submit_path
|
89
|
+
|
90
|
+
switch method.method.toLowerCase()
|
91
|
+
when 'post'
|
92
|
+
fd = new FormData
|
93
|
+
fd.append 'a', 'a' # TODO sending empty array causes EOFError
|
94
|
+
|
95
|
+
$.each method.parameters, (i) ->
|
96
|
+
$scope.addParameterToForm fd, this
|
97
|
+
|
98
|
+
$http.post path, fd,
|
99
|
+
transformRequest: angular.identity
|
100
|
+
headers: headers
|
101
|
+
.success method.response_handler
|
102
|
+
.error method.response_handler
|
103
|
+
when 'delete'
|
104
|
+
url = ''
|
105
|
+
|
106
|
+
$.each method.parameters, (i) ->
|
107
|
+
url = $scope.addParameterToUrl(url, this)
|
108
|
+
|
109
|
+
$http.delete path + '?' + url,
|
110
|
+
transformRequest: angular.identity
|
111
|
+
headers: headers
|
112
|
+
.success method.response_handler
|
113
|
+
.error method.response_handler
|
114
|
+
when 'get'
|
115
|
+
url = ''
|
116
|
+
|
117
|
+
$.each method.parameters, (i) ->
|
118
|
+
url = $scope.addParameterToUrl(url, this)
|
119
|
+
|
120
|
+
$http.get path + '?' + url,
|
121
|
+
transformRequest: angular.identity
|
122
|
+
headers: headers
|
123
|
+
.success method.response_handler
|
124
|
+
.error method.response_handler
|
125
|
+
when 'put'
|
126
|
+
fd = new FormData
|
127
|
+
fd.append 'a', 'a' # TODO sending empty array causes EOFError
|
128
|
+
|
129
|
+
$.each method.parameters, (i) ->
|
130
|
+
$scope.addParameterToForm fd, this
|
131
|
+
|
132
|
+
$http.put path, fd,
|
133
|
+
transformRequest: angular.identity
|
134
|
+
headers: headers
|
135
|
+
.success method.response_handler
|
136
|
+
.error method.response_handler
|
137
|
+
|
76
138
|
$http.get('/developers/projects.json').success (data) -> # TODO this should depends from app routes
|
77
139
|
$scope.project = data.project
|
78
140
|
$.each $scope.project.menu_items, () ->
|
@@ -91,60 +153,54 @@ TryApiApp.controller 'HomeController', [
|
|
91
153
|
headers: JSON.stringify(config.headers, null, 2)
|
92
154
|
status: status
|
93
155
|
|
94
|
-
method.
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
.
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
$http.put path, fd,
|
144
|
-
transformRequest: angular.identity
|
145
|
-
headers: headers
|
146
|
-
.success method.response_handler
|
147
|
-
.error method.response_handler
|
156
|
+
switch method.method.toLowerCase()
|
157
|
+
when 'web_socket'
|
158
|
+
method.submit = ->
|
159
|
+
$.each method.cookies, (i) ->
|
160
|
+
$cookies.put(this.name, this.value)
|
161
|
+
|
162
|
+
method.pending = true
|
163
|
+
method.connected = false
|
164
|
+
method.response = {data: []}
|
165
|
+
|
166
|
+
if 'WebSocket' of window
|
167
|
+
method.ws = new WebSocket('ws://' + $scope.project.endpoint + '/' + method.submit_path)
|
168
|
+
|
169
|
+
method.ws.onopen = ->
|
170
|
+
$scope.$apply ->
|
171
|
+
method.pending = false
|
172
|
+
method.response.data.push('Connected')
|
173
|
+
method.ws.send(JSON.stringify({command: "subscribe", identifier: JSON.stringify(method.identifier)}))
|
174
|
+
method.response.data.push('Subscribed to ' + JSON.stringify(method.identifier))
|
175
|
+
method.connected = true
|
176
|
+
|
177
|
+
method.ws.onmessage = (evt) ->
|
178
|
+
$scope.$apply ->
|
179
|
+
if(JSON.parse(evt.data).type != 'ping')
|
180
|
+
method.response.data.push(evt.data)
|
181
|
+
|
182
|
+
method.ws.onclose = ->
|
183
|
+
$scope.$apply ->
|
184
|
+
method.pending = false
|
185
|
+
method.connected = false
|
186
|
+
method.response.data.push('Disconnected')
|
187
|
+
|
188
|
+
else
|
189
|
+
method.response.data.push('WebSocket NOT supported by your Browser!')
|
190
|
+
|
191
|
+
method.speak = ->
|
192
|
+
method.ws.send JSON.stringify({
|
193
|
+
command: "message",
|
194
|
+
data: JSON.stringify({ message: method.message, action: 'speak'})
|
195
|
+
identifier: JSON.stringify(method.identifier)
|
196
|
+
})
|
197
|
+
method.message = ''
|
198
|
+
else
|
199
|
+
method.submit = ->
|
200
|
+
$scope.methodSubmit(method)
|
201
|
+
.error (data, status, headers, config) ->
|
202
|
+
if status = 422
|
203
|
+
alert data.error
|
148
204
|
|
149
205
|
$scope.addParameterToForm = (form, parameter) -> # TODO implement multidimentional parameters
|
150
206
|
if parameter.type == 'array'
|
@@ -165,4 +221,25 @@ TryApiApp.controller 'HomeController', [
|
|
165
221
|
else
|
166
222
|
if parameter.value
|
167
223
|
form.append parameter.name, parameter.value || ''
|
224
|
+
|
225
|
+
$scope.addParameterToUrl = (url, parameter) ->
|
226
|
+
if parameter.type == 'array'
|
227
|
+
$.each parameter.values, ->
|
228
|
+
value = this
|
229
|
+
$.each value, ->
|
230
|
+
subparameter = this
|
231
|
+
switch subparameter.type
|
232
|
+
when 'boolean'
|
233
|
+
url = url + parameter.name + '[]' + (subparameter.name || '') + '=' + (subparameter.value || false) + '&'
|
234
|
+
else
|
235
|
+
if subparameter.value
|
236
|
+
url = url + parameter.name + '[]' + (subparameter.name || '') + '=' + subparameter.value + '&'
|
237
|
+
else
|
238
|
+
switch parameter.type
|
239
|
+
when 'boolean'
|
240
|
+
url = url + parameter.name + '=' + (parameter.value || false) + '&'
|
241
|
+
else
|
242
|
+
if parameter.value
|
243
|
+
url = url + parameter.name + '=' + parameter.value + '&'
|
244
|
+
return url
|
168
245
|
]
|
@@ -18,7 +18,7 @@ angular.module('TryApi').directive 'param', [
|
|
18
18
|
template: '' +
|
19
19
|
'<div class="col-md-4 text-right" ng-if=\'parameter.type != "array"\'>' +
|
20
20
|
' <b>{{ parameter.name }}</b>' +
|
21
|
-
' <span class="
|
21
|
+
' <span class="label label-success">{{ parameter.type }}</span>' +
|
22
22
|
'</div>' +
|
23
23
|
'<div class="col-md-8" ng-if=\'parameter.type != "array"\'>' +
|
24
24
|
' <div ng-switch="parameter.type">' +
|
@@ -40,7 +40,7 @@ angular.module('TryApi').directive 'param', [
|
|
40
40
|
' <div class="row">' +
|
41
41
|
' <div class="col-md-4 text-right">' +
|
42
42
|
' <b>{{ parameter.name }}</b>' +
|
43
|
-
' <span class="
|
43
|
+
' <span class="label label-success">{{ parameter.type }}</span>' +
|
44
44
|
' </div>' +
|
45
45
|
' <div class="col-md-8">' +
|
46
46
|
' <div class="text-muted small" ng-bind-html="getHtml(parameter.description)"></div>' +
|
@@ -9,6 +9,9 @@ angular.module('TryApi').directive 'paramsarray', [
|
|
9
9
|
scope.addItem = ()->
|
10
10
|
scope.parameter.values.push jQuery.extend(true, {}, scope.parameter.parameters)
|
11
11
|
|
12
|
+
scope.deleteItem = (index)->
|
13
|
+
scope.parameter.values.splice(index, 1)
|
14
|
+
|
12
15
|
return {
|
13
16
|
link: link
|
14
17
|
restrict: 'A'
|
@@ -16,9 +19,12 @@ angular.module('TryApi').directive 'paramsarray', [
|
|
16
19
|
scope:
|
17
20
|
parameter: '=ngModel'
|
18
21
|
template: '' +
|
19
|
-
'<div ng-repeat="value in parameter.values track by $index"
|
22
|
+
'<div class="try-api-array-item" ng-repeat="value in parameter.values track by $index">' +
|
20
23
|
' <div params ng-model="value"></div>' +
|
24
|
+
' <div class="try-api-array-item-close" ng-click="deleteItem($index)"><i class="fa fa-close"></i></div>' +
|
21
25
|
'</div>' +
|
22
|
-
'<
|
26
|
+
'<div class="try-api-array-item try-api-array-item-add" ng-click="addItem()">' +
|
27
|
+
' <a>Add</a>' +
|
28
|
+
'</div>'
|
23
29
|
}
|
24
30
|
]
|
@@ -0,0 +1,88 @@
|
|
1
|
+
// From https://github.com/quanghoc/angular-bootstrap-scrollspy
|
2
|
+
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
angular.module('tryApiScrollSpy.directives', [])
|
6
|
+
|
7
|
+
.directive("scrollTo", ["$window", function($window){
|
8
|
+
return {
|
9
|
+
restrict : "AC",
|
10
|
+
compile : function(){
|
11
|
+
|
12
|
+
function scrollInto(elementId) {
|
13
|
+
if(!elementId) $window.scrollTo(0, 0);
|
14
|
+
//check if an element can be found with id attribute
|
15
|
+
var el = document.getElementById(elementId);
|
16
|
+
if(el) el.scrollIntoView();
|
17
|
+
}
|
18
|
+
|
19
|
+
return function(scope, element, attr) {
|
20
|
+
element.bind("click", function(event){
|
21
|
+
scrollInto(attr.scrollTo);
|
22
|
+
});
|
23
|
+
};
|
24
|
+
}
|
25
|
+
};
|
26
|
+
}])
|
27
|
+
|
28
|
+
.directive('scrollSpy', ['$window', '$timeout', '$rootScope', function($window, $timeout, $rootScope) {
|
29
|
+
var targets,
|
30
|
+
spies = [];
|
31
|
+
|
32
|
+
var refresh = function(attrs) {
|
33
|
+
var slice = Array.prototype.slice;
|
34
|
+
|
35
|
+
$timeout(function() {
|
36
|
+
targets = $(attrs.target).find('.second-level-menu-items li');
|
37
|
+
slice.call(targets).forEach(function(el) {
|
38
|
+
var spy = $(el.querySelector('a').getAttribute('href'));
|
39
|
+
|
40
|
+
if (spy.length > 0) {
|
41
|
+
spies.push(spy);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}, 1000);
|
45
|
+
};
|
46
|
+
|
47
|
+
var activate = function(scope, $element, attrs) {
|
48
|
+
$(attrs.target + ' .active').removeClass('active');
|
49
|
+
$element.addClass('active');
|
50
|
+
};
|
51
|
+
|
52
|
+
var process = function(scope, element, attrs) {
|
53
|
+
var windowHeight = $window.innerHeight,
|
54
|
+
windowTop = $window.scrollY,
|
55
|
+
$activeTarget;
|
56
|
+
|
57
|
+
spies.map(function(item, index) {
|
58
|
+
var pos = item.offset().top - windowTop;
|
59
|
+
|
60
|
+
if (pos < windowHeight) {
|
61
|
+
$activeTarget = targets.eq(index);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
// console.log($activeTarget);
|
66
|
+
activate(scope, $activeTarget, attrs);
|
67
|
+
};
|
68
|
+
|
69
|
+
return {
|
70
|
+
link: function(scope, element, attrs) {
|
71
|
+
targets = [];
|
72
|
+
spies = [];
|
73
|
+
|
74
|
+
refresh(attrs);
|
75
|
+
|
76
|
+
angular.element($window).bind("scroll", function() {
|
77
|
+
process(scope, element, attrs);
|
78
|
+
scope.$apply();
|
79
|
+
});
|
80
|
+
|
81
|
+
// When DOM changes, refresh with a broadcast like this $rootScope.$broadcast('scrollspy.refresh');
|
82
|
+
$rootScope.$on('scrollspy.refresh', function() {
|
83
|
+
refresh(attrs);
|
84
|
+
});
|
85
|
+
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}]);
|
@@ -76,7 +76,7 @@ body
|
|
76
76
|
|
77
77
|
&-menu
|
78
78
|
.active > a
|
79
|
-
color: #
|
79
|
+
color: #19B698
|
80
80
|
|
81
81
|
padding: 10px
|
82
82
|
|
@@ -258,7 +258,22 @@ body
|
|
258
258
|
.ladda-button
|
259
259
|
padding: 5px 8px
|
260
260
|
|
261
|
-
|
261
|
+
.try-api-array-item
|
262
|
+
border: 1px solid #e9e9e9
|
263
|
+
margin: 1px 1px 1px 10px
|
264
|
+
position: relative
|
265
|
+
padding-right: 30px
|
266
|
+
&-add
|
267
|
+
cursor: pointer
|
268
|
+
text-align: center
|
269
|
+
a
|
270
|
+
color: #19B698
|
271
|
+
&-close
|
272
|
+
color: #19B698
|
273
|
+
position: absolute
|
274
|
+
top: 8px
|
275
|
+
right: 6px
|
276
|
+
cursor: pointer
|
262
277
|
|
263
278
|
.droppable-area
|
264
279
|
border: 2px dashed transparent
|
@@ -318,3 +333,6 @@ body
|
|
318
333
|
width: 15px
|
319
334
|
height: 15px
|
320
335
|
cursor: pointer
|
336
|
+
|
337
|
+
.label-success
|
338
|
+
background-color: #19B698
|
@@ -3,7 +3,11 @@ class TryApi::ApplicationController < ActionController::Base
|
|
3
3
|
|
4
4
|
rescue_from Exception do |exception|
|
5
5
|
@message = exception.message
|
6
|
-
|
6
|
+
begin
|
7
|
+
render template: 'try_api/pages/config_file_not_found'
|
8
|
+
rescue Exception => e
|
9
|
+
render json: {error: exception.message}, status: 422
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
end
|
data/app/models/try_api/base.rb
CHANGED
@@ -35,17 +35,20 @@ module TryApi
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
attr_accessor :id
|
39
38
|
typesafe_accessor :parent, TryApi::Base
|
40
|
-
|
39
|
+
attr_accessor :id
|
41
40
|
|
42
|
-
def to_json
|
41
|
+
def to_json(id = 1)
|
42
|
+
self.id = id
|
43
43
|
result = {}
|
44
44
|
|
45
45
|
self.instance_variables.each do |i|
|
46
46
|
value = self.instance_variable_get(i)
|
47
47
|
if value.instance_of?(Array)
|
48
|
-
result[i.to_s.delete('@')] = value.map
|
48
|
+
result[i.to_s.delete('@')] = value.map do |v|
|
49
|
+
id += 1
|
50
|
+
v.to_json(id)
|
51
|
+
end
|
49
52
|
else
|
50
53
|
if i == :@parent
|
51
54
|
|
@@ -55,7 +58,6 @@ module TryApi
|
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
|
-
result.merge!({id: self.id})
|
59
61
|
result.with_indifferent_access
|
60
62
|
end
|
61
63
|
|
@@ -64,7 +66,6 @@ module TryApi
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def initialize(hash)
|
67
|
-
self.id = @@instances_count += 1
|
68
69
|
result_hash = {}
|
69
70
|
hash.to_h.each do |k, v|
|
70
71
|
if k.to_s == 'include!'
|
@@ -4,12 +4,15 @@ module TryApi
|
|
4
4
|
typesafe_accessor :description, String
|
5
5
|
typesafe_accessor :parameters, Array, items_type: TryApi::Parameter
|
6
6
|
typesafe_accessor :headers, Array, items_type: TryApi::Header
|
7
|
+
typesafe_accessor :cookies, Array, items_type: TryApi::Cookie
|
7
8
|
typesafe_accessor :path, String
|
8
9
|
typesafe_accessor :method, String
|
9
10
|
typesafe_accessor :example_responses, Array, items_type: TryApi::ExampleResponse
|
11
|
+
typesafe_accessor :api_prefix, String
|
12
|
+
typesafe_accessor :identifier, Hash
|
10
13
|
|
11
|
-
def to_json
|
12
|
-
super.merge local_path: local_path, full_path: full_path
|
14
|
+
def to_json(id)
|
15
|
+
super(id).merge local_path: local_path, full_path: full_path
|
13
16
|
end
|
14
17
|
|
15
18
|
def full_path
|
@@ -17,7 +20,7 @@ module TryApi
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def local_path
|
20
|
-
"/#{ self.project.api_prefix }#{ self.path }"
|
23
|
+
"/#{ self.api_prefix || self.project.api_prefix }#{ self.path }"
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
@@ -15,6 +15,7 @@
|
|
15
15
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"></script>
|
16
16
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Ladda/1.0.0/ladda.min.js"></script>
|
17
17
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ladda/0.4.2/angular-ladda.min.js"></script>
|
18
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-cookies.min.js"></script>
|
18
19
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"/>
|
19
20
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css"/>
|
20
21
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/atelier-savanna-dark.min.css"/>
|
@@ -23,7 +24,7 @@
|
|
23
24
|
<%= stylesheet_link_tag "try_api/application", :media => "all", :async => false %>
|
24
25
|
<%= javascript_include_tag "try_api/application", :media => "all", :async => false %>
|
25
26
|
</head>
|
26
|
-
<body
|
27
|
+
<body style="position: relative" scroll-spy='' data-target="#tryApiScrollspy" ng-app="TryApiApp" ng-controller="HomeController">
|
27
28
|
<%= yield %>
|
28
29
|
</body>
|
29
30
|
</html>
|
@@ -1,12 +1,16 @@
|
|
1
1
|
<div class="try-api-sidebar">
|
2
|
-
<div class="try-api-sidebar-header"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
<div class="try-api-sidebar-header">
|
3
|
+
<b>{{ project.name }}</b>
|
4
|
+
API
|
5
|
+
</div>
|
6
|
+
<div class="try-api-sidebar-menu-container">
|
7
|
+
<ul class="try-api-sidebar-menu try-api-sidebar-menu-items nav" id="tryApiScrollspy">
|
8
|
+
<li class="try-api-sidebar-menu-item" ng-repeat="menu_item in project.menu_items track by menu_item.id">
|
9
|
+
<a href="{{ '#section' + menu_item.id }}">{{ menu_item.title }}</a>
|
7
10
|
<ul class="second-level-menu-items nav" ng-show="menu_item.methods">
|
8
|
-
<li ng-repeat="method in menu_item.methods track by method.id"
|
9
|
-
|
11
|
+
<li ng-repeat="method in menu_item.methods track by method.id">
|
12
|
+
<a href="{{ '#section' + menu_item.id + method.id }}">{{ method.title }}</a>
|
13
|
+
</li>
|
10
14
|
</ul>
|
11
15
|
</li>
|
12
16
|
</ul>
|
@@ -14,7 +18,9 @@
|
|
14
18
|
</div>
|
15
19
|
<div class="try-api-container">
|
16
20
|
<div class="row method is-flex">
|
17
|
-
<div class="col-md-6 method-try"
|
21
|
+
<div class="col-md-6 method-try">
|
22
|
+
<h2 class="method-try-heading">{{ project.name }}</h2>
|
23
|
+
</div>
|
18
24
|
<div class="col-md-6 method-example">API endpoint
|
19
25
|
<div class="method-example-code">{{ project.endpoint }}</div>
|
20
26
|
</div>
|
@@ -31,13 +37,13 @@
|
|
31
37
|
<div ng-bind-html="getHtml(method.description)"></div>
|
32
38
|
</div>
|
33
39
|
</div>
|
34
|
-
<div class="row method is-flex" id="{{ method.description ? '' : ('section' + menu_item.id + method.id) }}">
|
40
|
+
<div class="row method is-flex" id="{{ method.description ? '' : ('section' + menu_item.id + method.id) }}" ng-if="method.method != 'web_socket'">
|
35
41
|
<div class="col-md-6 method-try"><h4>{{ method.title }}</h4>
|
36
42
|
<h4>
|
37
|
-
<
|
43
|
+
<span class="label label-success" style="text-transform: uppercase">{{ method.method }}</span>
|
38
44
|
<span url=true ng-model="method.submit_path" pattern="method.local_path"></span>
|
39
45
|
</h4>
|
40
|
-
<div ng-if="method.headers.length
|
46
|
+
<div ng-if="method.headers.length > 0"><label>Headers:</label>
|
41
47
|
<div class="row parameter" ng-repeat="header in method.headers">
|
42
48
|
<div class="col-md-4 text-right"><b>{{header.name }}</b></div>
|
43
49
|
<div class="col-md-8"><input ng-model="header.value" type="text"/>
|
@@ -47,7 +53,7 @@
|
|
47
53
|
</div>
|
48
54
|
</div>
|
49
55
|
</div>
|
50
|
-
<div ng-if="method.parameters.length
|
56
|
+
<div ng-if="method.parameters.length > 0"><label>Parameters:</label>
|
51
57
|
<div ng-model="method.parameters" params=""></div>
|
52
58
|
</div>
|
53
59
|
<br/>
|
@@ -85,6 +91,52 @@
|
|
85
91
|
</div>
|
86
92
|
</div>
|
87
93
|
</div>
|
94
|
+
<div class="row method is-flex" id="{{ method.description ? '' : ('section' + menu_item.id + method.id) }}" ng-if="method.method == 'web_socket'">
|
95
|
+
<div class="col-md-12 method-try"><h4>{{ method.title }}</h4>
|
96
|
+
<h4>
|
97
|
+
<span class="label label-success" style="text-transform: uppercase">{{ method.method }}</span>
|
98
|
+
<span url=true ng-model="method.submit_path" pattern="method.local_path"></span>
|
99
|
+
</h4>
|
100
|
+
<div ng-if="method.cookies.length > 0"><label>Identifier:</label>
|
101
|
+
<div class="row parameter">
|
102
|
+
<div class="col-md-4 text-right"></div>
|
103
|
+
<div class="col-md-8">
|
104
|
+
{{ method.identifier }}
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
<div ng-if="method.cookies.length > 0"><label>Cookies:</label>
|
109
|
+
<div class="row parameter" ng-repeat="cookie in method.cookies">
|
110
|
+
<div class="col-md-4 text-right"><b>{{cookie.name }}</b></div>
|
111
|
+
<div class="col-md-8">
|
112
|
+
<input ng-model="cookie.value" type="text"/>
|
113
|
+
<div class="text-muted small">
|
114
|
+
<div ng-trust-html="getHtml(cookie.description)"></div>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
<br/>
|
120
|
+
<div class="method-example-code" id="method.response">
|
121
|
+
<div ng-repeat="data_row in method.response.data track by $index">
|
122
|
+
{{ data_row }}
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
<br/>
|
126
|
+
<div class="text-right progress-demo">
|
127
|
+
<button class="btn btn-success ladda-button" data-color="mint" data-style="expand-right" ladda="method.pending" ng-click="method.submit()" sata-size="s" ng-hide="method.connected">
|
128
|
+
<span class="ladda-label">Connect</span><span class="ladda-spinner"></span>
|
129
|
+
<div class="ladda-progress" style="width: 100px"></div>
|
130
|
+
</button>
|
131
|
+
<textarea ng-model="method.message" placeholder="message" ng-show="method.connected" style="width: 300px"></textarea>
|
132
|
+
<button class="btn btn-success ladda-button" data-color="mint" data-style="expand-right" ladda="method.pending" ng-click="method.speak()" sata-size="s" ng-show="method.connected">
|
133
|
+
<span class="ladda-label">Speak</span><span class="ladda-spinner"></span>
|
134
|
+
<div class="ladda-progress" style="width: 100px"></div>
|
135
|
+
</button>
|
136
|
+
</div>
|
137
|
+
<br/>
|
138
|
+
</div>
|
139
|
+
</div>
|
88
140
|
</div>
|
89
141
|
</div>
|
90
142
|
<div class="row method is-flex">
|
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.1.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- app/assets/javascripts/try_api/param.directive.js.coffee
|
40
40
|
- app/assets/javascripts/try_api/params.directive.js.coffee
|
41
41
|
- app/assets/javascripts/try_api/paramsarray.directive.js.coffee
|
42
|
+
- app/assets/javascripts/try_api/scrollspy.directive.js
|
42
43
|
- app/assets/javascripts/try_api/url.directive.js.coffee
|
43
44
|
- app/assets/stylesheets/try_api/application.css.sass
|
44
45
|
- app/controllers/try_api/application_controller.rb
|
@@ -47,6 +48,7 @@ files:
|
|
47
48
|
- app/helpers/try_api/application_helper.rb
|
48
49
|
- app/models/try_api/base.rb
|
49
50
|
- app/models/try_api/config_parser.rb
|
51
|
+
- app/models/try_api/cookie.rb
|
50
52
|
- app/models/try_api/example_response.rb
|
51
53
|
- app/models/try_api/header.rb
|
52
54
|
- app/models/try_api/menu_item.rb
|