Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Sunny_yiyi
Swagger Ui
提交
b6eb2321
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,发现更多精彩内容 >>
提交
b6eb2321
编写于
9月 22, 2017
作者:
K
kyle
提交者:
GitHub
9月 22, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into master
上级
54a2d402
a3f923ee
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
73 addition
and
22 deletion
+73
-22
src/core/components/param-body.jsx
src/core/components/param-body.jsx
+2
-2
src/core/components/parameter-row.jsx
src/core/components/parameter-row.jsx
+6
-2
src/core/components/parameters.jsx
src/core/components/parameters.jsx
+2
-2
src/core/plugins/oas3/wrap-components/parameters.jsx
src/core/plugins/oas3/wrap-components/parameters.jsx
+1
-1
src/core/plugins/spec/actions.js
src/core/plugins/spec/actions.js
+2
-3
src/core/plugins/spec/reducers.js
src/core/plugins/spec/reducers.js
+3
-2
src/core/plugins/spec/selectors.js
src/core/plugins/spec/selectors.js
+3
-3
src/core/utils.js
src/core/utils.js
+21
-1
test/core/plugins/spec/selectors.js
test/core/plugins/spec/selectors.js
+4
-4
test/core/utils.js
test/core/utils.js
+29
-2
未找到文件。
src/core/components/param-body.jsx
浏览文件 @
b6eb2321
...
@@ -47,7 +47,7 @@ export default class ParamBody extends PureComponent {
...
@@ -47,7 +47,7 @@ export default class ParamBody extends PureComponent {
updateValues
=
(
props
)
=>
{
updateValues
=
(
props
)
=>
{
let
{
specSelectors
,
pathMethod
,
param
,
isExecute
,
consumesValue
=
""
}
=
props
let
{
specSelectors
,
pathMethod
,
param
,
isExecute
,
consumesValue
=
""
}
=
props
let
parameter
=
specSelectors
?
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
))
:
{}
let
parameter
=
specSelectors
?
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
)
,
param
.
get
(
"
in
"
)
)
:
{}
let
isXml
=
/xml/i
.
test
(
consumesValue
)
let
isXml
=
/xml/i
.
test
(
consumesValue
)
let
isJson
=
/json/i
.
test
(
consumesValue
)
let
isJson
=
/json/i
.
test
(
consumesValue
)
let
paramValue
=
isXml
?
parameter
.
get
(
"
value_xml
"
)
:
parameter
.
get
(
"
value
"
)
let
paramValue
=
isXml
?
parameter
.
get
(
"
value_xml
"
)
:
parameter
.
get
(
"
value
"
)
...
@@ -107,7 +107,7 @@ export default class ParamBody extends PureComponent {
...
@@ -107,7 +107,7 @@ export default class ParamBody extends PureComponent {
const
HighlightCode
=
getComponent
(
"
highlightCode
"
)
const
HighlightCode
=
getComponent
(
"
highlightCode
"
)
const
ContentType
=
getComponent
(
"
contentType
"
)
const
ContentType
=
getComponent
(
"
contentType
"
)
// for domains where specSelectors not passed
// for domains where specSelectors not passed
let
parameter
=
specSelectors
?
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
))
:
param
let
parameter
=
specSelectors
?
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
)
,
param
.
get
(
"
in
"
)
)
:
param
let
errors
=
parameter
.
get
(
"
errors
"
,
List
())
let
errors
=
parameter
.
get
(
"
errors
"
,
List
())
let
consumesValue
=
specSelectors
.
contentTypeValues
(
pathMethod
).
get
(
"
requestContentType
"
)
let
consumesValue
=
specSelectors
.
contentTypeValues
(
pathMethod
).
get
(
"
requestContentType
"
)
let
consumes
=
this
.
props
.
consumes
&&
this
.
props
.
consumes
.
size
?
this
.
props
.
consumes
:
ParamBody
.
defaultProp
.
consumes
let
consumes
=
this
.
props
.
consumes
&&
this
.
props
.
consumes
.
size
?
this
.
props
.
consumes
:
ParamBody
.
defaultProp
.
consumes
...
...
src/core/components/parameter-row.jsx
浏览文件 @
b6eb2321
...
@@ -19,13 +19,17 @@ export default class ParameterRow extends Component {
...
@@ -19,13 +19,17 @@ export default class ParameterRow extends Component {
let
{
specSelectors
,
pathMethod
,
param
}
=
props
let
{
specSelectors
,
pathMethod
,
param
}
=
props
let
defaultValue
=
param
.
get
(
"
default
"
)
let
defaultValue
=
param
.
get
(
"
default
"
)
let
parameter
=
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
))
let
parameter
=
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
)
,
param
.
get
(
"
in
"
)
)
let
value
=
parameter
?
parameter
.
get
(
"
value
"
)
:
""
let
value
=
parameter
?
parameter
.
get
(
"
value
"
)
:
""
if
(
defaultValue
!==
undefined
&&
value
===
undefined
)
{
if
(
defaultValue
!==
undefined
&&
value
===
undefined
)
{
this
.
onChangeWrapper
(
defaultValue
)
this
.
onChangeWrapper
(
defaultValue
)
}
}
}
}
shouldComponentUpdate
(
nextProps
)
{
return
nextProps
.
param
!==
this
.
props
.
param
}
componentWillReceiveProps
(
props
)
{
componentWillReceiveProps
(
props
)
{
let
{
specSelectors
,
pathMethod
,
param
}
=
props
let
{
specSelectors
,
pathMethod
,
param
}
=
props
let
example
=
param
.
get
(
"
example
"
)
let
example
=
param
.
get
(
"
example
"
)
...
@@ -86,7 +90,7 @@ export default class ParameterRow extends Component {
...
@@ -86,7 +90,7 @@ export default class ParameterRow extends Component {
let
isFormDataSupported
=
"
FormData
"
in
win
let
isFormDataSupported
=
"
FormData
"
in
win
let
required
=
param
.
get
(
"
required
"
)
let
required
=
param
.
get
(
"
required
"
)
let
itemType
=
param
.
getIn
(
isOAS3
&&
isOAS3
()
?
[
"
schema
"
,
"
items
"
,
"
type
"
]
:
[
"
items
"
,
"
type
"
])
let
itemType
=
param
.
getIn
(
isOAS3
&&
isOAS3
()
?
[
"
schema
"
,
"
items
"
,
"
type
"
]
:
[
"
items
"
,
"
type
"
])
let
parameter
=
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
))
let
parameter
=
specSelectors
.
getParameter
(
pathMethod
,
param
.
get
(
"
name
"
)
,
param
.
get
(
"
in
"
)
)
let
value
=
parameter
?
parameter
.
get
(
"
value
"
)
:
""
let
value
=
parameter
?
parameter
.
get
(
"
value
"
)
:
""
return
(
return
(
...
...
src/core/components/parameters.jsx
浏览文件 @
b6eb2321
...
@@ -37,7 +37,7 @@ export default class Parameters extends Component {
...
@@ -37,7 +37,7 @@ export default class Parameters extends Component {
onChangeKey
,
onChangeKey
,
}
=
this
.
props
}
=
this
.
props
changeParam
(
onChangeKey
,
param
.
get
(
"
name
"
),
value
,
isXml
)
changeParam
(
onChangeKey
,
param
.
get
(
"
name
"
),
param
.
get
(
"
in
"
),
value
,
isXml
)
}
}
onChangeConsumesWrapper
=
(
val
)
=>
{
onChangeConsumesWrapper
=
(
val
)
=>
{
...
@@ -94,7 +94,7 @@ export default class Parameters extends Component {
...
@@ -94,7 +94,7 @@ export default class Parameters extends Component {
<
ParameterRow
fn
=
{
fn
}
<
ParameterRow
fn
=
{
fn
}
getComponent
=
{
getComponent
}
getComponent
=
{
getComponent
}
param
=
{
parameter
}
param
=
{
parameter
}
key
=
{
parameter
.
get
(
"
name
"
)
}
key
=
{
`
${
parameter
.
get
(
"
in
"
)}
.
${
parameter
.
get
(
"
name
"
)}
`
}
onChange
=
{
this
.
onChange
}
onChange
=
{
this
.
onChange
}
onChangeConsumes
=
{
this
.
onChangeConsumesWrapper
}
onChangeConsumes
=
{
this
.
onChangeConsumesWrapper
}
specSelectors
=
{
specSelectors
}
specSelectors
=
{
specSelectors
}
...
...
src/core/plugins/oas3/wrap-components/parameters.jsx
浏览文件 @
b6eb2321
...
@@ -49,7 +49,7 @@ class Parameters extends Component {
...
@@ -49,7 +49,7 @@ class Parameters extends Component {
onChangeKey
,
onChangeKey
,
}
=
this
.
props
}
=
this
.
props
changeParam
(
onChangeKey
,
param
.
get
(
"
name
"
),
value
,
isXml
)
changeParam
(
onChangeKey
,
param
.
get
(
"
name
"
),
param
.
get
(
"
in
"
),
value
,
isXml
)
}
}
onChangeConsumesWrapper
=
(
val
)
=>
{
onChangeConsumesWrapper
=
(
val
)
=>
{
...
...
src/core/plugins/spec/actions.js
浏览文件 @
b6eb2321
...
@@ -130,10 +130,10 @@ export const formatIntoYaml = () => ({specActions, specSelectors}) => {
...
@@ -130,10 +130,10 @@ export const formatIntoYaml = () => ({specActions, specSelectors}) => {
}
}
}
}
export
function
changeParam
(
path
,
paramName
,
value
,
isXml
){
export
function
changeParam
(
path
,
paramName
,
paramIn
,
value
,
isXml
){
return
{
return
{
type
:
UPDATE_PARAM
,
type
:
UPDATE_PARAM
,
payload
:{
path
,
value
,
paramName
,
isXml
}
payload
:{
path
,
value
,
paramName
,
paramIn
,
isXml
}
}
}
}
}
...
@@ -206,7 +206,6 @@ export const executeRequest = (req) =>
...
@@ -206,7 +206,6 @@ export const executeRequest = (req) =>
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
req
.
contextUrl
=
parseUrl
(
specSelectors
.
url
()).
toString
()
req
.
contextUrl
=
parseUrl
(
specSelectors
.
url
()).
toString
()
if
(
op
&&
op
.
operationId
)
{
if
(
op
&&
op
.
operationId
)
{
req
.
operationId
=
op
.
operationId
req
.
operationId
=
op
.
operationId
}
else
if
(
op
&&
pathName
&&
method
)
{
}
else
if
(
op
&&
pathName
&&
method
)
{
...
...
src/core/plugins/spec/reducers.js
浏览文件 @
b6eb2321
...
@@ -40,9 +40,10 @@ export default {
...
@@ -40,9 +40,10 @@ export default {
},
},
[
UPDATE_PARAM
]:
(
state
,
{
payload
}
)
=>
{
[
UPDATE_PARAM
]:
(
state
,
{
payload
}
)
=>
{
let
{
path
,
paramName
,
value
,
isXml
}
=
payload
let
{
path
,
paramName
,
paramIn
,
value
,
isXml
}
=
payload
return
state
.
updateIn
(
[
"
resolved
"
,
"
paths
"
,
...
path
,
"
parameters
"
],
fromJS
([]),
parameters
=>
{
return
state
.
updateIn
(
[
"
resolved
"
,
"
paths
"
,
...
path
,
"
parameters
"
],
fromJS
([]),
parameters
=>
{
const
index
=
parameters
.
findIndex
(
p
=>
p
.
get
(
"
name
"
)
===
paramName
)
const
index
=
parameters
.
findIndex
(
p
=>
p
.
get
(
"
name
"
)
===
paramName
&&
p
.
get
(
"
in
"
)
===
paramIn
)
if
(
!
(
value
instanceof
win
.
File
))
{
if
(
!
(
value
instanceof
win
.
File
))
{
value
=
fromJSOrdered
(
value
)
value
=
fromJSOrdered
(
value
)
}
}
...
...
src/core/plugins/spec/selectors.js
浏览文件 @
b6eb2321
...
@@ -260,10 +260,10 @@ export const allowTryItOutFor = () => {
...
@@ -260,10 +260,10 @@ export const allowTryItOutFor = () => {
}
}
// Get the parameter value by parameter name
// Get the parameter value by parameter name
export
function
getParameter
(
state
,
pathMethod
,
name
)
{
export
function
getParameter
(
state
,
pathMethod
,
name
,
inType
)
{
let
params
=
spec
(
state
).
getIn
([
"
paths
"
,
...
pathMethod
,
"
parameters
"
],
fromJS
([]))
let
params
=
spec
(
state
).
getIn
([
"
paths
"
,
...
pathMethod
,
"
parameters
"
],
fromJS
([]))
return
params
.
filter
(
(
p
)
=>
{
return
params
.
filter
(
(
p
)
=>
{
return
Map
.
isMap
(
p
)
&&
p
.
get
(
"
name
"
)
===
name
return
Map
.
isMap
(
p
)
&&
p
.
get
(
"
name
"
)
===
name
&&
p
.
get
(
"
in
"
)
===
inType
}).
first
()
}).
first
()
}
}
...
@@ -280,7 +280,7 @@ export function parameterValues(state, pathMethod, isXml) {
...
@@ -280,7 +280,7 @@ export function parameterValues(state, pathMethod, isXml) {
let
params
=
spec
(
state
).
getIn
([
"
paths
"
,
...
pathMethod
,
"
parameters
"
],
fromJS
([]))
let
params
=
spec
(
state
).
getIn
([
"
paths
"
,
...
pathMethod
,
"
parameters
"
],
fromJS
([]))
return
params
.
reduce
(
(
hash
,
p
)
=>
{
return
params
.
reduce
(
(
hash
,
p
)
=>
{
let
value
=
isXml
&&
p
.
get
(
"
in
"
)
===
"
body
"
?
p
.
get
(
"
value_xml
"
)
:
p
.
get
(
"
value
"
)
let
value
=
isXml
&&
p
.
get
(
"
in
"
)
===
"
body
"
?
p
.
get
(
"
value_xml
"
)
:
p
.
get
(
"
value
"
)
return
hash
.
set
(
p
.
get
(
"
name
"
)
,
value
)
return
hash
.
set
(
`
${
p
.
get
(
"
in
"
)}
.
${
p
.
get
(
"
name
"
)}
`
,
value
)
},
fromJS
({}))
},
fromJS
({}))
}
}
...
...
src/core/utils.js
浏览文件 @
b6eb2321
...
@@ -500,12 +500,25 @@ export const validateString = ( val ) => {
...
@@ -500,12 +500,25 @@ export const validateString = ( val ) => {
}
}
}
}
export
const
validateDateTime
=
(
val
)
=>
{
if
(
isNaN
(
Date
.
parse
(
val
)))
{
return
"
Value must be a DateTime
"
}
}
export
const
validateGuid
=
(
val
)
=>
{
if
(
!
/^
[
{(
]?[
0-9a-f
]{8}
-
[
0-9a-f
]{4}
-
[
1-5
][
0-9a-f
]{3}
-
[
89ab
][
0-9a-f
]{3}
-
[
0-9a-f
]{12}[
)}
]?
$/
.
test
(
val
))
{
return
"
Value must be a Guid
"
}
}
// validation of parameters before execute
// validation of parameters before execute
export
const
validateParam
=
(
param
,
isXml
)
=>
{
export
const
validateParam
=
(
param
,
isXml
)
=>
{
let
errors
=
[]
let
errors
=
[]
let
value
=
isXml
&&
param
.
get
(
"
in
"
)
===
"
body
"
?
param
.
get
(
"
value_xml
"
)
:
param
.
get
(
"
value
"
)
let
value
=
isXml
&&
param
.
get
(
"
in
"
)
===
"
body
"
?
param
.
get
(
"
value_xml
"
)
:
param
.
get
(
"
value
"
)
let
required
=
param
.
get
(
"
required
"
)
let
required
=
param
.
get
(
"
required
"
)
let
type
=
param
.
get
(
"
type
"
)
let
type
=
param
.
get
(
"
type
"
)
let
format
=
param
.
get
(
"
format
"
)
/*
/*
If the parameter is required OR the parameter has a value (meaning optional, but filled in)
If the parameter is required OR the parameter has a value (meaning optional, but filled in)
...
@@ -528,7 +541,14 @@ export const validateParam = (param, isXml) => {
...
@@ -528,7 +541,14 @@ export const validateParam = (param, isXml) => {
}
}
if
(
type
===
"
string
"
)
{
if
(
type
===
"
string
"
)
{
let
err
=
validateString
(
value
)
let
err
if
(
format
===
"
date-time
"
)
{
err
=
validateDateTime
(
value
)
}
else
if
(
format
===
"
uuid
"
)
{
err
=
validateGuid
(
value
)
}
else
{
err
=
validateString
(
value
)
}
if
(
!
err
)
return
errors
if
(
!
err
)
return
errors
errors
.
push
(
err
)
errors
.
push
(
err
)
}
else
if
(
type
===
"
boolean
"
)
{
}
else
if
(
type
===
"
boolean
"
)
{
...
...
test/core/plugins/spec/selectors.js
浏览文件 @
b6eb2321
...
@@ -29,8 +29,8 @@ describe("spec plugin - selectors", function(){
...
@@ -29,8 +29,8 @@ describe("spec plugin - selectors", function(){
"
/one
"
:
{
"
/one
"
:
{
get
:
{
get
:
{
parameters
:
[
parameters
:
[
{
name
:
"
one
"
,
value
:
1
},
{
name
:
"
one
"
,
in
:
"
query
"
,
value
:
1
},
{
name
:
"
two
"
,
value
:
"
duos
"
}
{
name
:
"
two
"
,
in
:
"
query
"
,
value
:
"
duos
"
}
]
]
}
}
}
}
...
@@ -43,8 +43,8 @@ describe("spec plugin - selectors", function(){
...
@@ -43,8 +43,8 @@ describe("spec plugin - selectors", function(){
// Then
// Then
expect
(
paramValues
.
toJS
()).
toEqual
({
expect
(
paramValues
.
toJS
()).
toEqual
({
one
:
1
,
"
query.one
"
:
1
,
two
:
"
duos
"
"
query.two
"
:
"
duos
"
})
})
})
})
...
...
test/core/utils.js
浏览文件 @
b6eb2321
/* eslint-env mocha */
/* eslint-env mocha */
import
expect
from
"
expect
"
import
expect
from
"
expect
"
import
{
fromJS
,
OrderedMap
}
from
"
immutable
"
import
{
fromJS
,
OrderedMap
}
from
"
immutable
"
import
{
mapToList
,
validateNumber
,
validateInteger
,
validateParam
,
validateFile
,
fromJSOrdered
,
getAcceptControllingResponse
,
createDeepLinkPath
,
escapeDeepLinkPath
}
from
"
core/utils
"
import
{
mapToList
,
validate
DateTime
,
validateGuid
,
validate
Number
,
validateInteger
,
validateParam
,
validateFile
,
fromJSOrdered
,
getAcceptControllingResponse
,
createDeepLinkPath
,
escapeDeepLinkPath
}
from
"
core/utils
"
import
win
from
"
core/window
"
import
win
from
"
core/window
"
describe
(
"
utils
"
,
function
()
{
describe
(
"
utils
"
,
function
()
{
...
@@ -158,7 +158,7 @@ describe("utils", function() {
...
@@ -158,7 +158,7 @@ describe("utils", function() {
})
})
})
})
describe
(
"
validateFile
"
,
function
()
{
describe
(
"
validateFile
"
,
function
()
{
let
errorMessage
=
"
Value must be a file
"
let
errorMessage
=
"
Value must be a file
"
it
(
"
validates against objects which are instances of 'File'
"
,
function
()
{
it
(
"
validates against objects which are instances of 'File'
"
,
function
()
{
...
@@ -171,6 +171,33 @@ describe("utils", function() {
...
@@ -171,6 +171,33 @@ describe("utils", function() {
})
})
})
})
describe
(
"
validateDateTime
"
,
function
()
{
let
errorMessage
=
"
Value must be a DateTime
"
it
(
"
doesn't return for valid dates
"
,
function
()
{
expect
(
validateDateTime
(
"
Mon, 25 Dec 1995 13:30:00 +0430
"
)).
toBeFalsy
()
})
it
(
"
returns a message for invalid input'
"
,
function
()
{
expect
(
validateDateTime
(
null
)).
toEqual
(
errorMessage
)
expect
(
validateDateTime
(
"
string
"
)).
toEqual
(
errorMessage
)
})
})
describe
(
"
validateGuid
"
,
function
()
{
let
errorMessage
=
"
Value must be a Guid
"
it
(
"
doesn't return for valid guid
"
,
function
()
{
expect
(
validateGuid
(
"
8ce4811e-cec5-4a29-891a-15d1917153c1
"
)).
toBeFalsy
()
expect
(
validateGuid
(
"
{8ce4811e-cec5-4a29-891a-15d1917153c1}
"
)).
toBeFalsy
()
})
it
(
"
returns a message for invalid input'
"
,
function
()
{
expect
(
validateGuid
(
1
)).
toEqual
(
errorMessage
)
expect
(
validateGuid
(
"
string
"
)).
toEqual
(
errorMessage
)
})
})
describe
(
"
validateParam
"
,
function
()
{
describe
(
"
validateParam
"
,
function
()
{
let
param
=
null
let
param
=
null
let
result
=
null
let
result
=
null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录