Merge branch 'master' into master
This commit is contained in:
@@ -8,7 +8,6 @@ RUN mkdir -p /run/nginx
|
|||||||
COPY nginx.conf /etc/nginx/
|
COPY nginx.conf /etc/nginx/
|
||||||
|
|
||||||
# copy swagger files to the `/js` folder
|
# copy swagger files to the `/js` folder
|
||||||
ADD ./public/* /usr/share/nginx/html/
|
|
||||||
ADD ./dist/* /usr/share/nginx/html/
|
ADD ./dist/* /usr/share/nginx/html/
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
|
|||||||
|
|
||||||
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
|
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
|
||||||
------------------ | ------------ | -------------------------- | ----- | ------
|
------------------ | ------------ | -------------------------- | ----- | ------
|
||||||
3.0.4 | 2017-03-19 | 2.0 | [tag v3.0.4](https://github.com/swagger-api/swagger-ui/tree/v3.0.4) |
|
3.0.5 | 2017-03-19 | 2.0 | [tag v3.0.5](https://github.com/swagger-api/swagger-ui/tree/v3.0.5) |
|
||||||
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
|
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10) |
|
||||||
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
|
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
|
||||||
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
|
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
|
||||||
@@ -39,7 +39,7 @@ Will start nginx with swagger-ui on port 80.
|
|||||||
- Node 6.x
|
- Node 6.x
|
||||||
- NPM 3.x
|
- NPM 3.x
|
||||||
|
|
||||||
If you just want to see your specs, open `public/index.html` in your browser directly from your filesystem.
|
If you just want to see your specs, open `dist/index.html` in your browser directly from your filesystem.
|
||||||
|
|
||||||
If you'd like to make modifications to the codebase, run the dev server with: `npm run dev`.
|
If you'd like to make modifications to the codebase, run the dev server with: `npm run dev`.
|
||||||
|
|
||||||
|
|||||||
40
composer.json
Normal file
40
composer.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "swagger-api/swagger-ui",
|
||||||
|
"description": " Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.",
|
||||||
|
"keywords": [
|
||||||
|
"Swagger",
|
||||||
|
"OpenAPI",
|
||||||
|
"specification",
|
||||||
|
"documentation",
|
||||||
|
"API",
|
||||||
|
"UI"
|
||||||
|
],
|
||||||
|
"homepage": "http://swagger.io",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Anna Bodnia",
|
||||||
|
"email": "anna.bodnia@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Buu Nguyen",
|
||||||
|
"email": "buunguyen@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Josh Ponelat",
|
||||||
|
"email": "jponelat@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kyle Shockey",
|
||||||
|
"email": "kyleshockey1@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Robert Barnwell",
|
||||||
|
"email": "robert@robertismy.name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sahar Jafari",
|
||||||
|
"email": "shr.jafari@gmail.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
<title>Swagger UI</title>
|
<title>Swagger UI</title>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||||
<link rel="icon" type="image/png" href="../public/favicon-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||||
<link rel="icon" type="image/png" href="../public/favicon-16x16.png" sizes="16x16" />
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
<style>
|
<style>
|
||||||
html
|
html
|
||||||
{
|
{
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
6
dist/index.html
vendored
6
dist/index.html
vendored
@@ -6,8 +6,8 @@
|
|||||||
<title>Swagger UI</title>
|
<title>Swagger UI</title>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||||
<link rel="icon" type="image/png" href="../public/favicon-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||||
<link rel="icon" type="image/png" href="../public/favicon-16x16.png" sizes="16x16" />
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
<style>
|
<style>
|
||||||
html
|
html
|
||||||
{
|
{
|
||||||
@@ -90,4 +90,4 @@ window.onload = function() {
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
91
dist/swagger-ui-bundle.js
vendored
91
dist/swagger-ui-bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-bundle.js.map
vendored
2
dist/swagger-ui-bundle.js.map
vendored
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA66IA;AA27FA;AAuwGA;AAilFA;AAikFA;AAs9CA;AA8jDA;AA2qCA;AA4tEA;AAgkIA;;;;;;;;;;;;;;AAw4GA;AAyoIA;AAiuJA;AA8kHA;AAonGA;AAukEA;AA02DA;AAyxDA;AAw6BA;;;;;;AA8vEA;AA+zFA;;;;;AA23CA;AA2qFA;AAq2CA;AA0kCA;AAs/CA;AA0wEA;AA49FA;;;;;;;;;AA20BA;AA2zIA;AAi4DA;AA6tDA","sourceRoot":""}
|
||||||
4
dist/swagger-ui-standalone-preset.js
vendored
4
dist/swagger-ui-standalone-preset.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-standalone-preset.js.map
vendored
2
dist/swagger-ui-standalone-preset.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AAqTA;AAyiGA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA2SA;AAyiGA","sourceRoot":""}
|
||||||
2
dist/swagger-ui.css
vendored
2
dist/swagger-ui.css
vendored
File diff suppressed because one or more lines are too long
14
dist/swagger-ui.js
vendored
14
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui.js.map
vendored
2
dist/swagger-ui.js.map
vendored
@@ -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;;;;;;AAuwCA;AAoyHA;AA2wHA;AA07FA;AA+nCA;AAohCA;AAghCA;AAk4BA","sourceRoot":""}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui",
|
"name": "swagger-ui",
|
||||||
"version": "3.0.4",
|
"version": "3.0.5",
|
||||||
"main": "dist/swagger-ui.js",
|
"main": "dist/swagger-ui.js",
|
||||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"reselect": "2.5.3",
|
"reselect": "2.5.3",
|
||||||
"serialize-error": "2.0.0",
|
"serialize-error": "2.0.0",
|
||||||
"shallowequal": "0.2.2",
|
"shallowequal": "0.2.2",
|
||||||
"swagger-client": "^3.0.4",
|
"swagger-client": "^3.0.5",
|
||||||
"whatwg-fetch": "0.11.1",
|
"whatwg-fetch": "0.11.1",
|
||||||
"worker-loader": "^0.7.1",
|
"worker-loader": "^0.7.1",
|
||||||
"xml": "1.0.1",
|
"xml": "1.0.1",
|
||||||
|
|||||||
@@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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") } { 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
|
||||||
|
|||||||
@@ -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"}>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -68,22 +68,24 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
var system = store.getSystem()
|
var system = store.getSystem()
|
||||||
let queryConfig = parseSeach()
|
let queryConfig = parseSeach()
|
||||||
|
|
||||||
const downloadSpec = () => {
|
const downloadSpec = (fetchedConfig) => {
|
||||||
if(typeof constructorConfig !== "object") {
|
if(typeof constructorConfig !== "object") {
|
||||||
return system
|
return system
|
||||||
}
|
}
|
||||||
|
|
||||||
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
||||||
let mergedConfig = deepExtend({}, constructorConfig, localConfig, queryConfig)
|
let mergedConfig = deepExtend({}, constructorConfig, localConfig, fetchedConfig || {}, queryConfig)
|
||||||
store.setConfigs(filterConfigs(mergedConfig))
|
store.setConfigs(filterConfigs(mergedConfig))
|
||||||
|
|
||||||
if(!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
if (fetchedConfig !== null) {
|
||||||
system.specActions.updateUrl("")
|
if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
||||||
system.specActions.updateLoadingStatus("success")
|
system.specActions.updateUrl("")
|
||||||
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
|
system.specActions.updateLoadingStatus("success")
|
||||||
} else if(system.specActions.download && mergedConfig.url) {
|
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
|
||||||
system.specActions.updateUrl(mergedConfig.url)
|
} else if (system.specActions.download && mergedConfig.url) {
|
||||||
system.specActions.download(mergedConfig.url)
|
system.specActions.updateUrl(mergedConfig.url)
|
||||||
|
system.specActions.download(mergedConfig.url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mergedConfig.dom_id) {
|
if(mergedConfig.dom_id) {
|
||||||
@@ -95,7 +97,9 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
return system
|
return system
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!system.specActions.getConfigByUrl || (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec))) {
|
let configUrl = queryConfig.config || constructorConfig.configUrl
|
||||||
|
|
||||||
|
if (!configUrl || !system.specActions.getConfigByUrl || system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(configUrl, downloadSpec)) {
|
||||||
return downloadSpec()
|
return downloadSpec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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( {
|
||||||
|
|||||||
@@ -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 ) })
|
||||||
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import YAML from "js-yaml"
|
import YAML from "js-yaml"
|
||||||
import { parseSeach } from "core/utils"
|
|
||||||
import yamlConfig from "../../../swagger-config.yaml"
|
import yamlConfig from "../../../swagger-config.yaml"
|
||||||
|
|
||||||
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||||
@@ -27,9 +26,7 @@ export default function configPlugin (toolbox) {
|
|||||||
return fetch(url)
|
return fetch(url)
|
||||||
},
|
},
|
||||||
|
|
||||||
getConfigByUrl: (callback)=> ({ specActions }) => {
|
getConfigByUrl: (configUrl, cb)=> ({ specActions }) => {
|
||||||
let config = parseSeach()
|
|
||||||
let configUrl = config.config
|
|
||||||
if (configUrl) {
|
if (configUrl) {
|
||||||
return specActions.downloadConfig(configUrl).then(next, next)
|
return specActions.downloadConfig(configUrl).then(next, next)
|
||||||
}
|
}
|
||||||
@@ -37,9 +34,12 @@ export default function configPlugin (toolbox) {
|
|||||||
function next(res) {
|
function next(res) {
|
||||||
if (res instanceof Error || res.status >= 400) {
|
if (res instanceof Error || res.status >= 400) {
|
||||||
specActions.updateLoadingStatus("failedConfig")
|
specActions.updateLoadingStatus("failedConfig")
|
||||||
|
specActions.updateLoadingStatus("failedConfig")
|
||||||
|
specActions.updateUrl("")
|
||||||
console.error(res.statusText + " " + configUrl)
|
console.error(res.statusText + " " + configUrl)
|
||||||
|
cb(null)
|
||||||
} else {
|
} else {
|
||||||
callback(parseYamlConfig(res.text))
|
cb(parseYamlConfig(res.text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default class StandaloneLayout extends React.Component {
|
|||||||
) : null }
|
) : null }
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{ schemes && schemes.size && securityDefinitions ? (
|
{ schemes && schemes.size || securityDefinitions ? (
|
||||||
<div className="scheme-container">
|
<div className="scheme-container">
|
||||||
<Col className="schemes wrapper" mobile={12}>
|
<Col className="schemes wrapper" mobile={12}>
|
||||||
{ schemes && schemes.size ? (
|
{ schemes && schemes.size ? (
|
||||||
@@ -79,16 +79,6 @@ export default class StandaloneLayout extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
) : null }
|
) : null }
|
||||||
|
|
||||||
{ (!schemes || !schemes.size) && securityDefinitions ? (
|
|
||||||
<div className="scheme-container">
|
|
||||||
<Col className="schemes wrapper" mobile={12}>
|
|
||||||
{ securityDefinitions ? (
|
|
||||||
<AuthorizeBtn />
|
|
||||||
) : null }
|
|
||||||
</Col>
|
|
||||||
</div>
|
|
||||||
) : null }
|
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col mobile={12} desktop={12} >
|
<Col mobile={12} desktop={12} >
|
||||||
<Operations/>
|
<Operations/>
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
|
|
||||||
@include text_code();
|
@include text_code();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
small
|
||||||
|
{
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hgroup
|
hgroup
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user