swagger_ui_engine 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/ca.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/de.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/el.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/en.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/es.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/fr.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/geo.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/it.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/ja.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/ko-kr.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/pl.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/pt.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/ru.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/tr.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lang/zh-cn.js +3 -1
- data/app/assets/javascripts/swagger_ui_engine/lib/swagger-oauth.js +1 -1
- data/app/assets/javascripts/swagger_ui_engine/swagger-ui.js +10 -10
- data/app/assets/stylesheets/swagger_ui_engine/application.css +1 -0
- data/app/assets/stylesheets/swagger_ui_engine/custom.css +7 -0
- data/app/controllers/swagger_ui_engine/application_controller.rb +2 -1
- data/app/controllers/swagger_ui_engine/docs_controller.rb +17 -3
- data/app/helpers/swagger_ui_engine/auth_config_parser.rb +19 -0
- data/app/helpers/swagger_ui_engine/config_parser.rb +39 -0
- data/app/helpers/swagger_ui_engine/oauth_config_parser.rb +31 -0
- data/app/helpers/swagger_ui_engine/swagger_ui_defaults.rb +27 -0
- data/app/helpers/swagger_ui_engine/translation_helper.rb +16 -0
- data/app/{assets/javascripts/swagger_ui_engine/o2c.html → views/swagger_ui_engine/docs/ouath2.html.erb} +0 -0
- data/app/views/swagger_ui_engine/docs/show.html.erb +13 -6
- data/config/routes.rb +6 -1
- data/lib/swagger_ui_engine/configuration.rb +7 -0
- data/lib/swagger_ui_engine/engine.rb +2 -0
- data/lib/swagger_ui_engine/version.rb +1 -1
- metadata +10 -6
- data/app/helpers/auth_config_parser.rb +0 -17
- data/app/helpers/config_parser.rb +0 -37
- data/app/helpers/swagger_ui_defaults.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 523b130aea7593cd7682b8281962c30e5b2a0277
|
4
|
+
data.tar.gz: 23e0cbdee181c30db11d677fe3d296409de836be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488bbc670b69c113d6960e7aec42c76bf6736cfe12ac2b1a0ee79d53559f8d98900189fe2cdd0690528727450fa1019d0f4e92eee9287d3656f0b5c72d3b9912
|
7
|
+
data.tar.gz: 9fbca2dd081d43b86db825e1e7079bd7c85b9fb43d2c208c9ff0ec55b56483af04b9f9fad85e89817e9720d3e51bd10fd0da11bb50c35c00334222ff52044634
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.0.1
|
6
|
+
|
7
|
+
* Support OAuth2 authentication
|
8
|
+
* Support loading Swagger UI translations
|
9
|
+
* Add return link for multiple API versions
|
10
|
+
* Add `de` translation
|
11
|
+
* Refactor helpers
|
12
|
+
|
13
|
+
## 1.0.0
|
14
|
+
|
15
|
+
* Rails 5 dependency. It is compatible with previous versions.
|
16
|
+
* Support API versioning/multiple APIs definitions
|
17
|
+
* Add basic HTTP auth support
|
18
|
+
* Add `validator_enabled` configurable option
|
19
|
+
* Refactor Configuration class definition
|
20
|
+
* Refactor controllers
|
21
|
+
* Redefine gem summary and description
|
22
|
+
|
5
23
|
## 0.0.5
|
6
24
|
|
7
25
|
* Support Swagger UI version 2.2.10
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"Finalitzada la càrrega del recurs informatiu. Renderitzant Swagger UI",
|
50
50
|
"Unable to read api":"No es pot llegir l'api",
|
51
51
|
"from path":"des de la ruta",
|
52
|
-
"server returned":"el servidor ha retornat"
|
52
|
+
"server returned":"el servidor ha retornat",
|
53
|
+
"Authorize":"Authorize",
|
54
|
+
"Back to the list":"Back to the list",
|
53
55
|
});
|
@@ -0,0 +1,58 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/* jshint quotmark: double */
|
4
|
+
window.SwaggerTranslator.learn({
|
5
|
+
"Warning: Deprecated":"Warnung: Deprecated",
|
6
|
+
"Implementation Notes":"Implementierungshinweise",
|
7
|
+
"Response Class":"Response Class",
|
8
|
+
"Status":"Status",
|
9
|
+
"Parameters":"Parameter",
|
10
|
+
"Parameter":"Parameter",
|
11
|
+
"Value":"Wert",
|
12
|
+
"Description":"Beschreibung",
|
13
|
+
"Parameter Type":"Parametertyp",
|
14
|
+
"Data Type":"Datentyp",
|
15
|
+
"Response Messages":"Response Messages",
|
16
|
+
"HTTP Status Code":"HTTP Status Code",
|
17
|
+
"Reason":"Grund",
|
18
|
+
"Response Model":"Response Model",
|
19
|
+
"Request URL":"Request URL",
|
20
|
+
"Response Body":"Response Body",
|
21
|
+
"Response Code":"Response Code",
|
22
|
+
"Response Headers":"Response Headers",
|
23
|
+
"Hide Response":"Response ausblenden",
|
24
|
+
"Headers":"Headers",
|
25
|
+
"Try it out!":"Ausprobieren",
|
26
|
+
"Show/Hide":"Einblenden/Ausblenden",
|
27
|
+
"List Operations":"Endpunkte anzeigen",
|
28
|
+
"Expand Operations":"Endpunkte ausklappen",
|
29
|
+
"Raw":"Raw",
|
30
|
+
"can't parse JSON. Raw result":"Parsen von JSON fehlgeschlagen. Raw result",
|
31
|
+
"Example Value":"Beispielwert",
|
32
|
+
"Model Schema":"Schemamodell",
|
33
|
+
"Model":"Modell",
|
34
|
+
"Click to set as parameter value":"Klicken um Parameter zu setzen",
|
35
|
+
"apply":"anlegen",
|
36
|
+
"Username":"Benutzername",
|
37
|
+
"Password":"Passwort",
|
38
|
+
"Terms of service":"Nutzungsbedingungen",
|
39
|
+
"Created by":"Erstellt von",
|
40
|
+
"See more at":"Mehr unter",
|
41
|
+
"Contact the developer":"Entwickler kontaktieren",
|
42
|
+
"api version":"API-Version",
|
43
|
+
"Response Content Type":"Response Content Type",
|
44
|
+
"Parameter content type:":"Parameter Content Type:",
|
45
|
+
"fetching resource":"Lade Ressourcen",
|
46
|
+
"fetching resource list":"Lade Liste der Ressourcen",
|
47
|
+
"Explore":"Erkunde",
|
48
|
+
"Show Swagger Petstore Example Apis":"Anzeigen der Swagger Petstore Example Apis",
|
49
|
+
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Lesen vom Server nicht möglich. Prüfen Sie die 'access-control-origin' Einstellungen.",
|
50
|
+
"Please specify the protocol for":"Bitte geben Sie das Protokoll an",
|
51
|
+
"Can't read swagger JSON from":"Swagger JSON kann nicht gelesen werden",
|
52
|
+
"Finished Loading Resource Information. Rendering Swagger UI":"Ressourceninformationen sind geladen. Rendern der Swagger UI",
|
53
|
+
"Unable to read api":"API kann nicht gelesen werden",
|
54
|
+
"from path":"von Pfad",
|
55
|
+
"server returned":"Server antwortet",
|
56
|
+
"Authorize":"Autorisieren",
|
57
|
+
"Back to the list":"Zurück zur Liste",
|
58
|
+
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"Ολοκλήρωση Φόρτωσης Πληροφορικών Πόρου. Παρουσίαση Swagger UI",
|
53
53
|
"Unable to read api":"Αδυναμία ανάγνωσης api",
|
54
54
|
"from path":"από το μονοπάτι",
|
55
|
-
"server returned":"ο εξυπηρετηρής επέστρεψε"
|
55
|
+
"server returned":"ο εξυπηρετηρής επέστρεψε",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
|
53
53
|
"Unable to read api":"Unable to read api",
|
54
54
|
"from path":"from path",
|
55
|
-
"server returned":"server returned"
|
55
|
+
"server returned":"server returned",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"Finalizada la carga del recurso de Información. Mostrando Swagger UI",
|
50
50
|
"Unable to read api":"No se puede leer la api",
|
51
51
|
"from path":"desde ruta",
|
52
|
-
"server returned":"el servidor retornó"
|
52
|
+
"server returned":"el servidor retornó",
|
53
|
+
"Authorize":"Authorize",
|
54
|
+
"Back to the list":"Volver a la lista",
|
53
55
|
});
|
@@ -50,5 +50,7 @@ window.SwaggerTranslator.learn({
|
|
50
50
|
"Finished Loading Resource Information. Rendering Swagger UI":"Chargement des informations terminé. Affichage de Swagger UI",
|
51
51
|
"Unable to read api":"Impossible de lire l'api",
|
52
52
|
"from path":"à partir du chemin",
|
53
|
-
"server returned":"réponse du serveur"
|
53
|
+
"server returned":"réponse du serveur",
|
54
|
+
"Authorize":"Authorize",
|
55
|
+
"Back to the list":"Retour à la liste",
|
54
56
|
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"რესურსების ჩატვირთვა სრულდება. Swagger UI რენდერდება",
|
53
53
|
"Unable to read api":"api წაკითხვა ვერ მოხერხდა",
|
54
54
|
"from path":"მისამართიდან",
|
55
|
-
"server returned":"სერვერმა დააბრუნა"
|
55
|
+
"server returned":"სერვერმა დააბრუნა",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -48,5 +48,7 @@ window.SwaggerTranslator.learn({
|
|
48
48
|
"Finished Loading Resource Information. Rendering Swagger UI":"Lettura informazioni risorse termianta. Swagger UI viene mostrata",
|
49
49
|
"Unable to read api":"Impossibile leggere la api",
|
50
50
|
"from path":"da cartella",
|
51
|
-
"server returned":"il server ha restituito"
|
51
|
+
"server returned":"il server ha restituito",
|
52
|
+
"Authorize":"Authorize",
|
53
|
+
"Back to the list":"Torna all'elenco",
|
52
54
|
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"リソース情報の読み込みが完了しました. Swagger UIを描画しています",
|
53
53
|
"Unable to read api":"APIを読み込めません",
|
54
54
|
"from path":"次のパスから",
|
55
|
-
"server returned":"サーバからの返答"
|
55
|
+
"server returned":"サーバからの返答",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"리소스 정보 불러오기 완료. Swagger UI 랜더링",
|
50
50
|
"Unable to read api":"api를 읽을 수 없습니다.",
|
51
51
|
"from path":"다음 경로로 부터",
|
52
|
-
"server returned":"서버 응답함."
|
52
|
+
"server returned":"서버 응답함.",
|
53
|
+
"Authorize":"Authorize",
|
54
|
+
"Back to the list":"Back to the list",
|
53
55
|
});
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"Ukończono Ładowanie Informacji o Zasobie. Renderowanie Swagger UI",
|
50
50
|
"Unable to read api":"Nie można odczytać api",
|
51
51
|
"from path":"ze ścieżki",
|
52
|
-
"server returned":"serwer zwrócił"
|
52
|
+
"server returned":"serwer zwrócił",
|
53
|
+
"Authorize": "Autoryzuj",
|
54
|
+
"Back to the list":"Powrót do listy",
|
53
55
|
});
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"Carregar informação de recurso finalizada. Renderizando Swagger UI",
|
50
50
|
"Unable to read api":"Não foi possível ler api",
|
51
51
|
"from path":"do caminho",
|
52
|
-
"server returned":"servidor retornou"
|
52
|
+
"server returned":"servidor retornou",
|
53
|
+
"Authorize":"Authorize",
|
54
|
+
"Back to the list":"Back to the list",
|
53
55
|
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим",
|
53
53
|
"Unable to read api":"Не удалось прочитать api",
|
54
54
|
"from path":"по адресу",
|
55
|
-
"server returned":"сервер сказал"
|
55
|
+
"server returned":"сервер сказал",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -49,5 +49,7 @@ window.SwaggerTranslator.learn({
|
|
49
49
|
"Finished Loading Resource Information. Rendering Swagger UI":"Kaynak baglantısı tamamlandı. Swagger UI gösterime hazırlanıyor",
|
50
50
|
"Unable to read api":"api okunamadı",
|
51
51
|
"from path":"yoldan",
|
52
|
-
"server returned":"sunucuya dönüldü"
|
52
|
+
"server returned":"sunucuya dönüldü",
|
53
|
+
"Authorize":"Authorize",
|
54
|
+
"Back to the list":"Back to the list",
|
53
55
|
});
|
@@ -52,5 +52,7 @@ window.SwaggerTranslator.learn({
|
|
52
52
|
"Finished Loading Resource Information. Rendering Swagger UI":"已加载资源信息。正在渲染Swagger UI",
|
53
53
|
"Unable to read api":"无法读取api",
|
54
54
|
"from path":"从路径",
|
55
|
-
"server returned":"服务器返回"
|
55
|
+
"server returned":"服务器返回",
|
56
|
+
"Authorize":"Authorize",
|
57
|
+
"Back to the list":"Back to the list",
|
56
58
|
});
|
@@ -1 +1 @@
|
|
1
|
-
function handleLogin(){var e=[],o=window.swaggerUiAuth.authSchemes||window.swaggerUiAuth.securityDefinitions;if(o){var i,n=o;for(i in n){var a=n[i];if("oauth2"===a.type&&a.scopes){var t;if(Array.isArray(a.scopes)){var p;for(p=0;p<a.scopes.length;p++)e.push(a.scopes[p])}else for(t in a.scopes)e.push({scope:t,description:a.scopes[t],OAuthSchemeKey:i})}}}for(window.swaggerUi.api&&window.swaggerUi.api.info&&(appName=window.swaggerUi.api.info.title),$(".api-popup-dialog").remove(),popupDialog=$(['<div class="api-popup-dialog">','<div class="api-popup-title">Select OAuth2.0 Scopes</div>','<div class="api-popup-content">',"<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.",'<a href="#">Learn how to use</a>',"</p>","<p><strong>"+appName+"</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>",'<ul class="api-popup-scopes">',"</ul>",'<p class="error-msg"></p>','<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',"</div>","</div>"].join("")),$(document.body).append(popupDialog),popup=popupDialog.find("ul.api-popup-scopes").empty(),p=0;p<e.length;p++)t=e[p],str='<li><input type="checkbox" id="scope_'+p+'" scope="'+t.scope+'"" oauthtype="'+t.OAuthSchemeKey+'"/><label for="scope_'+p+'">'+t.scope,t.description&&($.map(o,function(e,o){return o}).length>1?str+='<br/><span class="api-scope-desc">'+t.description+" ("+t.OAuthSchemeKey+")</span>":str+='<br/><span class="api-scope-desc">'+t.description+"</span>"),str+="</label></li>",popup.append(str);var r=$(window),s=r.width(),c=r.height(),l=r.scrollTop(),d=popupDialog.outerWidth(),u=popupDialog.outerHeight(),h=(c-u)/2+l,g=(s-d)/2;popupDialog.css({top:(h<0?0:h)+"px",left:(g<0?0:g)+"px"}),popupDialog.find("button.api-popup-cancel").click(function(){popupMask.hide(),popupDialog.hide(),popupDialog.empty(),popupDialog=[]}),$("button.api-popup-authbtn").unbind(),popupDialog.find("button.api-popup-authbtn").click(function(){function e(e){return e.vendorExtensions["x-tokenName"]||e.tokenName}popupMask.hide(),popupDialog.hide();var o,i=window.swaggerUi.api.authSchemes,n=window.location,a=location.pathname.substring(0,location.pathname.lastIndexOf("/")),t=n.protocol+"//"+n.host+a+"/o2c.html",p=window.oAuthRedirectUrl||t,r=null,s=[],c=popup.find("input:checked"),l=[];for(k=0;k<c.length;k++){var d=$(c[k]).attr("scope");s.indexOf(d)===-1&&s.push(d);var u=$(c[k]).attr("oauthtype");l.indexOf(u)===-1&&l.push(u)}window.enabledScopes=s;for(var h in i)if(i.hasOwnProperty(h)&&l.indexOf(h)!=-1){var g=i[h].flow;if("oauth2"!==i[h].type||!g||"implicit"!==g&&"accessCode"!==g){if("oauth2"===i[h].type&&g&&"application"===g){var w=i[h];return window.swaggerUi.tokenName=e(w)||"access_token",void clientCredentialsFlow(s,w.tokenUrl,h)}if(i[h].grantTypes){var c=i[h].grantTypes;for(var f in c)if(c.hasOwnProperty(f)&&"implicit"===f){var w=c[f];w.loginEndpoint.url;r=w.loginEndpoint.url+"?response_type=token",window.swaggerUi.tokenName=e(w)}else if(c.hasOwnProperty(f)&&"accessCode"===f){var w=c[f];w.tokenRequestEndpoint.url;r=w.tokenRequestEndpoint.url+"?response_type=code",window.swaggerUi.tokenName=e(w)}}}else{var w=i[h];r=w.authorizationUrl+"?response_type="+("implicit"===g?"token":"code"),window.swaggerUi.tokenName=e(w)||"access_token",window.swaggerUi.tokenUrl="accessCode"===g?w.tokenUrl:null,o=h}}redirect_uri=p,r+="&redirect_uri="+encodeURIComponent(p),r+="&realm="+encodeURIComponent(realm),r+="&client_id="+encodeURIComponent(clientId),r+="&scope="+encodeURIComponent(s.join(scopeSeparator)),r+="&state="+encodeURIComponent(o);for(var h in additionalQueryStringParams)r+="&"+h+"="+encodeURIComponent(additionalQueryStringParams[h]);window.open(r)}),popupMask.show(),popupDialog.show()}function handleLogout(){for(key in window.swaggerUi.api.clientAuthorizations.authz)window.swaggerUi.api.clientAuthorizations.remove(key);window.enabledScopes=null,$(".api-ic.ic-on").addClass("ic-off"),$(".api-ic.ic-on").removeClass("ic-on"),$(".api-ic.ic-warning").addClass("ic-error"),$(".api-ic.ic-warning").removeClass("ic-warning")}function initOAuth(e){var o=e||{},i=[];return appName=o.appName||i.push("missing appName"),popupMask=o.popupMask||$("#api-common-mask"),popupDialog=o.popupDialog||$(".api-popup-dialog"),clientId=o.clientId||i.push("missing client id"),clientSecret=o.clientSecret||null,realm=o.realm||i.push("missing realm"),scopeSeparator=o.scopeSeparator||" ",additionalQueryStringParams=o.additionalQueryStringParams||{},i.length>0?void log("auth unable initialize oauth: "+i):($("pre code").each(function(e,o){hljs.highlightBlock(o)}),$(".api-ic").unbind(),void $(".api-ic").click(function(e){$(e.target).hasClass("ic-off")?handleLogin():handleLogout()}))}function clientCredentialsFlow(e,o,i){var n={client_id:clientId,client_secret:clientSecret,scope:e.join(" "),grant_type:"client_credentials"};$.ajax({url:o,type:"POST",data:n,success:function(e,o,n){onOAuthComplete(e,i)},error:function(e,o,i){onOAuthComplete("")}})}var appName,popupMask,popupDialog,clientId,realm,redirect_uri,clientSecret,scopeSeparator,additionalQueryStringParams;window.processOAuthCode=function(e){var o=e.state,i=window.location,n=location.pathname.substring(0,location.pathname.lastIndexOf("/")),a=i.protocol+"//"+i.host+n+"/o2c.html",t=window.oAuthRedirectUrl||a,p={client_id:clientId,code:e.code,grant_type:"authorization_code",redirect_uri:t};clientSecret&&(p.client_secret=clientSecret),$.ajax({url:window.swaggerUiAuth.tokenUrl,type:"POST",data:p,success:function(e,i,n){onOAuthComplete(e,o)},error:function(e,o,i){onOAuthComplete("")}})},window.onOAuthComplete=function(e,o){if(e)if(e.error){var i=$("input[type=checkbox],.secured");i.each(function(e){i[e].checked=!1}),alert(e.error)}else{var n=e[window.swaggerUiAuth.tokenName];if(o||(o=e.state),n){var a=null;$.each($(".auth .api-ic .api_information_panel"),function(e,o){var i=o;if(i&&i.childNodes){var n=[];$.each(i.childNodes,function(e,o){var i=o.innerHTML;i&&n.push(i)});for(var t=[],p=0;p<n.length;p++){var r=n[p];window.enabledScopes&&window.enabledScopes.indexOf(r)==-1&&t.push(r)}t.length>0?(a=o.parentNode.parentNode,$(a.parentNode).find(".api-ic.ic-on").addClass("ic-off"),$(a.parentNode).find(".api-ic.ic-on").removeClass("ic-on"),$(a).find(".api-ic").addClass("ic-warning"),$(a).find(".api-ic").removeClass("ic-error")):(a=o.parentNode.parentNode,$(a.parentNode).find(".api-ic.ic-off").addClass("ic-on"),$(a.parentNode).find(".api-ic.ic-off").removeClass("ic-off"),$(a).find(".api-ic").addClass("ic-info"),$(a).find(".api-ic").removeClass("ic-warning"),$(a).find(".api-ic").removeClass("ic-error"))}}),"undefined"!=typeof window.swaggerUi&&(window.swaggerUi.api.clientAuthorizations.add(window.swaggerUiAuth.OAuthSchemeKey,new SwaggerClient.ApiKeyAuthorization("Authorization","Bearer "+n,"header")),window.swaggerUi.load())}}};
|
1
|
+
function handleLogin(){var e=[],o=window.swaggerUiAuth.authSchemes||window.swaggerUiAuth.securityDefinitions;if(o){var i,n=o;for(i in n){var a=n[i];if("oauth2"===a.type&&a.scopes){var t;if(Array.isArray(a.scopes)){var p;for(p=0;p<a.scopes.length;p++)e.push(a.scopes[p])}else for(t in a.scopes)e.push({scope:t,description:a.scopes[t],OAuthSchemeKey:i})}}}for(window.swaggerUi.api&&window.swaggerUi.api.info&&(appName=window.swaggerUi.api.info.title),$(".api-popup-dialog").remove(),popupDialog=$(['<div class="api-popup-dialog">','<div class="api-popup-title">Select OAuth2.0 Scopes</div>','<div class="api-popup-content">',"<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.",'<a href="#">Learn how to use</a>',"</p>","<p><strong>"+appName+"</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>",'<ul class="api-popup-scopes">',"</ul>",'<p class="error-msg"></p>','<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button" data-sw-translate>Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',"</div>","</div>"].join("")),$(document.body).append(popupDialog),popup=popupDialog.find("ul.api-popup-scopes").empty(),p=0;p<e.length;p++)t=e[p],str='<li><input type="checkbox" id="scope_'+p+'" scope="'+t.scope+'"" oauthtype="'+t.OAuthSchemeKey+'"/><label for="scope_'+p+'">'+t.scope,t.description&&($.map(o,function(e,o){return o}).length>1?str+='<br/><span class="api-scope-desc">'+t.description+" ("+t.OAuthSchemeKey+")</span>":str+='<br/><span class="api-scope-desc">'+t.description+"</span>"),str+="</label></li>",popup.append(str);var r=$(window),s=r.width(),c=r.height(),l=r.scrollTop(),d=popupDialog.outerWidth(),u=popupDialog.outerHeight(),h=(c-u)/2+l,g=(s-d)/2;popupDialog.css({top:(h<0?0:h)+"px",left:(g<0?0:g)+"px"}),popupDialog.find("button.api-popup-cancel").click(function(){popupMask.hide(),popupDialog.hide(),popupDialog.empty(),popupDialog=[]}),$("button.api-popup-authbtn").unbind(),popupDialog.find("button.api-popup-authbtn").click(function(){function e(e){return e.vendorExtensions["x-tokenName"]||e.tokenName}popupMask.hide(),popupDialog.hide();var o,i=window.swaggerUi.api.authSchemes,n=window.location,a=location.pathname.substring(0,location.pathname.lastIndexOf("/")),t=n.protocol+"//"+n.host+a+"/o2c.html",p=window.oAuthRedirectUrl||t,r=null,s=[],c=popup.find("input:checked"),l=[];for(k=0;k<c.length;k++){var d=$(c[k]).attr("scope");s.indexOf(d)===-1&&s.push(d);var u=$(c[k]).attr("oauthtype");l.indexOf(u)===-1&&l.push(u)}window.enabledScopes=s;for(var h in i)if(i.hasOwnProperty(h)&&l.indexOf(h)!=-1){var g=i[h].flow;if("oauth2"!==i[h].type||!g||"implicit"!==g&&"accessCode"!==g){if("oauth2"===i[h].type&&g&&"application"===g){var w=i[h];return window.swaggerUi.tokenName=e(w)||"access_token",void clientCredentialsFlow(s,w.tokenUrl,h)}if(i[h].grantTypes){var c=i[h].grantTypes;for(var f in c)if(c.hasOwnProperty(f)&&"implicit"===f){var w=c[f];w.loginEndpoint.url;r=w.loginEndpoint.url+"?response_type=token",window.swaggerUi.tokenName=e(w)}else if(c.hasOwnProperty(f)&&"accessCode"===f){var w=c[f];w.tokenRequestEndpoint.url;r=w.tokenRequestEndpoint.url+"?response_type=code",window.swaggerUi.tokenName=e(w)}}}else{var w=i[h];r=w.authorizationUrl+"?response_type="+("implicit"===g?"token":"code"),window.swaggerUi.tokenName=e(w)||"access_token",window.swaggerUi.tokenUrl="accessCode"===g?w.tokenUrl:null,o=h}}redirect_uri=p,r+="&redirect_uri="+encodeURIComponent(p),r+="&realm="+encodeURIComponent(realm),r+="&client_id="+encodeURIComponent(clientId),r+="&scope="+encodeURIComponent(s.join(scopeSeparator)),r+="&state="+encodeURIComponent(o);for(var h in additionalQueryStringParams)r+="&"+h+"="+encodeURIComponent(additionalQueryStringParams[h]);window.open(r)}),popupMask.show(),popupDialog.show()}function handleLogout(){for(key in window.swaggerUi.api.clientAuthorizations.authz)window.swaggerUi.api.clientAuthorizations.remove(key);window.enabledScopes=null,$(".api-ic.ic-on").addClass("ic-off"),$(".api-ic.ic-on").removeClass("ic-on"),$(".api-ic.ic-warning").addClass("ic-error"),$(".api-ic.ic-warning").removeClass("ic-warning")}function initOAuth(e){var o=e||{},i=[];return appName=o.appName||i.push("missing appName"),popupMask=o.popupMask||$("#api-common-mask"),popupDialog=o.popupDialog||$(".api-popup-dialog"),clientId=o.clientId||i.push("missing client id"),clientSecret=o.clientSecret||null,realm=o.realm||i.push("missing realm"),scopeSeparator=o.scopeSeparator||" ",additionalQueryStringParams=o.additionalQueryStringParams||{},i.length>0?void log("auth unable initialize oauth: "+i):($("pre code").each(function(e,o){hljs.highlightBlock(o)}),$(".api-ic").unbind(),void $(".api-ic").click(function(e){$(e.target).hasClass("ic-off")?handleLogin():handleLogout()}))}function clientCredentialsFlow(e,o,i){var n={client_id:clientId,client_secret:clientSecret,scope:e.join(" "),grant_type:"client_credentials"};$.ajax({url:o,type:"POST",data:n,success:function(e,o,n){onOAuthComplete(e,i)},error:function(e,o,i){onOAuthComplete("")}})}var appName,popupMask,popupDialog,clientId,realm,redirect_uri,clientSecret,scopeSeparator,additionalQueryStringParams;window.processOAuthCode=function(e){var o=e.state,i=window.location,n=location.pathname.substring(0,location.pathname.lastIndexOf("/")),a=i.protocol+"//"+i.host+n+"/o2c.html",t=window.oAuthRedirectUrl||a,p={client_id:clientId,code:e.code,grant_type:"authorization_code",redirect_uri:t};clientSecret&&(p.client_secret=clientSecret),$.ajax({url:window.swaggerUiAuth.tokenUrl,type:"POST",data:p,success:function(e,i,n){onOAuthComplete(e,o)},error:function(e,o,i){onOAuthComplete("")}})},window.onOAuthComplete=function(e,o){if(e)if(e.error){var i=$("input[type=checkbox],.secured");i.each(function(e){i[e].checked=!1}),alert(e.error)}else{var n=e[window.swaggerUiAuth.tokenName];if(o||(o=e.state),n){var a=null;$.each($(".auth .api-ic .api_information_panel"),function(e,o){var i=o;if(i&&i.childNodes){var n=[];$.each(i.childNodes,function(e,o){var i=o.innerHTML;i&&n.push(i)});for(var t=[],p=0;p<n.length;p++){var r=n[p];window.enabledScopes&&window.enabledScopes.indexOf(r)==-1&&t.push(r)}t.length>0?(a=o.parentNode.parentNode,$(a.parentNode).find(".api-ic.ic-on").addClass("ic-off"),$(a.parentNode).find(".api-ic.ic-on").removeClass("ic-on"),$(a).find(".api-ic").addClass("ic-warning"),$(a).find(".api-ic").removeClass("ic-error")):(a=o.parentNode.parentNode,$(a.parentNode).find(".api-ic.ic-off").addClass("ic-on"),$(a.parentNode).find(".api-ic.ic-off").removeClass("ic-off"),$(a).find(".api-ic").addClass("ic-info"),$(a).find(".api-ic").removeClass("ic-warning"),$(a).find(".api-ic").removeClass("ic-error"))}}),"undefined"!=typeof window.swaggerUi&&(window.swaggerUi.api.clientAuthorizations.add(window.swaggerUiAuth.OAuthSchemeKey,new SwaggerClient.ApiKeyAuthorization("Authorization","Bearer "+n,"header")),window.swaggerUi.load())}}};
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* @link http://swagger.io
|
5
5
|
* @license Apache-2.0
|
6
6
|
*/
|
7
|
-
(function(){/* jshint ignore:start */
|
7
|
+
(function(){/* jshint ignore:start */
|
8
8
|
{(function() {
|
9
9
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
10
10
|
templates['apikey_auth'] = template({"1":function(container,depth0,helpers,partials,data) {
|
@@ -29,7 +29,7 @@ templates['apikey_auth'] = template({"1":function(container,depth0,helpers,parti
|
|
29
29
|
+ " </div>\n </div>\n</div>\n";
|
30
30
|
},"useData":true});
|
31
31
|
templates['auth_button'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
32
|
-
return "<a class='authorize__btn' href=\"#\">Authorize</a>\n";
|
32
|
+
return "<a class='authorize__btn' href=\"#\" data-sw-translate>Authorize</a>\n";
|
33
33
|
},"useData":true});
|
34
34
|
templates['auth_button_operation'] = template({"1":function(container,depth0,helpers,partials,data) {
|
35
35
|
return " authorize__btn_operation_login\n";
|
@@ -685,7 +685,7 @@ templates['resource'] = template({"1":function(container,depth0,helpers,partials
|
|
685
685
|
+ ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.url : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "")
|
686
686
|
+ "' data-sw-translate>Raw</a>\n </li>\n";
|
687
687
|
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
688
|
-
var stack1, helper, options, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, buffer =
|
688
|
+
var stack1, helper, options, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, buffer =
|
689
689
|
"<div class='heading'>\n <h2>\n <a href='#!/"
|
690
690
|
+ ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.id : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "")
|
691
691
|
+ "' class=\"toggleEndpointList\" data-id=\""
|
@@ -797,7 +797,7 @@ templates['status_code'] = template({"1":function(container,depth0,helpers,parti
|
|
797
797
|
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.headers : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
798
798
|
+ " </tbody>\n </table>\n</td>";
|
799
799
|
},"useData":true});
|
800
|
-
})();}
|
800
|
+
})();}
|
801
801
|
/* jshint ignore:end */
|
802
802
|
'use strict';
|
803
803
|
|
@@ -24827,7 +24827,7 @@ SwaggerUi.partials.signature = (function () {
|
|
24827
24827
|
return result;
|
24828
24828
|
};
|
24829
24829
|
*/
|
24830
|
-
|
24830
|
+
|
24831
24831
|
var getPrefix = function (name, xml) {
|
24832
24832
|
var result = name || '';
|
24833
24833
|
|
@@ -24965,7 +24965,7 @@ SwaggerUi.partials.signature = (function () {
|
|
24965
24965
|
|
24966
24966
|
if (namespace) {
|
24967
24967
|
attrs.push(namespace);
|
24968
|
-
}
|
24968
|
+
}
|
24969
24969
|
|
24970
24970
|
if (!properties && !additionalProperties) { return getErrorMessage(); }
|
24971
24971
|
|
@@ -25010,10 +25010,10 @@ SwaggerUi.partials.signature = (function () {
|
|
25010
25010
|
var output, index;
|
25011
25011
|
config = config || {};
|
25012
25012
|
config.modelsToIgnore = config.modelsToIgnore || [];
|
25013
|
-
|
25013
|
+
|
25014
25014
|
var descriptor = _.isString($ref) ? getDescriptorByRef($ref, name, models, config)
|
25015
25015
|
: getDescriptor(name, definition, models, config);
|
25016
|
-
|
25016
|
+
|
25017
25017
|
if (!descriptor) {
|
25018
25018
|
return getErrorMessage();
|
25019
25019
|
}
|
@@ -25064,7 +25064,7 @@ SwaggerUi.partials.signature = (function () {
|
|
25064
25064
|
else {
|
25065
25065
|
name = name || model.name;
|
25066
25066
|
}
|
25067
|
-
|
25067
|
+
|
25068
25068
|
if (config.modelsToIgnore.indexOf($ref) > -1) {
|
25069
25069
|
type = 'loop';
|
25070
25070
|
config.loopTo = modelType;
|
@@ -25075,7 +25075,7 @@ SwaggerUi.partials.signature = (function () {
|
|
25075
25075
|
if (!model.definition) {
|
25076
25076
|
return null;
|
25077
25077
|
}
|
25078
|
-
return new Descriptor(name, type, model.definition, models, config);
|
25078
|
+
return new Descriptor(name, type, model.definition, models, config);
|
25079
25079
|
}
|
25080
25080
|
|
25081
25081
|
function getDescriptor (name, definition, models, config){
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module SwaggerUiEngine
|
2
2
|
class DocsController < ApplicationController
|
3
|
-
include ConfigParser
|
4
|
-
include
|
3
|
+
include SwaggerUiEngine::ConfigParser
|
4
|
+
include SwaggerUiEngine::OauthConfigParser
|
5
|
+
include SwaggerUiEngine::SwaggerUiDefaults
|
5
6
|
|
6
|
-
before_action :set_configs
|
7
|
+
before_action :set_configs, :set_oauth_configs
|
8
|
+
|
9
|
+
def oauth2
|
10
|
+
end
|
7
11
|
|
8
12
|
def index
|
9
13
|
# backward compatibility for defining single doc url in strings
|
@@ -12,6 +16,7 @@ module SwaggerUiEngine
|
|
12
16
|
end
|
13
17
|
|
14
18
|
def show
|
19
|
+
@single_doc_url = single_doc_url? || single_doc_url_hash?
|
15
20
|
@swagger_url = @swagger_url[params[:id].to_sym] unless single_doc_url?
|
16
21
|
end
|
17
22
|
|
@@ -26,6 +31,15 @@ module SwaggerUiEngine
|
|
26
31
|
@validator_url = set_validator_url
|
27
32
|
end
|
28
33
|
|
34
|
+
def set_oauth_configs
|
35
|
+
@oauth_app_name = set_oauth_app_name
|
36
|
+
@oauth_client_id = set_oauth_client_id
|
37
|
+
@oauth_client_secret = set_oauth_client_secret
|
38
|
+
@oauth_realm = set_oauth_realm
|
39
|
+
@oauth_query_string_params = set_oauth_query_string_params
|
40
|
+
@oauth_scope_separator = set_oauth_scope_separator
|
41
|
+
end
|
42
|
+
|
29
43
|
def single_doc_url?
|
30
44
|
@swagger_url.is_a?(String)
|
31
45
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module AuthConfigParser
|
3
|
+
def admin_username
|
4
|
+
configuration.admin_username
|
5
|
+
end
|
6
|
+
|
7
|
+
def admin_password
|
8
|
+
configuration.admin_password
|
9
|
+
end
|
10
|
+
|
11
|
+
def basic_authentication_enabled?
|
12
|
+
admin_username && admin_password
|
13
|
+
end
|
14
|
+
|
15
|
+
def configuration
|
16
|
+
SwaggerUiEngine.configuration
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module ConfigParser
|
3
|
+
def set_doc_expansion
|
4
|
+
configuration.doc_expansion || default_doc_expansion
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_json_editor
|
8
|
+
configuration.json_editor || default_json_editor
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_model_rendering
|
12
|
+
configuration.model_rendering || default_model_rendering
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_request_headers
|
16
|
+
configuration.request_headers || default_request_headers
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_show_operation_ids
|
20
|
+
configuration.show_operation_ids || default_show_operation_ids
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_swagger_url
|
24
|
+
configuration.swagger_url || default_swagger_url
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_validator_url
|
28
|
+
validator_enabled ? default_validator_url : 'null'
|
29
|
+
end
|
30
|
+
|
31
|
+
def validator_enabled
|
32
|
+
configuration.validator_enabled || false
|
33
|
+
end
|
34
|
+
|
35
|
+
def configuration
|
36
|
+
SwaggerUiEngine.configuration
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module OauthConfigParser
|
3
|
+
def set_oauth_app_name
|
4
|
+
configuration.oauth_app_name || 'your-app-name'
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_oauth_client_id
|
8
|
+
configuration.oauth_client_id || 'your-client-id'
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_oauth_client_secret
|
12
|
+
configuration.oauth_client_secret || 'your-client-secret-if-required'
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_oauth_realm
|
16
|
+
configuration.oauth_realm || 'your-realms'
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_oauth_scope_separator
|
20
|
+
configuration.oauth_scope_separator || ' '
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_oauth_query_string_params
|
24
|
+
configuration.oauth_query_string_params || {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def configuration
|
28
|
+
SwaggerUiEngine.configuration
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module SwaggerUiDefaults
|
3
|
+
def default_swagger_url
|
4
|
+
'http://petstore.swagger.io/v2/swagger.json'
|
5
|
+
end
|
6
|
+
|
7
|
+
def default_doc_expansion
|
8
|
+
'none'
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_json_editor
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_model_rendering
|
16
|
+
'schema'
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_request_headers
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_validator_url
|
24
|
+
'//online.swagger.io/validator'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module TranslationHelper
|
3
|
+
def load_translation_file
|
4
|
+
return unless translator_enabled?
|
5
|
+
javascript_include_tag('swagger_ui_engine/lang/translator', lang_file_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def lang_file_path
|
9
|
+
"swagger_ui_engine/lang/#{I18n.locale.to_s.downcase}.js"
|
10
|
+
end
|
11
|
+
|
12
|
+
def translator_enabled?
|
13
|
+
SwaggerUiEngine.configuration.translator_enabled
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -11,6 +11,7 @@
|
|
11
11
|
<%= stylesheet_link_tag "swagger_ui_engine/print", media: "print" %>
|
12
12
|
|
13
13
|
<%= javascript_include_tag "swagger_ui_engine/application" %>
|
14
|
+
<%= load_translation_file %>
|
14
15
|
<%= csrf_meta_tags %>
|
15
16
|
|
16
17
|
<script type="text/javascript">
|
@@ -33,17 +34,18 @@
|
|
33
34
|
window.swaggerUi = new SwaggerUi({
|
34
35
|
url: url,
|
35
36
|
validatorUrl: "<%= @validator_url %>",
|
37
|
+
oauth2RedirectUrl: "<%= oauth2_docs_path %>",
|
36
38
|
dom_id: "swagger-ui-container",
|
37
39
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
38
40
|
onComplete: function(swaggerApi, swaggerUi){
|
39
41
|
if(typeof initOAuth == "function") {
|
40
42
|
initOAuth({
|
41
|
-
clientId: "
|
42
|
-
clientSecret: "
|
43
|
-
realm: "
|
44
|
-
appName: "
|
45
|
-
scopeSeparator: " ",
|
46
|
-
additionalQueryStringParams:
|
43
|
+
clientId: "<%= @oauth_client_id %>",
|
44
|
+
clientSecret: "<%= @oauth_client_secret %>",
|
45
|
+
realm: "<%= @oauth_realm %>",
|
46
|
+
appName: "<%= @oauth_app_name %>",
|
47
|
+
scopeSeparator: "<%= @oauth_scope_separator %>",
|
48
|
+
additionalQueryStringParams: "<%= @oauth_query_string_params %>"
|
47
49
|
});
|
48
50
|
}
|
49
51
|
|
@@ -86,5 +88,10 @@
|
|
86
88
|
|
87
89
|
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate> </div>
|
88
90
|
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
91
|
+
<% unless @single_doc_url %>
|
92
|
+
<div class="swagger-ui-wrap">
|
93
|
+
<a href="<%= docs_path %>" class="swagger-return-link" data-sw-translate>Back to the list</a>
|
94
|
+
</div>
|
95
|
+
<% end %>
|
89
96
|
</body>
|
90
97
|
</html>
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
SwaggerUiEngine::Engine.routes.draw do
|
2
2
|
scope format: false do
|
3
|
-
resources :docs, only: [:index, :show]
|
3
|
+
resources :docs, only: [:index, :show] do
|
4
|
+
collection do
|
5
|
+
get 'oauth2', to: 'docs#oauth2', format: false
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
4
9
|
root to: 'docs#index'
|
5
10
|
end
|
6
11
|
end
|
@@ -7,8 +7,15 @@ module SwaggerUiEngine
|
|
7
7
|
:doc_expansion,
|
8
8
|
:json_editor,
|
9
9
|
:model_rendering,
|
10
|
+
:oauth_client_id,
|
11
|
+
:oauth_client_secret,
|
12
|
+
:oauth_realm,
|
13
|
+
:oauth_app_name,
|
14
|
+
:oauth_scope_separator,
|
15
|
+
:oauth_query_string_params,
|
10
16
|
:request_headers,
|
11
17
|
:swagger_url,
|
18
|
+
:translator_enabled,
|
12
19
|
:validator_enabled,
|
13
20
|
].freeze
|
14
21
|
|
@@ -8,10 +8,12 @@ module SwaggerUiEngine
|
|
8
8
|
swagger_ui_engine/lib/reset.css
|
9
9
|
swagger_ui_engine/lib/screen.css
|
10
10
|
swagger_ui_engine/lib/print.css
|
11
|
+
swagger_ui_engine/custom.css
|
11
12
|
swagger_ui_engine/print.css
|
12
13
|
swagger_ui_engine/logo_small.png
|
13
14
|
swagger_ui_engine/favicon-32x32.png
|
14
15
|
swagger_ui_engine/favicon-16x16.png
|
16
|
+
swagger_ui_engine/lang/*.js
|
15
17
|
)
|
16
18
|
|
17
19
|
Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_ui_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZuzannaSt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- app/assets/images/swagger_ui_engine/wordnik_api.png
|
56
56
|
- app/assets/javascripts/swagger_ui_engine/application.js
|
57
57
|
- app/assets/javascripts/swagger_ui_engine/lang/ca.js
|
58
|
+
- app/assets/javascripts/swagger_ui_engine/lang/de.js
|
58
59
|
- app/assets/javascripts/swagger_ui_engine/lang/el.js
|
59
60
|
- app/assets/javascripts/swagger_ui_engine/lang/en.js
|
60
61
|
- app/assets/javascripts/swagger_ui_engine/lang/es.js
|
@@ -85,11 +86,11 @@ files:
|
|
85
86
|
- app/assets/javascripts/swagger_ui_engine/lib/object-assign-pollyfill.js
|
86
87
|
- app/assets/javascripts/swagger_ui_engine/lib/sanitize-html.min.js
|
87
88
|
- app/assets/javascripts/swagger_ui_engine/lib/swagger-oauth.js
|
88
|
-
- app/assets/javascripts/swagger_ui_engine/o2c.html
|
89
89
|
- app/assets/javascripts/swagger_ui_engine/swagger-ui.js
|
90
90
|
- app/assets/javascripts/swagger_ui_engine/swagger-ui.min.js
|
91
91
|
- app/assets/javascripts/swagger_ui_engine/swagger.json
|
92
92
|
- app/assets/stylesheets/swagger_ui_engine/application.css
|
93
|
+
- app/assets/stylesheets/swagger_ui_engine/custom.css
|
93
94
|
- app/assets/stylesheets/swagger_ui_engine/lib/print.css.erb
|
94
95
|
- app/assets/stylesheets/swagger_ui_engine/lib/reset.css
|
95
96
|
- app/assets/stylesheets/swagger_ui_engine/lib/screen.css.erb
|
@@ -98,10 +99,13 @@ files:
|
|
98
99
|
- app/assets/stylesheets/swagger_ui_engine/print.css
|
99
100
|
- app/controllers/swagger_ui_engine/application_controller.rb
|
100
101
|
- app/controllers/swagger_ui_engine/docs_controller.rb
|
101
|
-
- app/helpers/auth_config_parser.rb
|
102
|
-
- app/helpers/config_parser.rb
|
103
|
-
- app/helpers/
|
102
|
+
- app/helpers/swagger_ui_engine/auth_config_parser.rb
|
103
|
+
- app/helpers/swagger_ui_engine/config_parser.rb
|
104
|
+
- app/helpers/swagger_ui_engine/oauth_config_parser.rb
|
105
|
+
- app/helpers/swagger_ui_engine/swagger_ui_defaults.rb
|
106
|
+
- app/helpers/swagger_ui_engine/translation_helper.rb
|
104
107
|
- app/views/swagger_ui_engine/docs/index.html.erb
|
108
|
+
- app/views/swagger_ui_engine/docs/ouath2.html.erb
|
105
109
|
- app/views/swagger_ui_engine/docs/show.html.erb
|
106
110
|
- config/routes.rb
|
107
111
|
- lib/swagger_ui_engine.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module AuthConfigParser
|
2
|
-
def admin_username
|
3
|
-
configuration.admin_username
|
4
|
-
end
|
5
|
-
|
6
|
-
def admin_password
|
7
|
-
configuration.admin_password
|
8
|
-
end
|
9
|
-
|
10
|
-
def basic_authentication_enabled?
|
11
|
-
admin_username && admin_password
|
12
|
-
end
|
13
|
-
|
14
|
-
def configuration
|
15
|
-
SwaggerUiEngine.configuration
|
16
|
-
end
|
17
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ConfigParser
|
2
|
-
def set_doc_expansion
|
3
|
-
configuration.doc_expansion || default_doc_expansion
|
4
|
-
end
|
5
|
-
|
6
|
-
def set_json_editor
|
7
|
-
configuration.json_editor || default_json_editor
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_model_rendering
|
11
|
-
configuration.model_rendering || default_model_rendering
|
12
|
-
end
|
13
|
-
|
14
|
-
def set_request_headers
|
15
|
-
configuration.request_headers || default_request_headers
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_show_operation_ids
|
19
|
-
configuration.show_operation_ids || default_show_operation_ids
|
20
|
-
end
|
21
|
-
|
22
|
-
def set_swagger_url
|
23
|
-
configuration.swagger_url || default_swagger_url
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_validator_url
|
27
|
-
validator_enabled ? default_validator_url : 'null'
|
28
|
-
end
|
29
|
-
|
30
|
-
def validator_enabled
|
31
|
-
configuration.validator_enabled || false
|
32
|
-
end
|
33
|
-
|
34
|
-
def configuration
|
35
|
-
SwaggerUiEngine.configuration
|
36
|
-
end
|
37
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module SwaggerUiDefaults
|
2
|
-
def default_swagger_url
|
3
|
-
'http://petstore.swagger.io/v2/swagger.json'
|
4
|
-
end
|
5
|
-
|
6
|
-
def default_doc_expansion
|
7
|
-
'none'
|
8
|
-
end
|
9
|
-
|
10
|
-
def default_model_rendering
|
11
|
-
'schema'
|
12
|
-
end
|
13
|
-
|
14
|
-
def default_json_editor
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def default_request_headers
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def default_validator_url
|
23
|
-
'//online.swagger.io/validator'
|
24
|
-
end
|
25
|
-
end
|