grape-swagger-ui 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/views/layouts/swagger.html.erb +1 -1
- data/lib/generators/swagger/layout/layout_generator.rb +3 -2
- data/lib/generators/swagger/layout/templates/swagger.html.erb +106 -0
- data/lib/generators/swagger/layout/templates/swagger.html.haml +1 -2
- data/lib/generators/swagger/layout/templates/swagger.html.slim +96 -0
- data/lib/grape-swagger-ui/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177cfa3f40b4492ee4fef7ebc9f30c76cd06b990
|
4
|
+
data.tar.gz: 9c457aab5f44ddee97d7a9a63347ed63a04383ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55dc4a15138b3b70af5809b07ce9e700e208c53a75622e34f5a4572187689c6bf962091c597e792b39c80d54903e28ddc0ce9e5fc2e13724c1eb8c3a266aaca8
|
7
|
+
data.tar.gz: b7f418eae47ff9458d0b2cd68b801b8b024517bfbab665fca11fe140eb0b74559982eee8f698cb2d37622bae54cc241c578116fd544814607c6430550a4a99f4
|
data/README.md
CHANGED
@@ -49,9 +49,9 @@ else
|
|
49
49
|
|
50
50
|
*Generate the main layout for customizations*
|
51
51
|
|
52
|
-
rails generate swagger:layout
|
52
|
+
rails generate swagger:layout [TEMPLATE_ENGINE]
|
53
53
|
|
54
|
-
and change the initializer.
|
54
|
+
and change the initializer. Currently supported: ERB, HAML, SLIM.
|
55
55
|
|
56
56
|
Since this is a seperate layout and if you want to use this in your staging environment you need to precompile it.
|
57
57
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
if (url && url.length > 1) {
|
15
15
|
url = decodeURIComponent(url[1]);
|
16
16
|
} else {
|
17
|
-
url = "
|
17
|
+
url = "<%= request.protocol %><%= request.host%>:<%=request.port%>/api/v1/swagger_doc";
|
18
18
|
}
|
19
19
|
|
20
20
|
hljs.configure({
|
@@ -2,13 +2,14 @@ module Swagger
|
|
2
2
|
module Generators
|
3
3
|
class LayoutGenerator < ::Rails::Generators::Base
|
4
4
|
desc 'Setup a dedicated layout for the swagger-ui'
|
5
|
+
argument :template_engine, :type => :string, :default => "erb"
|
5
6
|
|
6
7
|
def self.source_root
|
7
8
|
File.expand_path('../templates', __FILE__)
|
8
9
|
end
|
9
10
|
|
10
|
-
def create_swagger_layout
|
11
|
-
template
|
11
|
+
def create_swagger_layout
|
12
|
+
template "swagger.html.#{template_engine.underscore}", File.join('app', 'views', 'layouts', "swagger.html.#{template_engine.underscore}")
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang="<%%= I18n.locale.to_s %>" xml:lang="<%%= I18n.locale.to_s %>" xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<title>Swagger UI</title>
|
5
|
+
<%%= javascript_include_tag :swagger_ui %>
|
6
|
+
<%%= stylesheet_link_tag :swagger_ui_screen, :media => :screen %>
|
7
|
+
<%%= stylesheet_link_tag :swagger_ui_print, :media => :print %>
|
8
|
+
<%%= csrf_meta_tags %>
|
9
|
+
<style>
|
10
|
+
.swagger-ui-wrap {
|
11
|
+
max-width: 80%;
|
12
|
+
min-width: 960px;
|
13
|
+
margin-left: auto;
|
14
|
+
margin-right: auto;
|
15
|
+
}
|
16
|
+
</style>
|
17
|
+
|
18
|
+
<script>
|
19
|
+
$(function () {
|
20
|
+
var url = window.location.search.match(/url=([^&]+)/);
|
21
|
+
if (url && url.length > 1) {
|
22
|
+
url = decodeURIComponent(url[1]);
|
23
|
+
} else {
|
24
|
+
url = "<%%= request.protocol %><%%= request.host %>:<%%= request.port %>/api/v1/swagger_doc";
|
25
|
+
}
|
26
|
+
|
27
|
+
hljs.configure({
|
28
|
+
highlightSizeThreshold: 5000
|
29
|
+
});
|
30
|
+
|
31
|
+
// Pre load translate...
|
32
|
+
if(window.SwaggerTranslator) {
|
33
|
+
window.SwaggerTranslator.translate();
|
34
|
+
}
|
35
|
+
window.swaggerUi = new SwaggerUi({
|
36
|
+
url: url,
|
37
|
+
dom_id: "swagger-ui-container",
|
38
|
+
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
39
|
+
onComplete: function(swaggerApi, swaggerUi){
|
40
|
+
if(typeof initOAuth == "function") {
|
41
|
+
initOAuth({
|
42
|
+
clientId: "your-client-id",
|
43
|
+
clientSecret: "your-client-secret-if-required",
|
44
|
+
realm: "your-realms",
|
45
|
+
appName: "your-app-name",
|
46
|
+
scopeSeparator: ",",
|
47
|
+
additionalQueryStringParams: {}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
if(window.SwaggerTranslator) {
|
52
|
+
window.SwaggerTranslator.translate();
|
53
|
+
}
|
54
|
+
},
|
55
|
+
onFailure: function(data) {
|
56
|
+
log("Unable to Load SwaggerUI");
|
57
|
+
},
|
58
|
+
docExpansion: "none",
|
59
|
+
jsonEditor: false,
|
60
|
+
defaultModelRendering: 'schema',
|
61
|
+
showRequestHeaders: false
|
62
|
+
});
|
63
|
+
|
64
|
+
$('#input_apiKey').change(function() {
|
65
|
+
var key = $('#input_apiKey')[0].value;
|
66
|
+
if(key && key.trim() != "") {
|
67
|
+
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
|
68
|
+
}
|
69
|
+
})
|
70
|
+
|
71
|
+
window.swaggerUi.load();
|
72
|
+
|
73
|
+
function log() {
|
74
|
+
if ('console' in window) {
|
75
|
+
console.log.apply(console, arguments);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
});
|
79
|
+
|
80
|
+
|
81
|
+
</script>
|
82
|
+
</head>
|
83
|
+
<body class="swagger-section">
|
84
|
+
<div id="header">
|
85
|
+
<div class="swagger-ui-wrap">
|
86
|
+
<a href="http://swagger.io" id="logo">
|
87
|
+
<span class="logo__title">swagger</span>
|
88
|
+
</a>
|
89
|
+
<form id="api_selector">
|
90
|
+
<div class="input">
|
91
|
+
<input id="input_baseUrl" name="baseUrl" placeholder="http://example.com/api" type="text">/</input>
|
92
|
+
</div>
|
93
|
+
<div class="input">
|
94
|
+
<input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
|
95
|
+
</div>
|
96
|
+
<div id="auth_container"></div>
|
97
|
+
<div class="input">
|
98
|
+
<a class="header__btn" href="#" id="explore">Explore</a>
|
99
|
+
</div>
|
100
|
+
</form>
|
101
|
+
</div>
|
102
|
+
</div>
|
103
|
+
<div class="swagger-ui-wrap" id="message-bar"> </div>
|
104
|
+
<div class="swagger-ui-wrap" id="swagger-ui-container"></div>
|
105
|
+
</body>
|
106
|
+
</html>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
if (url && url.length > 1) {
|
23
23
|
url = decodeURIComponent(url[1]);
|
24
24
|
} else {
|
25
|
-
url = "
|
25
|
+
url = "#{request.protocol}#{request.host}:#{request.port}/api/v1/swagger_doc";
|
26
26
|
}
|
27
27
|
|
28
28
|
hljs.configure({
|
@@ -93,4 +93,3 @@
|
|
93
93
|
%a#explore.header__btn{"data-sw-translate" => "", :href => "#"} Explore
|
94
94
|
#message-bar.swagger-ui-wrap{"data-sw-translate" => ""}
|
95
95
|
#swagger-ui-container.swagger-ui-wrap
|
96
|
-
|
@@ -0,0 +1,96 @@
|
|
1
|
+
doctype html
|
2
|
+
html xmlns="http://www.w3.org/1999/xhtml" lang=I18n.locale.to_s xml:lang=(I18n.locale.to_s )
|
3
|
+
head
|
4
|
+
title Swagger UI
|
5
|
+
|
6
|
+
= javascript_include_tag :swagger_ui
|
7
|
+
= stylesheet_link_tag :swagger_ui_screen, :media => :screen
|
8
|
+
= stylesheet_link_tag :swagger_ui_print, :media => :print
|
9
|
+
= csrf_meta_tags
|
10
|
+
|
11
|
+
css:
|
12
|
+
.swagger-ui-wrap {
|
13
|
+
max-width: 80%;
|
14
|
+
min-width: 960px;
|
15
|
+
margin-left: auto;
|
16
|
+
margin-right: auto;
|
17
|
+
}
|
18
|
+
|
19
|
+
javascript:
|
20
|
+
$(function () {
|
21
|
+
var url = window.location.search.match(/url=([^&]+)/);
|
22
|
+
if (url && url.length > 1) {
|
23
|
+
url = decodeURIComponent(url[1]);
|
24
|
+
} else {
|
25
|
+
url = "#{request.protocol}#{request.host}:#{request.port}/api/v1/swagger_doc";
|
26
|
+
}
|
27
|
+
|
28
|
+
hljs.configure({
|
29
|
+
highlightSizeThreshold: 5000
|
30
|
+
});
|
31
|
+
|
32
|
+
// Pre load translate...
|
33
|
+
if(window.SwaggerTranslator) {
|
34
|
+
window.SwaggerTranslator.translate();
|
35
|
+
}
|
36
|
+
window.swaggerUi = new SwaggerUi({
|
37
|
+
url: url,
|
38
|
+
dom_id: "swagger-ui-container",
|
39
|
+
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
40
|
+
onComplete: function(swaggerApi, swaggerUi){
|
41
|
+
if(typeof initOAuth == "function") {
|
42
|
+
initOAuth({
|
43
|
+
clientId: "your-client-id",
|
44
|
+
clientSecret: "your-client-secret-if-required",
|
45
|
+
realm: "your-realms",
|
46
|
+
appName: "your-app-name",
|
47
|
+
scopeSeparator: ",",
|
48
|
+
additionalQueryStringParams: {}
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
if(window.SwaggerTranslator) {
|
53
|
+
window.SwaggerTranslator.translate();
|
54
|
+
}
|
55
|
+
},
|
56
|
+
onFailure: function(data) {
|
57
|
+
log("Unable to Load SwaggerUI");
|
58
|
+
},
|
59
|
+
docExpansion: "none",
|
60
|
+
jsonEditor: false,
|
61
|
+
defaultModelRendering: 'schema',
|
62
|
+
showRequestHeaders: false
|
63
|
+
});
|
64
|
+
|
65
|
+
$('#input_apiKey').change(function() {
|
66
|
+
var key = $('#input_apiKey')[0].value;
|
67
|
+
if(key && key.trim() != "") {
|
68
|
+
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
|
69
|
+
}
|
70
|
+
})
|
71
|
+
|
72
|
+
window.swaggerUi.load();
|
73
|
+
|
74
|
+
function log() {
|
75
|
+
if ('console' in window) {
|
76
|
+
console.log.apply(console, arguments);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
body.swagger-section
|
82
|
+
#header
|
83
|
+
.swagger-ui-wrap
|
84
|
+
a#logo href="http://swagger.io"
|
85
|
+
span.logo__title swagger
|
86
|
+
form#api_selector
|
87
|
+
.input
|
88
|
+
input#input_baseUrl name="baseUrl" placeholder="http://example.com/api" type="text" /
|
89
|
+
.input
|
90
|
+
input#input_apiKey name="apiKey" placeholder="api_key" type="text"
|
91
|
+
#auth_container
|
92
|
+
.input
|
93
|
+
a#explore.header__btn data-sw-translate="" href="#" Explore
|
94
|
+
|
95
|
+
#message-bar.swagger-ui-wrap data-sw-translate=""
|
96
|
+
#swagger-ui-container.swagger-ui-wrap
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaas Endrikat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -44,7 +44,9 @@ files:
|
|
44
44
|
- grape-swagger-ui.gemspec
|
45
45
|
- lib/generators/swagger/layout/USAGE
|
46
46
|
- lib/generators/swagger/layout/layout_generator.rb
|
47
|
+
- lib/generators/swagger/layout/templates/swagger.html.erb
|
47
48
|
- lib/generators/swagger/layout/templates/swagger.html.haml
|
49
|
+
- lib/generators/swagger/layout/templates/swagger.html.slim
|
48
50
|
- lib/grape-swagger-ui.rb
|
49
51
|
- lib/grape-swagger-ui/version.rb
|
50
52
|
- vendor/assets/fonts/DroidSans-Bold.ttf
|
@@ -117,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
119
|
version: '0'
|
118
120
|
requirements: []
|
119
121
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.5.2
|
121
123
|
signing_key:
|
122
124
|
specification_version: 4
|
123
125
|
summary: swagger ui js integration for grape and grape-swagger
|