Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Sunny_yiyi
Swagger Ui
提交
d1bffc8f
S
Swagger Ui
项目概览
Sunny_yiyi
/
Swagger Ui
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Swagger Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d1bffc8f
编写于
11月 25, 2012
作者:
T
Tony Tam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
manual merge of #97
上级
55f0c1a2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
60 addition
and
29 deletion
+60
-29
Cakefile
Cakefile
+1
-0
lib/swagger.js
lib/swagger.js
+3
-2
src/main/coffeescript/view/OperationView.coffee
src/main/coffeescript/view/OperationView.coffee
+16
-2
src/main/coffeescript/view/ParameterView.coffee
src/main/coffeescript/view/ParameterView.coffee
+13
-6
src/main/coffeescript/view/ResourceView.coffee
src/main/coffeescript/view/ResourceView.coffee
+0
-7
src/main/html/css/screen.css
src/main/html/css/screen.css
+9
-0
src/main/template/operation.handlebars
src/main/template/operation.handlebars
+7
-5
src/main/template/param.handlebars
src/main/template/param.handlebars
+5
-3
src/main/template/param_required.handlebars
src/main/template/param_required.handlebars
+6
-4
未找到文件。
Cakefile
浏览文件 @
d1bffc8f
...
...
@@ -11,6 +11,7 @@ sourceFiles = [
'view/StatusCodeView'
'view/ParameterView'
'view/SignatureView'
'view/ContentTypeView'
]
...
...
lib/swagger.js
浏览文件 @
d1bffc8f
...
...
@@ -255,7 +255,7 @@
_results
=
[];
for
(
_i
=
0
,
_len
=
ops
.
length
;
_i
<
_len
;
_i
++
)
{
o
=
ops
[
_i
];
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
o
.
httpMethod
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
o
.
responseClass
,
o
.
errorResponses
,
this
);
op
=
new
SwaggerOperation
(
o
.
nickname
,
resource_path
,
o
.
httpMethod
,
o
.
parameters
,
o
.
summary
,
o
.
notes
,
o
.
responseClass
,
o
.
errorResponses
,
this
,
o
.
supportedContentTypes
);
this
.
operations
[
op
.
nickname
]
=
op
;
_results
.
push
(
this
.
operationsArray
.
push
(
op
));
}
...
...
@@ -413,7 +413,7 @@
SwaggerOperation
=
(
function
()
{
function
SwaggerOperation
(
nickname
,
path
,
httpMethod
,
parameters
,
summary
,
notes
,
responseClass
,
errorResponses
,
resource
)
{
function
SwaggerOperation
(
nickname
,
path
,
httpMethod
,
parameters
,
summary
,
notes
,
responseClass
,
errorResponses
,
resource
,
supportedContentTypes
)
{
var
parameter
,
v
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
_this
=
this
;
this
.
nickname
=
nickname
;
...
...
@@ -425,6 +425,7 @@
this
.
responseClass
=
responseClass
;
this
.
errorResponses
=
errorResponses
;
this
.
resource
=
resource
;
this
.
supportedContentTypes
=
supportedContentTypes
;
this
[
"
do
"
]
=
__bind
(
this
[
"
do
"
],
this
);
if
(
this
.
nickname
==
null
)
{
...
...
src/main/coffeescript/view/OperationView.coffee
浏览文件 @
d1bffc8f
...
...
@@ -24,7 +24,13 @@ class OperationView extends Backbone.View
$
(
'.model-signature'
,
$
(
@
el
)).
append
responseSignatureView
.
render
().
el
else
$
(
'.model-signature'
,
$
(
@
el
)).
html
(
@
model
.
responseClass
)
contentTypeModel
=
isParam
:
false
supportedContentTypes
:
@
model
.
supportedContentTypes
contentTypeView
=
new
ContentTypeView
({
model
:
contentTypeModel
})
$
(
'.content-type'
,
$
(
@
el
)).
append
contentTypeView
.
render
().
el
# Render each parameter
@
addParameter
param
for
param
in
@
model
.
parameters
...
...
@@ -118,6 +124,14 @@ class OperationView extends Backbone.View
obj
.
contentType
=
"application/json"
if
(
obj
.
type
.
toLowerCase
()
==
"post"
or
obj
.
type
.
toLowerCase
()
==
"put"
or
obj
.
type
.
toLowerCase
()
==
"patch"
)
obj
.
contentType
=
false
if
isFileUpload
paramContentTypeField
=
$
(
"td select[name=contentType]"
,
$
(
@
el
)).
val
()
if
paramContentTypeField
obj
.
contentType
=
paramContentTypeField
responseContentTypeField
=
$
(
'.content > .content-type > div > select[name=contentType]'
,
$
(
@
el
)).
val
()
if
responseContentTypeField
obj
.
headers
.
accept
=
responseContentTypeField
jQuery
.
ajax
(
obj
)
false
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
...
...
@@ -158,5 +172,5 @@ class OperationView extends Backbone.View
hljs
.
highlightBlock
(
$
(
'.response_body'
,
$
(
@
el
))[
0
])
toggleOperationContent
:
->
elem
=
$
(
'#'
+
@
model
.
resourceName
+
"_"
+
@
model
.
nickname
+
"_"
+
@
model
.
httpMethod
+
"_
"
+
@
model
.
number
+
"_
content"
);
elem
=
$
(
'#'
+
@
model
.
resourceName
+
"_"
+
@
model
.
nickname
+
"_"
+
@
model
.
httpMethod
+
"_content"
);
if
elem
.
is
(
':visible'
)
then
Docs
.
collapseOperation
(
elem
)
else
Docs
.
expandOperation
(
elem
)
src/main/coffeescript/view/ParameterView.coffee
浏览文件 @
d1bffc8f
...
...
@@ -9,15 +9,22 @@ class ParameterView extends Backbone.View
$
(
@
el
).
html
(
template
(
@
model
))
signatureModel
=
sampleJSON
:
@
model
.
sampleJSON
isParam
:
true
signature
:
@
model
.
signature
sampleJSON
:
@
model
.
sampleJSON
isParam
:
true
signature
:
@
model
.
signature
if
@
model
.
sampleJSON
signatureView
=
new
SignatureView
({
model
:
signatureModel
,
tagName
:
'div'
})
$
(
'.model-signature'
,
$
(
@
el
)).
append
signatureView
.
render
().
el
signatureView
=
new
SignatureView
({
model
:
signatureModel
,
tagName
:
'div'
})
$
(
'.model-signature'
,
$
(
@
el
)).
append
signatureView
.
render
().
el
else
$
(
'.model-signature'
,
$
(
@
el
)).
html
(
@
model
.
signature
)
$
(
'.model-signature'
,
$
(
@
el
)).
html
(
@
model
.
signature
)
contentTypeModel
=
isParam
:
true
supportedContentTypes
:
@
model
.
supportedContentTypes
contentTypeView
=
new
ContentTypeView
({
model
:
contentTypeModel
})
$
(
'.content-type'
,
$
(
@
el
)).
append
contentTypeView
.
render
().
el
@
...
...
src/main/coffeescript/view/ResourceView.coffee
浏览文件 @
d1bffc8f
...
...
@@ -4,18 +4,11 @@ class ResourceView extends Backbone.View
render
:
->
$
(
@
el
).
html
(
Handlebars
.
templates
.
resource
(
@
model
))
@
number
=
0
# Render each operation
@
addOperation
operation
for
operation
in
@
model
.
operationsArray
@
addOperation
:
(
operation
)
->
operation
.
number
=
@
number
# Render an operation and add it to operations li
operationView
=
new
OperationView
({
model
:
operation
,
tagName
:
'li'
,
className
:
'endpoint'
})
$
(
'.endpoints'
,
$
(
@
el
)).
append
operationView
.
render
().
el
@
number
++
src/main/html/css/screen.css
浏览文件 @
d1bffc8f
...
...
@@ -1579,3 +1579,12 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
pre
code
{
background
:
none
;
}
.content
>
.content-type
>
div
>
label
{
clear
:
both
;
display
:
block
;
color
:
#0F6AB4
;
font-size
:
1.1em
;
margin
:
0
;
padding
:
15px
0
5px
0px
;
}
src/main/template/operation.handlebars
浏览文件 @
d1bffc8f
<ul
class=
'operations'
>
<li
class=
'
{{
httpMethod
}}
operation'
id=
'
{{
resourceName
}}
_
{{
nickname
}}
_
{{
httpMethod
}}
_
{{
number
}}
'
>
<li
class=
'
{{
httpMethod
}}
operation'
id=
'
{{
resourceName
}}
_
{{
nickname
}}
_
{{
httpMethod
}}
'
>
<div
class=
'heading'
>
<h3>
<span
class=
'http_method'
>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
_
{{
number
}}
'
class=
"toggleOperation"
>
{{
httpMethod
}}
</a>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
'
class=
"toggleOperation"
>
{{
httpMethod
}}
</a>
</span>
<span
class=
'path'
>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
_
{{
number
}}
'
class=
"toggleOperation"
>
{{
path
}}
</a>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
'
class=
"toggleOperation"
>
{{
path
}}
</a>
</span>
</h3>
<ul
class=
'options'
>
<li>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
_
{{
number
}}
'
class=
"toggleOperation"
>
{{{
summary
}}}
</a>
<a
href=
'#!/
{{
resourceName
}}
/
{{
nickname
}}
_
{{
httpMethod
}}
'
class=
"toggleOperation"
>
{{{
summary
}}}
</a>
</li>
</ul>
</div>
<div
class=
'content'
id=
'
{{
resourceName
}}
_
{{
nickname
}}
_
{{
httpMethod
}}
_
{{
number
}}
_
content'
style=
'display:none'
>
<div
class=
'content'
id=
'
{{
resourceName
}}
_
{{
nickname
}}
_
{{
httpMethod
}}
_content'
style=
'display:none'
>
{{#if
notes
}}
<h4>
Implementation Notes
</h4>
<p>
{{{
notes
}}}
</p>
...
...
@@ -25,6 +25,8 @@
<h4>
Response Model
</h4>
<span
class=
"model-signature"
></span>
{{/if}}
<br/>
<div
class=
"content-type"
/>
<form
accept-charset=
'UTF-8'
class=
'sandbox'
>
<div
style=
'margin:0;padding:0;display:inline'
></div>
<h4>
Parameters
</h4>
...
...
src/main/template/param.handlebars
浏览文件 @
d1bffc8f
...
...
@@ -8,20 +8,22 @@
{{#if
defaultValue
}}
<textarea
class=
'body-textarea'
name=
'
{{
name
}}
'
>
{{
defaultValue
}}
</textarea>
{{else}}
<textarea
class=
'body-textarea'
name=
'
{{
name
}}
'
></textarea>
<textarea
class=
'body-textarea'
name=
'
{{
name
}}
'
></textarea>
<br
/>
<div
class=
"content-type"
/>
{{/if}}
{{/if}}
{{else}}
{{#if
defaultValue
}}
<input
minlength=
'0'
name=
'
{{
name
}}
'
placeholder=
''
type=
'text'
value=
'
{{
defaultValue
}}
'
/>
{{else}}
<input
minlength=
'0'
name=
'
{{
name
}}
'
placeholder=
''
type=
'text'
value=
''
/>
<input
minlength=
'0'
name=
'
{{
name
}}
'
placeholder=
''
type=
'text'
value=
''
/>
{{/if}}
{{/if}}
</td>
<td>
{{{
description
}}}
</td>
<td>
<span
class=
"model-signature"
></span>
<span
class=
"model-signature"
></span>
</td>
src/main/template/param_required.handlebars
浏览文件 @
d1bffc8f
...
...
@@ -7,7 +7,9 @@
{{#if
defaultValue
}}
<textarea
class=
'body-textarea'
placeholder=
'(required)'
name=
'
{{
name
}}
'
>
{{
defaultValue
}}
</textarea>
{{else}}
<textarea
class=
'body-textarea'
placeholder=
'(required)'
name=
'
{{
name
}}
'
></textarea>
<textarea
class=
'body-textarea'
placeholder=
'(required)'
name=
'
{{
name
}}
'
></textarea>
<br
/>
<div
class=
"content-type"
/>
{{/if}}
{{/if}}
{{else}}
...
...
@@ -15,14 +17,14 @@
<input
class=
'required'
type=
'file'
name=
'
{{
name
}}
'
/>
{{else}}
{{#if
defaultValue
}}
<input
class=
'required'
minlength=
'1'
name=
'
{{
name
}}
'
placeholder=
'(required)'
type=
'text'
value=
'
{{
defaultValue
}}
'
/>
<input
class=
'required'
minlength=
'1'
name=
'
{{
name
}}
'
placeholder=
'(required)'
type=
'text'
value=
'
{{
defaultValue
}}
'
/>
{{else}}
<input
class=
'required'
minlength=
'1'
name=
'
{{
name
}}
'
placeholder=
'(required)'
type=
'text'
value=
''
/>
<input
class=
'required'
minlength=
'1'
name=
'
{{
name
}}
'
placeholder=
'(required)'
type=
'text'
value=
''
/>
{{/if}}
{{/if}}
{{/if}}
</td>
<td>
<strong>
{{{
description
}}}
</strong>
<strong>
{{{
description
}}}
</strong>
</td>
<td><span
class=
"model-signature"
></span></td>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录