Merge branch 'master' into public-gone

This commit is contained in:
shockey
2017-04-06 16:51:38 -07:00
committed by GitHub
16 changed files with 141 additions and 72 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAsdA;AAkoJA;AAyiCA;;;;;AAskCA;AA66IA;AA27FA;AAuwGA;AAymEA;AAm+CA;AA+/CA;AA+rCA;AA65DA;AAs0IA;;;;;;;;;;;;;;AAgyFA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAi9BA;;;;;;AA6xEA;AAq2FA;;;;;AA23CA;AA2qFA;AAo2CA;AAokCA;AAkhDA;AAwvEA;AAq+FA;;;;;;;;;AAwyBA;AA2zIA;AAi4DA;AA6tDA;;;;;;AAg3BA;AA8iHA;AAipGA","sourceRoot":""} {"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAsdA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA66IA;AA27FA;AAuwGA;AAilFA;AAikFA;AAs9CA;AA8jDA;AA2qCA;AA4tEA;AAgkIA;;;;;;;;;;;;;;AAw4GA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAi9BA;;;;;;AAqtEA;AA+zFA;;;;;AA23CA;AA2qFA;AAq2CA;AA0kCA;AAs/CA;AA0wEA;AA49FA;;;;;;;;;AA20BA;AA2zIA;AAi4DA;AA6tDA","sourceRoot":""}

File diff suppressed because one or more lines are too long

2
dist/swagger-ui.css vendored

File diff suppressed because one or more lines are too long

18
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmwCA;AAoyHA;AA2wHA;AA07FA;AAmnCA;AAu/BA;AAmiCA;AA44BA","sourceRoot":""} {"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmwCA;AAoyHA;AA2wHA;AA07FA;AA+nCA;AAohCA;AAghCA;AAk4BA","sourceRoot":""}

View File

