├── config
├── .gitkeep
├── local
│ └── swaggervel.php
└── swagger.php
├── tests
└── .gitkeep
├── resources
└── views
│ ├── .gitkeep
│ └── index.blade.php
├── public
├── images
│ ├── favicon.ico
│ ├── throbber.gif
│ ├── logo_small.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── pet_store_api.png
│ ├── wordnik_api.png
│ └── explorer_icons.png
├── fonts
│ ├── droid-sans-v6-latin-700.eot
│ ├── droid-sans-v6-latin-700.ttf
│ ├── droid-sans-v6-latin-700.woff
│ ├── droid-sans-v6-latin-700.woff2
│ ├── droid-sans-v6-latin-regular.eot
│ ├── droid-sans-v6-latin-regular.ttf
│ ├── droid-sans-v6-latin-regular.woff
│ └── droid-sans-v6-latin-regular.woff2
├── lib
│ ├── jquery.slideto.min.js
│ ├── jquery.wiggle.min.js
│ ├── jquery.ba-bbq.min.js
│ ├── highlight.7.3.pack.js
│ ├── swagger-oauth.js
│ ├── underscore-min.js
│ ├── backbone-min.js
│ ├── underscore-min.map
│ ├── marked.js
│ └── handlebars-2.0.0.js
├── o2c.html
├── lang
│ ├── translator.js
│ ├── zh-CN.js
│ └── en.js
└── css
│ ├── typography.css
│ ├── reset.css
│ └── style.css
├── .travis.yml
├── .gitattributes
├── phpunit.xml
├── composer.json
├── .gitignore
├── README.md
└── src
├── SwaggervelServiceProvider.php
└── routes.php
/config/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/resources/views/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/favicon.ico
--------------------------------------------------------------------------------
/public/images/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/throbber.gif
--------------------------------------------------------------------------------
/public/images/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/logo_small.png
--------------------------------------------------------------------------------
/public/images/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/favicon-16x16.png
--------------------------------------------------------------------------------
/public/images/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/favicon-32x32.png
--------------------------------------------------------------------------------
/public/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/pet_store_api.png
--------------------------------------------------------------------------------
/public/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helei112g/laravel-swagger/HEAD/public/images/wordnik_api.png
--------------------------------------------------------------------------------
/config/local/swaggervel.php:
--------------------------------------------------------------------------------
1 |
2 | var qp = null;
3 | if(window.location.hash) {
4 | qp = location.hash.substring(1);
5 | }
6 | else {
7 | qp = location.search.substring(1);
8 | }
9 | qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
10 | function(key, value) {
11 | return key===""?value:decodeURIComponent(value) }
12 | ):{}
13 |
14 | if (window.opener.swaggerUi.tokenUrl)
15 | window.opener.processOAuthCode(qp);
16 | else
17 | window.opener.onOAuthComplete(qp);
18 |
19 | window.close();
20 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./tests/
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "riverslei/laravel-swagger",
3 | "description": "在laravel5中使用swagger自动生成api接口文档",
4 | "keywords": ["laravel", "swagger", "laravel swagger", "laravel5", "swagger-php", "documentation", "api"],
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "helei112g",
9 | "email": "helei5200@126.com"
10 | }
11 | ],
12 | "require": {
13 | "php": ">=5.5.9",
14 | "zircote/swagger-php": "~1.0"
15 | },
16 | "autoload": {
17 | "psr-4": {
18 | "Riverslei\\Swaggervel\\": "src/"
19 | }
20 | },
21 | "minimum-stability": "stable"
22 | }
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear on external disk
35 | .Spotlight-V100
36 | .Trashes
37 |
38 | # Directories potentially created on remote AFP share
39 | .AppleDB
40 | .AppleDesktop
41 | Network Trash Folder
42 | Temporary Items
43 | .apdisk
44 |
--------------------------------------------------------------------------------
/public/lib/jquery.wiggle.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | jQuery Wiggle
3 | Author: WonderGroup, Jordan Thomas
4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html
5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License)
6 | */
7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('
').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 说明
2 | 该项目,主要用于解决API文档生成的问题。
3 | 项目基于laravel5+swagger-php构成。[项目源地址](https://github.com/slampenny/Swaggervel)
4 |
5 | # 改进日志
6 | * V1.1.1 修改了依赖swagger-php包版本问题(swagger-php v2上的版本使用了PSR-4标准)
7 | * 2015年7月1日 [v1.1.0] 修改路由
8 | * 修改了项目文件结构
9 | * 将swagger前端部分版本提升到V2.1版本,使用swagger前端[项目地址](https://github.com/helei112g/swagger-ui)
10 | * 将项目改进为PSR-4自动加载,抛弃之前的PSR-0
11 |
12 | # 安装
13 | 建议采用 `composer` 进行安装,
14 | 1. 在项目的composer.json中配置 `"riverslei/laravel-swagger": "~1.0"`
15 | 2. 运行 `composer update`
16 | 3. 安装完成后,配置 `config/app.php` 中的服务提供者 `Riverslei\Swaggervel\SwaggervelServiceProvider::class`
17 | 4. 以上配置完成后,运行 `php artisan vendor:publish` ,生成相关的配置文件以及资源文件。
18 |
19 | *通过以上配置,已经完成了所有的安装工作,现在开始运行*
20 |
21 | # 运行
22 | 查看api-doc的路由,使用一下命令
23 | ```artisan
24 | php artisan route:list
25 | ```
26 | 根据路由信息,访问:baseUrl+api-docs,如果看到swagger的首页,说明已经成功
27 |
28 | # 补充
29 | 安装该lib后,不需要再运行命令生成相关的json文件,一切在你运行url访问你项目swagger文档首页时,它会自动扫描相关的Model及Controller
30 | ,一切就是这么美妙,以后再也不需要劳心费神的写api接口文档了。
31 |
32 | 这里给出swagger-php注解的书写规则文档:[官方文档](http://zircote.com/swagger-php/annotations.html)
33 |
--------------------------------------------------------------------------------
/public/lang/translator.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * Translator for documentation pages.
5 | *
6 | * To enable translation you should include one of language-files in your index.html
7 | * after .
8 | * For example -
9 | *
10 | * If you wish to translate some new texsts you should do two things:
11 | * 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too.
12 | * 2. Mark that text it templates this way New Phrase or .
13 | * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate.
14 | *
15 | */
16 | window.SwaggerTranslator = {
17 | _words:[],
18 |
19 | translate: function() {
20 | var $this = this;
21 | $('[data-sw-translate]').each(function(){
22 | $(this).html($this._tryTranslate($(this).html()));
23 | $(this).val($this._tryTranslate($(this).val()));
24 | $(this).attr('title', $this._tryTranslate($(this).attr('title')));
25 | });
26 | },
27 |
28 | _tryTranslate: function(word){
29 | return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
30 | },
31 |
32 | learn: function(wordsMap){
33 | this._words = wordsMap;
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/src/SwaggervelServiceProvider.php:
--------------------------------------------------------------------------------
1 | publishes([
25 | __DIR__.'/../config/swagger.php' => config_path('swagger.php'),
26 | ]);
27 |
28 | $this->publishes([
29 | __DIR__.'/../public' => public_path('vendor/swagger'),
30 | ], 'public');
31 |
32 |
33 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'swagger');
34 |
35 | $this->publishes([
36 | __DIR__.'/../resources/views' => base_path('resources/views/vendor/swagger'),
37 | ]);
38 |
39 | require_once __DIR__ .'/routes.php';
40 | }
41 | /**
42 | * Register the service provider.
43 | *
44 | * @return void
45 | */
46 | public function register()
47 | {
48 | $this->mergeConfigFrom(
49 | __DIR__.'/../config/swagger.php', 'swagger'
50 | );
51 | }
52 |
53 | /**
54 | * Get the services provided by the provider.
55 | *
56 | * @return array
57 | */
58 | public function provides()
59 | {
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/public/css/typography.css:
--------------------------------------------------------------------------------
1 | /* droid-sans-regular - latin */
2 | @font-face {
3 | font-family: 'Droid Sans';
4 | font-style: normal;
5 | font-weight: 400;
6 | src: url('../fonts/droid-sans-v6-latin-regular.eot'); /* IE9 Compat Modes */
7 | src: local('Droid Sans'), local('DroidSans'),
8 | url('../fonts/droid-sans-v6-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
9 | url('../fonts/droid-sans-v6-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
10 | url('../fonts/droid-sans-v6-latin-regular.woff') format('woff'), /* Modern Browsers */
11 | url('../fonts/droid-sans-v6-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
12 | url('../fonts/droid-sans-v6-latin-regular.svg#DroidSans') format('svg'); /* Legacy iOS */
13 | }
14 | /* droid-sans-700 - latin */
15 | @font-face {
16 | font-family: 'Droid Sans';
17 | font-style: normal;
18 | font-weight: 700;
19 | src: url('../fonts/droid-sans-v6-latin-700.eot'); /* IE9 Compat Modes */
20 | src: local('Droid Sans Bold'), local('DroidSans-Bold'),
21 | url('../fonts/droid-sans-v6-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
22 | url('../fonts/droid-sans-v6-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
23 | url('../fonts/droid-sans-v6-latin-700.woff') format('woff'), /* Modern Browsers */
24 | url('../fonts/droid-sans-v6-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
25 | url('../fonts/droid-sans-v6-latin-700.svg#DroidSans') format('svg'); /* Legacy iOS */
26 | }
27 |
--------------------------------------------------------------------------------
/public/css/reset.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
2 | html,
3 | body,
4 | div,
5 | span,
6 | applet,
7 | object,
8 | iframe,
9 | h1,
10 | h2,
11 | h3,
12 | h4,
13 | h5,
14 | h6,
15 | p,
16 | blockquote,
17 | pre,
18 | a,
19 | abbr,
20 | acronym,
21 | address,
22 | big,
23 | cite,
24 | code,
25 | del,
26 | dfn,
27 | em,
28 | img,
29 | ins,
30 | kbd,
31 | q,
32 | s,
33 | samp,
34 | small,
35 | strike,
36 | strong,
37 | sub,
38 | sup,
39 | tt,
40 | var,
41 | b,
42 | u,
43 | i,
44 | center,
45 | dl,
46 | dt,
47 | dd,
48 | ol,
49 | ul,
50 | li,
51 | fieldset,
52 | form,
53 | label,
54 | legend,
55 | table,
56 | caption,
57 | tbody,
58 | tfoot,
59 | thead,
60 | tr,
61 | th,
62 | td,
63 | article,
64 | aside,
65 | canvas,
66 | details,
67 | embed,
68 | figure,
69 | figcaption,
70 | footer,
71 | header,
72 | hgroup,
73 | menu,
74 | nav,
75 | output,
76 | ruby,
77 | section,
78 | summary,
79 | time,
80 | mark,
81 | audio,
82 | video {
83 | margin: 0;
84 | padding: 0;
85 | border: 0;
86 | font-size: 100%;
87 | font: inherit;
88 | vertical-align: baseline;
89 | }
90 | /* HTML5 display-role reset for older browsers */
91 | article,
92 | aside,
93 | details,
94 | figcaption,
95 | figure,
96 | footer,
97 | header,
98 | hgroup,
99 | menu,
100 | nav,
101 | section {
102 | display: block;
103 | }
104 | body {
105 | line-height: 1;
106 | }
107 | ol,
108 | ul {
109 | list-style: none;
110 | }
111 | blockquote,
112 | q {
113 | quotes: none;
114 | }
115 | blockquote:before,
116 | blockquote:after,
117 | q:before,
118 | q:after {
119 | content: '';
120 | content: none;
121 | }
122 | table {
123 | border-collapse: collapse;
124 | border-spacing: 0;
125 | }
126 |
--------------------------------------------------------------------------------
/public/lang/zh-CN.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /* 中文版本。 */
4 | window.SwaggerTranslator.learn({
5 | "Warning: Deprecated":"Warning: Deprecated",
6 | "Implementation Notes":"注意事项",
7 | "Response Class":"Response Class",
8 | "Status":"Status1",
9 | "Parameters":"请求参数",
10 | "Parameter":"参数",
11 | "Value":"值",
12 | "Description":"说明信息",
13 | "Parameter Type":"参数类型",
14 | "Data Type":"数据类型",
15 | "Response Messages":"响应信息",
16 | "HTTP Status Code":"返回码",
17 | "Reason":"原因",
18 | "Response Model":"响应 Model",
19 | "Request URL":"Request URL",
20 | "Response Body":"Response Body",
21 | "Response Code":"Response Code",
22 | "Response Headers":"Response Headers",
23 | "Headers":"头",
24 | "Hide Response":"隐藏响应",
25 | "Try it out!":"测试",
26 | "Show/Hide":"展开/收起",
27 | "List Operations":"查看列表",
28 | "Expand Operations":"展开所有",
29 | "Raw":"Raw",
30 | "can't parse JSON. Raw result":"can't parse JSON. Raw result",
31 | "Model Schema":"Model Schema",
32 | "Model":"Model",
33 | "apply":"apply",
34 | "Username":"Username",
35 | "Password":"Password",
36 | "Terms of service":"Terms of service",
37 | "Created by":"Created by",
38 | "See more at":"See more at",
39 | "Contact the developer":"联系开发者",
40 | "api version":"api version",
41 | "Response Content Type":"Response Content Type",
42 | "fetching resource":"fetching resource",
43 | "fetching resource list":"fetching resource list",
44 | "Explore":"Explore",
45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
47 | "Please specify the protocol for":"Please specify the protocol for",
48 | "Can't read swagger JSON from":"Can't read swagger JSON from",
49 | "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
50 | "Unable to read api":"Unable to read api",
51 | "from path":"from path",
52 | "server returned":"server returned",
53 | "Parameter content type:":"参数类型:"
54 | });
55 |
--------------------------------------------------------------------------------
/public/lang/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /* jshint quotmark: double */
4 | window.SwaggerTranslator.learn({
5 | "Warning: Deprecated":"Warning: Deprecated",
6 | "Implementation Notes":"Implementation Notes",
7 | "Response Class":"Response Class",
8 | "Status":"Status",
9 | "Parameters":"Parameters",
10 | "Parameter":"Parameter",
11 | "Value":"Value",
12 | "Description":"Description",
13 | "Parameter Type":"Parameter Type",
14 | "Data Type":"Data Type",
15 | "Response Messages":"Response Messages",
16 | "HTTP Status Code":"HTTP Status Code",
17 | "Reason":"Reason",
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":"Hide Response",
24 | "Try it out!":"Try it out!",
25 | "Show/Hide":"Show/Hide",
26 | "List Operations":"List Operations",
27 | "Expand Operations":"Expand Operations",
28 | "Raw":"Raw",
29 | "can't parse JSON. Raw result":"can't parse JSON. Raw result",
30 | "Model Schema":"Model Schema",
31 | "Model":"Model",
32 | "apply":"apply",
33 | "Username":"Username",
34 | "Password":"Password",
35 | "Terms of service":"Terms of service",
36 | "Created by":"Created by",
37 | "See more at":"See more at",
38 | "Contact the developer":"Contact the developer",
39 | "api version":"api version",
40 | "Response Content Type":"Response Content Type",
41 | "fetching resource":"fetching resource",
42 | "fetching resource list":"fetching resource list",
43 | "Explore":"Explore",
44 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
46 | "Please specify the protocol for":"Please specify the protocol for",
47 | "Can't read swagger JSON from":"Can't read swagger JSON from",
48 | "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
49 | "Unable to read api":"Unable to read api",
50 | "from path":"from path",
51 | "server returned":"server returned"
52 | });
53 |
--------------------------------------------------------------------------------
/config/swagger.php:
--------------------------------------------------------------------------------
1 | storage_path() . '/docs',
16 |
17 | /*
18 | |--------------------------------------------------------------------------
19 | | Relative path to access parsed swagger annotations.
20 | |--------------------------------------------------------------------------
21 | */
22 | 'doc-route' => 'docs',
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Absolute path to directory containing the swagger annotations are stored.
27 | |--------------------------------------------------------------------------
28 | */
29 | "app-dir" => "app",
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Absolute path to directories that you would like to exclude from swagger generation
34 | |--------------------------------------------------------------------------
35 | */
36 | "excludes" => array(
37 | storage_path(),
38 | base_path()."/tests",
39 | base_path()."/resources/views",
40 | base_path()."/config"
41 | ),
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | Turn this off to remove swagger generation on production
46 | |--------------------------------------------------------------------------
47 | */
48 | "generateAlways" => true,
49 |
50 | "api-key" => "auth_token",
51 |
52 | /*
53 | |--------------------------------------------------------------------------
54 | | Edit to set the api's version number
55 | |--------------------------------------------------------------------------
56 | */
57 | "default-api-version" => "",
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | Edit to set the swagger version number
62 | |--------------------------------------------------------------------------
63 | */
64 | "default-swagger-version" => "1.2",
65 |
66 | /*
67 | |--------------------------------------------------------------------------
68 | | Edit to set the api's base path
69 | |--------------------------------------------------------------------------
70 | */
71 | "default-base-path" => "",
72 |
73 | /*
74 | |--------------------------------------------------------------------------
75 | | Edit to trust the proxy's ip address - needed for AWS Load Balancer
76 | |--------------------------------------------------------------------------
77 | */
78 | "behind-reverse-proxy" => false,
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Uncomment to add response headers when swagger is generated
82 | |--------------------------------------------------------------------------
83 | */
84 | /*"viewHeaders" => array(
85 | 'Content-Type' => 'text/plain'
86 | ),*/
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Uncomment to add request headers when swagger performs requests
91 | |--------------------------------------------------------------------------
92 | */
93 | /*"requestHeaders" => array(
94 | 'TestMe' => 'testValue'
95 | ),*/
96 | );
97 |
--------------------------------------------------------------------------------
/public/lib/jquery.ba-bbq.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
3 | * http://benalman.com/projects/jquery-bbq-plugin/
4 | *
5 | * Copyright (c) 2010 "Cowboy" Ben Alman
6 | * Dual licensed under the MIT and GPL licenses.
7 | * http://benalman.com/about/license/
8 | */
9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
--------------------------------------------------------------------------------
/src/routes.php:
--------------------------------------------------------------------------------
1 | 'application/json'
18 | ));
19 | });
20 |
21 | Route::get('api-docs', function() {
22 | if (Config::get('swagger.generateAlways')) {
23 | $appDir = base_path()."/".Config::get('swagger.app-dir');
24 | $docDir = Config::get('swagger.doc-dir');
25 |
26 | if (!File::exists($docDir) || is_writable($docDir)) {
27 | // delete all existing documentation
28 | if (File::exists($docDir)) {
29 | File::deleteDirectory($docDir);
30 | }
31 |
32 | File::makeDirectory($docDir);
33 |
34 | $defaultBasePath = Config::get('swagger.default-base-path');
35 | $defaultApiVersion = Config::get('swagger.default-api-version');
36 | $defaultSwaggerVersion = Config::get('swagger.default-swagger-version');
37 | $excludeDirs = Config::get('swagger.excludes');
38 |
39 | $swagger = new Swagger($appDir, $excludeDirs);
40 |
41 | $resourceList = $swagger->getResourceList(array(
42 | 'output' => 'array',
43 | 'apiVersion' => $defaultApiVersion,
44 | 'swaggerVersion' => $defaultSwaggerVersion,
45 | ));
46 | $resourceOptions = array(
47 | 'output' => 'json',
48 | 'defaultSwaggerVersion' => $resourceList['swaggerVersion'],
49 | 'defaultBasePath' => $defaultBasePath
50 | );
51 |
52 | $output = array();
53 | foreach ($swagger->getResourceNames() as $resourceName) {
54 | $json = $swagger->getResource($resourceName, $resourceOptions);
55 | $resourceName = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($resourceName, DIRECTORY_SEPARATOR));
56 | $output[$resourceName] = $json;
57 | }
58 |
59 | $filename = $docDir . '/api-docs.json';
60 | file_put_contents($filename, Swagger::jsonEncode($resourceList, true));
61 |
62 | foreach ($output as $name => $json) {
63 | $name = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($name, DIRECTORY_SEPARATOR));
64 | $filename = $docDir . '/'.$name . '.json';
65 | file_put_contents($filename, $json);
66 | }
67 | }
68 | }
69 |
70 | if (Config::get('swagger.behind-reverse-proxy')) {
71 | $proxy = Request::server('REMOTE_ADDR');
72 | Request::setTrustedProxies(array($proxy));
73 | }
74 |
75 | Blade::setEscapedContentTags('{{{', '}}}');
76 | Blade::setContentTags('{{', '}}');
77 |
78 | //need the / at the end to avoid CORS errors on Homestead systems.
79 | $response = response()->view('swagger::index', array(
80 | 'secure' => Request::secure(),
81 | 'urlToDocs' => url(Config::get('swagger.doc-route')),
82 | 'requestHeaders' => Config::get('swagger.requestHeaders') )
83 | );
84 |
85 | //need the / at the end to avoid CORS errors on Homestead systems.
86 | /*$response = Response::make(
87 | View::make('swaggervel::index', array(
88 | 'secure' => Request::secure(),
89 | 'urlToDocs' => url(Config::get('swaggervel.doc-route')),
90 | 'requestHeaders' => Config::get('swaggervel.requestHeaders') )
91 | ),
92 | 200
93 | );*/
94 |
95 | if (Config::has('swagger.viewHeaders')) {
96 | foreach (Config::get('swagger.viewHeaders') as $key => $value) {
97 | $response->header($key, $value);
98 | }
99 | }
100 |
101 | return $response;
102 | });
103 |
--------------------------------------------------------------------------------
/resources/views/index.blade.php:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 | HeLei API DOC
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 | {{-- {{ HTML::script('packages/jlapp/swaggervel/lib/swagger-oauth.js' , array(), $secure); !!}--}}
37 |
38 |
100 |
101 |
102 |
103 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/public/css/style.css:
--------------------------------------------------------------------------------
1 | .swagger-section #header a#logo {
2 | font-size: 1.5em;
3 | font-weight: bold;
4 | text-decoration: none;
5 | background: transparent url(../images/logo.png) no-repeat left center;
6 | padding: 20px 0 20px 40px;
7 | }
8 | #text-head {
9 | font-size: 80px;
10 | font-family: 'Roboto', sans-serif;
11 | color: #ffffff;
12 | float: right;
13 | margin-right: 20%;
14 | }
15 | .navbar-fixed-top .navbar-nav {
16 | height: auto;
17 | }
18 | .navbar-fixed-top .navbar-brand {
19 | height: auto;
20 | }
21 | .navbar-header {
22 | height: auto;
23 | }
24 | .navbar-inverse {
25 | background-color: #000;
26 | border-color: #000;
27 | }
28 | #navbar-brand {
29 | margin-left: 20%;
30 | }
31 | .navtext {
32 | font-size: 10px;
33 | }
34 | .h1,
35 | h1 {
36 | font-size: 60px;
37 | }
38 | .navbar-default .navbar-header .navbar-brand {
39 | color: #a2dfee;
40 | }
41 | /* tag titles */
42 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
43 | color: #393939;
44 | font-family: 'Arvo', serif;
45 | font-size: 1.5em;
46 | }
47 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
48 | color: black;
49 | }
50 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
51 | color: #525252;
52 | padding-left: 0px;
53 | display: block;
54 | clear: none;
55 | float: left;
56 | font-family: 'Arvo', serif;
57 | font-weight: bold;
58 | }
59 | .navbar-default .navbar-collapse,
60 | .navbar-default .navbar-form {
61 | border-color: #0A0A0A;
62 | }
63 | .container1 {
64 | width: 1500px;
65 | margin: auto;
66 | margin-top: 0;
67 | background-image: url('../images/shield.png');
68 | background-repeat: no-repeat;
69 | background-position: -40px -20px;
70 | margin-bottom: 210px;
71 | }
72 | .container-inner {
73 | width: 1200px;
74 | margin: auto;
75 | background-color: rgba(223, 227, 228, 0.75);
76 | padding-bottom: 40px;
77 | padding-top: 40px;
78 | border-radius: 15px;
79 | }
80 | .header-content {
81 | padding: 0;
82 | width: 1000px;
83 | }
84 | .title1 {
85 | font-size: 80px;
86 | font-family: 'Vollkorn', serif;
87 | color: #404040;
88 | text-align: center;
89 | padding-top: 40px;
90 | padding-bottom: 100px;
91 | }
92 | #icon {
93 | margin-top: -18px;
94 | }
95 | .subtext {
96 | font-size: 25px;
97 | font-style: italic;
98 | color: #08b;
99 | text-align: right;
100 | padding-right: 250px;
101 | }
102 | .bg-primary {
103 | background-color: #00468b;
104 | }
105 | .navbar-default .nav > li > a,
106 | .navbar-default .nav > li > a:focus {
107 | color: #08b;
108 | }
109 | .navbar-default .nav > li > a,
110 | .navbar-default .nav > li > a:hover {
111 | color: #08b;
112 | }
113 | .navbar-default .nav > li > a,
114 | .navbar-default .nav > li > a:focus:hover {
115 | color: #08b;
116 | }
117 | .text-faded {
118 | font-size: 25px;
119 | font-family: 'Vollkorn', serif;
120 | }
121 | .section-heading {
122 | font-family: 'Vollkorn', serif;
123 | font-size: 45px;
124 | padding-bottom: 10px;
125 | }
126 | hr {
127 | border-color: #00468b;
128 | padding-bottom: 10px;
129 | }
130 | .description {
131 | margin-top: 20px;
132 | padding-bottom: 200px;
133 | }
134 | .description li {
135 | font-family: 'Vollkorn', serif;
136 | font-size: 25px;
137 | color: #525252;
138 | margin-left: 28%;
139 | padding-top: 5px;
140 | }
141 | .gap {
142 | margin-top: 200px;
143 | }
144 | .troubleshootingtext {
145 | color: rgba(255, 255, 255, 0.7);
146 | padding-left: 30%;
147 | }
148 | .troubleshootingtext li {
149 | list-style-type: circle;
150 | font-size: 25px;
151 | padding-bottom: 5px;
152 | }
153 | .overlay {
154 | position: absolute;
155 | top: 0;
156 | left: 0;
157 | width: 100%;
158 | height: 100%;
159 | z-index: 1000;
160 | }
161 | .block.response_body.json:hover {
162 | cursor: pointer;
163 | }
164 | .backdrop {
165 | color: blue;
166 | }
167 | #myModal {
168 | height: 100%;
169 | }
170 | .modal-backdrop {
171 | bottom: 0;
172 | position: fixed;
173 | }
174 | .curl {
175 | padding: 10px;
176 | font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
177 | font-size: 0.9em;
178 | max-height: 400px;
179 | margin-top: 5px;
180 | overflow-y: auto;
181 | background-color: #fcf6db;
182 | border: 1px solid #e5e0c6;
183 | border-radius: 4px;
184 | }
185 | .curl_title {
186 | font-size: 1.1em;
187 | margin: 0;
188 | padding: 15px 0 5px;
189 | font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
190 | font-weight: 500;
191 | line-height: 1.1;
192 | }
193 | .footer {
194 | display: none;
195 | }
196 | .swagger-section .swagger-ui-wrap h2 {
197 | padding: 0;
198 | }
199 | h2 {
200 | margin: 0;
201 | margin-bottom: 5px;
202 | }
203 | .markdown p {
204 | font-size: 15px;
205 | font-family: 'Arvo', serif;
206 | }
207 | .swagger-section .swagger-ui-wrap .code {
208 | font-size: 15px;
209 | font-family: 'Arvo', serif;
210 | }
211 | .swagger-section .swagger-ui-wrap b {
212 | font-family: 'Arvo', serif;
213 | }
214 | #signin:hover {
215 | cursor: pointer;
216 | }
217 | .dropdown-menu {
218 | padding: 15px;
219 | }
220 | .navbar-right .dropdown-menu {
221 | left: 0;
222 | right: auto;
223 | }
224 | #signinbutton {
225 | width: 100%;
226 | height: 32px;
227 | font-size: 13px;
228 | font-weight: bold;
229 | color: #08b;
230 | }
231 | .navbar-default .nav > li .details {
232 | color: #000000;
233 | text-transform: none;
234 | font-size: 15px;
235 | font-weight: normal;
236 | font-family: 'Open Sans', sans-serif;
237 | font-style: italic;
238 | line-height: 20px;
239 | top: -2px;
240 | }
241 | .navbar-default .nav > li .details:hover {
242 | color: black;
243 | }
244 | #signout {
245 | width: 100%;
246 | height: 32px;
247 | font-size: 13px;
248 | font-weight: bold;
249 | color: #08b;
250 | }
251 |
--------------------------------------------------------------------------------
/public/lib/highlight.7.3.pack.js:
--------------------------------------------------------------------------------
1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=(""+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q'+L[0]+""}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return''+r.value+""}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+=""}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"
")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",rE:true,sL:"css"}},{cN:"tag",b:"