@@ -145,7 +145,7 @@ export default class Oauth2 extends React.Component {
} }
{ {
( flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && ( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) &&
( !isAuthorized || isAuthorized && this.state.clientId) && <Row> ( !isAuthorized || isAuthorized && this.state.clientId) && <Row>
<label htmlFor="client_id">client_id:</label> <label htmlFor="client_id">client_id:</label>
<Col tablet={10} desktop={10}> <Col tablet={10} desktop={10}>
@@ -159,7 +159,7 @@ export default class Oauth2 extends React.Component {
} }
{ {
( flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row> ( flow === APPLICATION || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row>
<label htmlFor="client_secret">client_secret:</label> <label htmlFor="client_secret">client_secret:</label>
<Col tablet={10} desktop={10}> <Col tablet={10} desktop={10}>
{ {
@@ -205,7 +205,7 @@ export default class Oauth2 extends React.Component {
} ) } )
} }
<div className="auth-btn-wrapper"> <div className="auth-btn-wrapper">
{ isValid && flow !== APPLICATION && { isValid &&
( isAuthorized ? <Button className="btn modal-btn auth authorize" onClick={ this.logout }>Logout</Button> ( isAuthorized ? <Button className="btn modal-btn auth authorize" onClick={ this.logout }>Logout</Button>
: <Button className="btn modal-btn auth authorize" onClick={ this.authorize }>Authorize</Button> : <Button className="btn modal-btn auth authorize" onClick={ this.authorize }>Authorize</Button>
) )

View File

@@ -19,7 +19,7 @@ export default class Curl extends React.Component {
<div> <div>
<h4>Curl</h4> <h4>Curl</h4>
<div className="copy-paste"> <div className="copy-paste">
<textarea onFocus={this.handleFocus} className="curl" style={{ whiteSpace: "normal" }} defaultValue={curl}></textarea> <textarea onFocus={this.handleFocus} className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
</div> </div>
</div> </div>
) )

View File

@@ -68,7 +68,7 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
{ error.get("message") } { error.get("message") }
</span> </span>
<div> <div>
{ errorLine ? <a onClick={jumpToLine.bind(null, errorLine)}>Jump to line { errorLine }</a> : null } { errorLine && jumpToLine ? <a onClick={jumpToLine.bind(null, errorLine)}>Jump to line { errorLine }</a> : null }
</div> </div>
</div> </div>
} }
@@ -77,11 +77,23 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
} }
const SpecErrorItem = ( { error, jumpToLine } ) => { const SpecErrorItem = ( { error, jumpToLine } ) => {
let locationMessage = null
if(error.get("path")) {
if(List.isList(error.get("path"))) {
locationMessage = <small>at { error.get("path").join(".") }</small>
} else {
locationMessage = <small>at { error.get("path") }</small>
}
} else if(error.get("line") && !jumpToLine) {
locationMessage = <small>on line { error.get("line") }</small>
}
return ( return (
<div className="error-wrapper"> <div className="error-wrapper">
{ !error ? null : { !error ? null :
<div> <div>
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }{ error.get("path") ? <small> at {List.isList(error.get("path")) ? error.get("path").join(".") : error.get("path")}</small>: null }</h4> <h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }&nbsp;{ locationMessage }</h4>
<span style={{ whiteSpace: "pre-line"}}>{ error.get("message") }</span> <span style={{ whiteSpace: "pre-line"}}>{ error.get("message") }</span>
<div> <div>
{ jumpToLine ? ( { jumpToLine ? (
@@ -106,6 +118,10 @@ ThrownErrorItem.propTypes = {
jumpToLine: PropTypes.func jumpToLine: PropTypes.func
} }
ThrownErrorItem.defaultProps = {
jumpToLine: null
}
SpecErrorItem.propTypes = { SpecErrorItem.propTypes = {
error: PropTypes.object.isRequired, error: PropTypes.object.isRequired,
jumpToLine: PropTypes.func jumpToLine: PropTypes.func

View File

@@ -202,11 +202,12 @@ export default class Operation extends React.Component {
pathMethod={ [path, method] } pathMethod={ [path, method] }
/> />
{!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ? <Schemes schemes={ schemes } {!tryItOutEnabled || !allowTryItOut ? null : schemes && schemes.size ? <div className="opblock-schemes">
path={ path } <Schemes schemes={ schemes }
method={ method } path={ path }
specActions={ specActions }/> method={ method }
: null specActions={ specActions }/>
</div> : null
} }
<div className={(!tryItOutEnabled || !response || !allowTryItOut) ? "execute-wrapper" : "btn-group"}> <div className={(!tryItOutEnabled || !response || !allowTryItOut) ? "execute-wrapper" : "btn-group"}>

View File

@@ -31,7 +31,7 @@ export default class Schemes extends React.Component {
return ( return (
<label htmlFor="schemes"> <label htmlFor="schemes">
<span>Schemes</span> <span className="schemes-title">Schemes</span>
<select onChange={ this.onChange }> <select onChange={ this.onChange }>
{ schemes.valueSeq().map( { schemes.valueSeq().map(
( scheme ) => <option value={ scheme } key={ scheme }>{ scheme }</option> ( scheme ) => <option value={ scheme } key={ scheme }>{ scheme }</option>

View File

@@ -14,6 +14,11 @@ export default function authorize ( auth, authActions, errActions, configs ) {
return return
} }
if (flow === "application") {
authActions.authorizeOauth2Application(auth)
return
}
// todo move to parser // todo move to parser
if ( !redirectUrl ) { if ( !redirectUrl ) {
errActions.newAuthErr( { errActions.newAuthErr( {

View File

@@ -119,3 +119,35 @@ export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } )
}) })
.catch(err => { errActions.newAuthErr( err ) }) .catch(err => { errActions.newAuthErr( err ) })
} }
export const authorizeOauth2Application = ( auth ) => ( { fn, authActions, errActions } ) => {
let { schema, scopes, name, clientId, clientSecret } = auth
fn.fetch(schema.get("tokenUrl"), {
method: "post", headers: {
"Accept":"application/json, text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded"
},
body: "grant_type=client_credentials" +
"&client_id=" + encodeURIComponent(clientId) +
"&client_secret=" + encodeURIComponent(clientSecret) +
"&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
})
.then(function (response) {
if ( !response.ok ) {
errActions.newAuthErr( {
authId: name,
level: "error",
source: "auth",
message: response.statusText
} )
return
} else {
response.json()
.then(function (json){
authActions.authorizeOauth2({ auth, token: json})
})
}
})
.catch(err => { errActions.newAuthErr( err ) })
}

View File

@@ -14,8 +14,9 @@ export default function downloadUrlPlugin (toolbox) {
fetch({ fetch({
url, url,
loadSpec: true, loadSpec: true,
credentials: "same-origin",
headers: { headers: {
"Accept": "application/json" "Accept": "application/json,*/*"
} }
}).then(next,next) }).then(next,next)

View File

@@ -24,6 +24,11 @@
@include text_code(); @include text_code();
} }
small
{
color: #666;
}
} }
hgroup hgroup

View File

@@ -307,6 +307,16 @@ body
@include method($_color-disabled); @include method($_color-disabled);
} }
.opblock-schemes
{
padding: 8px 20px;
.schemes-title
{
padding: 0 10px 0 0;
}
}
} }