Compare commits

..
54 Commits
Author SHA1 Message Date
shockey f14d8067c4 Merge pull request #3005 from shockey/v/3.0.8
v/3.0.8
2017-04-28 19:55:24 -07:00
Kyle Shockey c08f3c230b v3.0.8 (fixes #2923 #2889) 2017-04-28 19:51:37 -07:00
Kyle Shockey 96f4b65dfa Rebuild dist 2017-04-28 19:40:39 -07:00
Kyle Shockey 69fd57f17f Increment swagger-client version 2017-04-28 18:43:24 -07:00
shockey f85fdb7835 Merge pull request #3004 from shockey/ft/3003-version-info
Add global variable that exposes UI version
2017-04-28 10:46:27 -07:00
Kyle Shockey 15d43886a3 Attach information to version object 2017-04-28 10:41:47 -07:00
Kyle Shockey 0e62d920e8 Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/3003-version-info 2017-04-28 10:29:06 -07:00
Kyle Shockey b6c3f91127 Fix #3003 2017-04-28 10:06:43 -07:00
shockey 11e9bbfdbb Merge pull request #2958 from swagger-api/feature/older-react
Remove object-assign
2017-04-28 09:38:51 -07:00
shockey d2c3078a79 Merge branch 'master' into feature/older-react 2017-04-28 09:21:15 -07:00
shockey dd11740359 Merge pull request #3002 from Minasokoni/searchbar-update
Updated searchbar sizing and added onSubmit func
2017-04-28 09:06:48 -07:00
Robert Barnwell 8a1e447f0f Merge branch 'master' into searchbar-update 2017-04-28 08:39:16 -07:00
Minasokoni ca808e9d18 updated searchbar sizing 2017-04-28 08:36:32 -07:00
Josh Ponelat f5e89dc02e build 2017-04-28 11:19:39 +02:00
Josh Ponelat 2cff912261 remove object-assign dep ( which was missing from package.json ) 2017-04-28 11:17:59 +02:00
shockey 5a5a4d016b Merge pull request #2997 from shockey/Minasokoni-container-name-change
Changed main container className
2017-04-27 20:12:47 -07:00
Kyle Shockey f1f912a46f Merge branch 'master' of github.com:swagger-api/swagger-ui into Minasokoni-container-name-change 2017-04-27 20:04:52 -07:00
Kyle Shockey 518e2ec732 Merge branch 'master' into Minasokoni-container-name-change 2017-04-27 19:57:29 -07:00
Anna 862301e6df Merge pull request #2993 from bodnia/fix-2870
fix #2870
2017-04-27 19:14:16 +02:00
Anna Bodnia 374ac9cbbb fix #2870 2017-04-27 20:09:05 +03:00
Kyle Shockey 7d87c9d680 Fix typo in container classname 2017-04-27 09:09:09 -07:00
Kyle Shockey 78336e99aa Merge branch 'container-name-change' of https://github.com/Minasokoni/swagger-ui into Minasokoni-container-name-change 2017-04-27 09:08:55 -07:00
Anna a7c90e2d77 Merge pull request #2992 from bodnia/fix-2844
#2844 fix accessCode flow
2017-04-27 18:06:12 +02:00
Anna Bodnia 87a23c7c9e fix eslint errors 2017-04-27 19:01:27 +03:00
Anna Bodnia d013e7a05c #2844 fix accessCode flow 2017-04-27 18:55:25 +03:00
Minasokoni 198f9b6874 changed container classname 2017-04-27 08:35:33 -07:00
shockey 210b20eea8 Merge pull request #2985 from swagger-api/shockey-patch-2
Update webpack-dist.config.js
2017-04-26 23:03:20 -07:00
shockey f755f80072 Update webpack-dist.config.js 2017-04-26 22:43:54 -07:00
shockey 8137f25cc7 Merge pull request #2983 from shockey/bug/2937-core-missing-modules
Bug/2937 core missing modules
2017-04-26 19:42:00 -07:00
shockey a8ff714eee Merge branch 'master' into bug/2937-core-missing-modules 2017-04-26 18:34:58 -07:00
Kyle Shockey 494048e809 Fix #2937 2017-04-26 18:23:57 -07:00
Kyle Shockey bcd36ff667 Fix #2937 2017-04-26 18:11:27 -07:00
Ron 38ed6192c3 Merge pull request #2982 from swagger-api/issue_template
new issue_template
2017-04-26 15:58:29 -07:00
Ron b9df212ccc new issue_template 2017-04-26 15:50:35 -07:00
Anna 22dc506b13 Merge pull request #2977 from bodnia/issue-2898
#2898  operationsSorter config description
2017-04-26 17:39:39 +02:00
Anna da7210d328 Merge branch 'master' into issue-2898 2017-04-26 17:33:51 +02:00
Anna ca05b3e255 Merge pull request #2979 from bodnia/fix-oauth2-issue
fixes password, application oauth2 flows
2017-04-26 17:11:23 +02:00
Anna Bodnia 891c321c8a build 2017-04-26 18:06:26 +03:00
Anna Bodnia cecf0670b7 Merge branch 'master' into fix-oauth2-issue
# Conflicts:
#	dist/swagger-ui.css
2017-04-26 17:53:53 +03:00
Anna Bodnia bb73dd49d8 fixes password, application oauth2 flows 2017-04-26 17:50:09 +03:00
Anna Bodnia eab557f470 #2898 operationsSorter config description 2017-04-26 11:53:27 +03:00
shockey ac25a5dac6 Merge pull request #2974 from swagger-api/shockey-patch-1
Update README.md
2017-04-25 13:33:02 -07:00
shockey 073313df6f Merge branch 'master' into shockey-patch-1 2017-04-25 11:23:36 -07:00
shockey 26912b094f Merge pull request #2611 from elopio/snapcraft
Add the packaging metadata to build the swagger-ui snap
2017-04-25 11:23:21 -07:00
shockey 6f6f76caf4 Update README.md 2017-04-25 11:15:54 -07:00
shockey bbb3035bac Merge branch 'master' into snapcraft 2017-04-25 10:23:55 -07:00
shockey 6841732367 Merge pull request #2967 from Minasokoni/textformating
Headers now break onto their own lines
2017-04-25 10:23:06 -07:00
Robert Barnwell 1a417b3c6c Merge branch 'master' into textformating 2017-04-25 00:22:46 -07:00
Minasokoni aa327ed256 headers now break onto their own lines 2017-04-25 00:20:46 -07:00
Leo Arias 808f8d2827 Merge branch 'master' into snapcraft 2017-04-24 21:42:31 -06:00
Ron 4c40fa192b Merge pull request #2957 from deepu105/patch-1
Correct url in README file
2017-04-24 08:24:50 -07:00
Deepu K Sasidharan 2c6bd5d988 Correct url in README file
The npmjs.com/package/swagger-ui-dist url in the readme is wrong as it tries to load within github domain
2017-04-23 11:29:03 +02:00
Leo Arias 6a36b58977 Add the daemon 2017-01-14 05:15:39 +00:00
Leo Arias 7169ea32c9 Add the packaging metadata to build the swagger-ui snap 2017-01-14 04:35:51 +00:00
24 changed files with 261 additions and 196 deletions
+3
View File
@@ -0,0 +1,3 @@
When reporting an issue, please provide the following details:
- swagger-ui version
- a swagger file reproducing the issue
+3 -2
View File
@@ -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
------------------ | ------------ | -------------------------- | ----- | ------
3.0.7 | 2017-03-19 | 2.0 | [tag v3.0.7](https://github.com/swagger-api/swagger-ui/tree/v3.0.7) |
3.0.8 | 2017-03-19 | 2.0 | [tag v3.0.8](https://github.com/swagger-api/swagger-ui/tree/v3.0.8) |
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.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
@@ -75,7 +75,7 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
})
```
If you'd like to use the bundle files via npm, check out the [`swagger-ui-dist` package](npmjs.com/package/swagger-ui-dist).
If you'd like to use the bundle files via npm, check out the [`swagger-ui-dist` package](https://www.npmjs.com/package/swagger-ui-dist).
#### Parameters
@@ -86,6 +86,7 @@ spec | A JSON object describing the OpenAPI Specification. When used, the `url`
validatorUrl | By default, Swagger-UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to `null` will disable validation.
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
oauth2RedirectUrl | OAuth redirect URL
operationsSorter | Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.
+7 -37
View File
@@ -8,11 +8,13 @@
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var isValid, qp;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
@@ -33,51 +35,19 @@
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
createForm(oauth2.auth, qp).submit();
oauth2.callback(oauth2.auth);
} else {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: "Authorization failed: no accessCode came from the server"
message: "Authorization failed: no accessCode received from the server"
});
window.close();
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
window.close();
}
}
function createForm(auth, qp) {
var form = document.createElement("form");
var schema = auth.schema;
var action = schema.get("tokenUrl");
var name, input;
var fields = {
code: qp.code,
"redirect_uri": location.protocol + "//" + location.host + location.pathname,
"grant_type": "authorization_code",
"client_secret": auth.clientSecret,
"client_id": auth.clientId
}
for ( name in fields ) {
input = document.createElement("input");
input.name = name;
input.value = fields[name];
input.type = "hidden";
form.appendChild(input);
}
form.method = "POST";
form.action = action;
document.body.appendChild(form);
return form;
window.close();
}
</script>
+41 -40
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0dA;;;;;;AAoIA;AAk7FA;AAmtCA;;;;;AA0uIA;AA+4IA;AAm9FA;AA2rGA;AA8lFA;AA2nFA;AAu9CA;AAyhDA;AAqrCA;AAy4EA;AA8/GA;;;;;;;;;;;;;;AA+mJA;AA4mIA;AAquJA;AAwsHA;AAinGA;AAmiEA;AAy4DA;AAm2DA;AA0nBA;;;;;;AA4iFA;AAk0FA;;;;;AA23CA;AA2qFA;AAw2CA;AAglCA;AA0/CA;AAykFA;AA+1FA;;;;;;;;;AAk4CA;AA2zIA;AAk4DA;AAolDA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAmTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA2pJA;AA+uFA;AA2rGA;AAgiFA;AA0rFA;AAk9CA;AA2hDA;AA4rCA;AAi6EA;;;;;AA2gCA;AA02JA;;;;;;;;;;;;;;AAuyEA;AA4mIA;AAquJA;AAwsHA;AA2mGA;AAiiEA;AAq4DA;AA+2DA;AAqlBA;;;;;;AAilFA;AAs1FA;;;;;AAy3CA;AA2qFA;AAw2CA;AAwkCA;AAs/CA;AA4kFA;AAy1FA;;;;;;;;;AAm5CA;AA2zIA;AAk4DA;AAolDA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -9
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA4wCA;AAoyHA;AAuxHA;AAy4FA;AA8rCA;AAugCA;AA+hCA;AA24BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAwxCA;AAoyHA;AAuxHA;AAy4FA;AA2sCA;AAmgCA;AA0iCA;AA+3BA","sourceRoot":""}
+11 -1
View File
@@ -4,9 +4,13 @@ var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var deepExtend = require('deep-extend')
var autoprefixer = require('autoprefixer')
const {gitDescribeSync} = require('git-describe');
var loadersByExtension = require('./build-tools/loadersByExtension')
var pkg = require('./package.json')
const gitInfo = gitDescribeSync(__dirname)
module.exports = function(options) {
// Special options, that have logic in this file
@@ -59,8 +63,14 @@ module.exports = function(options) {
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
},
'buildInfo': JSON.stringify({
PACKAGE_VERSION: (pkg.version),
GIT_COMMIT: gitInfo.hash,
GIT_DIRTY: gitInfo.dirty
})
}))
var cssLoader = 'css-loader!postcss-loader'
+5 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.7",
"version": "3.0.8",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -36,10 +36,12 @@
},
"dependencies": {
"babel-polyfill": "^6.23.0",
"base64-js": "^1.2.0",
"brace": "0.7.0",
"deep-extend": "0.4.1",
"expect": "1.20.2",
"getbase": "^2.8.2",
"ieee754": "^1.1.8",
"immutable": "^3.x.x",
"js-yaml": "^3.5.5",
"less": "2.7.1",
@@ -67,7 +69,7 @@
"reselect": "2.5.3",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "^3.0.7",
"swagger-client": "^3.0.8",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
@@ -93,6 +95,7 @@
"eslint-plugin-react": "^6.10.3",
"extract-text-webpack-plugin": "0.8.2",
"file-loader": "0.8.4",
"git-describe": "^4.0.1",
"html-webpack-plugin": "^2.28.0",
"imports-loader": "0.6.5",
"json-loader": "0.5.3",
+28
View File
@@ -0,0 +1,28 @@
name: swagger-ui
version: master
summary: The World's Most Popular API Framework
description: |
Swagger UI is part of the Swagger project. The Swagger project allows you to
produce, visualize and consume your OWN RESTful services. No proxy or 3rd
party services required. Do it your own way.
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS
assets that dynamically generate beautiful documentation and sandbox from a
Swagger-compliant API. Because Swagger UI has no dependencies, you can host
it in any server environment, or on your local machine.
grade: devel
confinement: strict
apps:
swagger-ui:
command: sh -c \"cd $SNAP/lib/node_modules/swagger-ui/dist && http-server -a localhost -p 8080\"
daemon: simple
plugs: [network, network-bind]
parts:
swagger-ui:
source: .
plugin: nodejs
npm-run: [build]
node-packages: [handlebars, http-server]
+38 -36
View File
@@ -26,7 +26,7 @@ export default class Oauth2 extends React.Component {
let username = auth && auth.get("username") || ""
let clientId = auth && auth.get("clientId") || ""
let clientSecret = auth && auth.get("clientSecret") || ""
let passwordType = auth && auth.get("passwordType") || "none"
let passwordType = auth && auth.get("passwordType") || "basic"
this.state = {
name: name,
@@ -108,44 +108,46 @@ export default class Oauth2 extends React.Component {
<p className="flow">Flow: <code>{ schema.get("flow") }</code></p>
{
flow === PASSWORD && ( !isAuthorized || isAuthorized && this.state.username) && <Row>
<Col tablet={2} desktop={2}>username:</Col>
<Col tablet={10} desktop={10}>
flow !== PASSWORD ? null
: <Row>
<Row>
<label htmlFor="oauth_username">username:</label>
{
isAuthorized ? <code> { this.state.username } </code>
: <Col tablet={10} desktop={10}>
<input id="oauth_username" type="text" data-name="username" onChange={ this.onInputChange }/>
</Col>
}
</Row>
{
isAuthorized ? <span>{ this.state.username }</span>
: <input type="text" data-name="username" onChange={ this.onInputChange }/>
}
</Col>
</Row>
<Row>
<label htmlFor="oauth_password">password:</label>
{
isAuthorized ? <code> ****** </code>
: <Col tablet={10} desktop={10}>
<input id="oauth_password" type="password" data-name="password" onChange={ this.onInputChange }/>
</Col>
}
</Row>
<Row>
<label htmlFor="password_type">type:</label>
{
isAuthorized ? <code> { this.state.passwordType } </code>
: <Col tablet={10} desktop={10}>
<select id="password_type" data-name="passwordType" onChange={ this.onInputChange }>
<option value="basic">Basic auth</option>
<option value="request-body">Request body</option>
<option value="query">Query parameters</option>
</select>
</Col>
}
</Row>
</Row>
}
{
flow === PASSWORD && !isAuthorized && <Row>
<Col tablet={2} desktop={2}>password:</Col>
<Col tablet={10} desktop={10}>
<input type="password" data-name="password" onChange={ this.onInputChange }/>
</Col>
</Row>
}
{
flow === PASSWORD && <Row>
<Col tablet={2} desktop={2}>type:</Col>
<Col tablet={10} desktop={10}>
{
isAuthorized ? <span>{ this.state.passwordType }</span>
: <select data-name="passwordType" onChange={ this.onInputChange }>
<option value="none">None or other</option>
<option value="basic">Basic auth</option>
<option value="request">Request body</option>
</select>
}
</Col>
</Row>
}
{
( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) &&
( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "basic") ) &&
( !isAuthorized || isAuthorized && this.state.clientId) && <Row>
<label htmlFor="client_id">client_id:</label>
{
@@ -159,7 +161,7 @@ export default class Oauth2 extends React.Component {
}
{
( flow === APPLICATION || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "none") ) && <Row>
( flow === APPLICATION || flow === ACCESS_CODE || ( flow === PASSWORD && this.state.passwordType!== "basic") ) && <Row>
<label htmlFor="client_secret">client_secret:</label>
{
isAuthorized ? <code> ****** </code>
+1 -1
View File
@@ -16,7 +16,7 @@ export class Container extends React.Component {
if(fullscreen)
return <section {...rest}/>
let containerClass = "container" + (full ? "-full" : "")
let containerClass = "swagger-container" + (full ? "-full" : "")
return (
<section {...rest} className={xclass(rest.className, containerClass)}/>
)
+6
View File
@@ -6,6 +6,12 @@ import * as AllPlugins from "core/plugins/all"
import { filterConfigs } from "plugins/configs"
import { parseSeach } from "core/utils"
// eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
window.versions = window.versions || {}
window.versions.swaggerUi = `${PACKAGE_VERSION}/${GIT_COMMIT || "unknown"}${GIT_DIRTY ? "-dirty" : ""}`
module.exports = function SwaggerUI(opts) {
const defaults = {
+2 -2
View File
@@ -16,7 +16,7 @@ export default function authorize ( auth, authActions, errActions, configs ) {
}
if (flow === "application") {
authActions.authorizeOauth2Application(auth)
authActions.authorizeApplication(auth)
return
}
@@ -45,7 +45,7 @@ export default function authorize ( auth, authActions, errActions, configs ) {
win.swaggerUIRedirectOauth2 = {
auth: auth,
state: state,
callback: authActions.preAuthorizeOauth2,
callback: flow === "implicit" ? authActions.preAuthorizeImplicit : authActions.authorizeAccessCode,
errCb: errActions.newAuthErr
}
+68 -50
View File
@@ -1,5 +1,5 @@
import win from "core/window"
import { btoa } from "core/utils"
import { btoa, buildFormData } from "core/utils"
export const SHOW_AUTH_POPUP = "show_popup"
export const AUTHORIZE = "authorize"
@@ -31,7 +31,7 @@ export function logout(payload) {
}
}
export const preAuthorizeOauth2 = (payload) => ( { authActions, errActions } ) => {
export const preAuthorizeImplicit = (payload) => ( { authActions, errActions } ) => {
let { auth , token, isValid } = payload
let { schema, name } = auth
let flow = schema.get("flow")
@@ -68,29 +68,72 @@ export function authorizeOauth2(payload) {
}
}
export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } ) => {
export const authorizePassword = ( auth ) => ( { authActions } ) => {
let { schema, name, username, password, passwordType, clientId, clientSecret } = auth
let req = {
url: schema.get("tokenUrl"),
method: "post",
headers: {
"content-type": "application/x-www-form-urlencoded"
},
query: {
grant_type: "password",
username,
password,
scopes: encodeURIComponent(auth.scopes.join(scopeSeparator))
let form = {
grant_type: "password",
scopes: encodeURIComponent(auth.scopes.join(scopeSeparator))
}
let query = {}
let headers = {}
if ( passwordType === "basic") {
headers.Authorization = "Basic " + btoa(username + ":" + password)
} else {
Object.assign(form, {username}, {password})
if ( passwordType === "query") {
if ( clientId ) { query.client_id = clientId }
if ( clientSecret ) { query.client_secret = clientSecret }
} else {
Object.assign(form, {client_id: clientId}, {client_secret: clientSecret})
}
}
if ( passwordType === "basic") {
req.headers.authorization = "Basic " + btoa(clientId + ":" + clientSecret)
} else if ( passwordType === "request") {
req.query = Object.assign(req.query, { client_id: clientId, client_secret: clientSecret })
return authActions.authorizeRequest({ body: buildFormData(form), url: schema.get("tokenUrl"), name, headers, query, auth})
}
export const authorizeApplication = ( auth ) => ( { authActions } ) => {
let { schema, scopes, name, clientId, clientSecret } = auth
let form = {
grant_type: "client_credentials",
client_id: clientId,
client_secret: clientSecret,
scope: scopes.join(scopeSeparator)
}
return fn.fetch(req)
.then(( response ) => {
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth })
}
export const authorizeAccessCode = ( auth ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret } = auth
let form = {
grant_type: "authorization_code",
code: auth.code,
client_id: clientId,
client_secret: clientSecret
}
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
}
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions } ) => {
let { body, query={}, headers={}, name, url, auth } = data
let _headers = Object.assign({
"Accept":"application/json, text/plain, */*",
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/x-www-form-urlencoded"
}, headers)
fn.fetch({
url: url,
method: "post",
headers: _headers,
query: query,
body: body
})
.then(function (response) {
let token = JSON.parse(response.data)
let error = token && ( token.error || "" )
let parseError = token && ( token.parseError || "" )
@@ -115,39 +158,14 @@ export const authorizePassword = ( auth ) => ( { fn, authActions, errActions } )
return
}
authActions.authorizeOauth2({ auth, token })
authActions.authorizeOauth2({ auth, token})
})
.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 ) {
.catch(e => {
let err = new Error(e)
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 ) })
message: err.message
} ) })
}
+3 -4
View File
@@ -2,7 +2,6 @@ import { createStore, applyMiddleware, bindActionCreators, compose } from "redux
import Im, { fromJS, Map } from "immutable"
import deepExtend from "deep-extend"
import { combineReducers } from "redux-immutable"
import assign from "object-assign"
import serializeError from "serialize-error"
import { NEW_THROWN_ERR } from "corePlugins/err/actions"
import win from "core/window"
@@ -74,7 +73,7 @@ export default class Store {
let dispatch = this.getStore().dispatch
let getState = this.getStore().getState
this.boundSystem = assign({},
this.boundSystem = Object.assign({},
this.getRootInjects(),
this.getWrappedAndBoundActions(dispatch),
this.getBoundSelectors(getState, this.getSystem),
@@ -92,7 +91,7 @@ export default class Store {
}
getRootInjects() {
return assign({
return Object.assign({
getSystem: this.getSystem,
getStore: this.getStore.bind(this),
getComponents: this.getComponents.bind(this),
@@ -251,7 +250,7 @@ export default class Store {
getMapStateToProps() {
return () => {
let obj = assign({}, this.getSystem())
let obj = Object.assign({}, this.getSystem())
return obj
}
}
+13 -2
View File
@@ -1,5 +1,4 @@
import Im from "immutable"
import assign from "object-assign"
import shallowEqual from "shallowequal"
import camelCase from "lodash/camelCase"
@@ -85,7 +84,7 @@ export function objReduce(obj, fn) {
return Object.keys(obj).reduce((newObj, key) => {
let res = fn(obj[key], key)
if(res && typeof res === "object")
assign(newObj, res)
Object.assign(newObj, res)
return newObj
}, {})
}
@@ -566,3 +565,15 @@ export const sorters = {
method: (a, b) => a.get("method").localeCompare(b.get("method"))
}
}
export const buildFormData = (data) => {
let formArr = []
for (let name in data) {
let val = data[name]
if (val !== undefined && val !== "") {
formArr.push([name, "=", encodeURIComponent(val).replace(/%20/g,"+")].join(""))
}
}
return formArr.join("&")
}
+2 -2
View File
@@ -43,10 +43,10 @@ export default class Topbar extends React.Component {
<img height="30" width="30" src={ Logo } alt="Swagger UX"/>
<span>swagger</span>
</Link>
<div className="download-url-wrapper">
<form className="download-url-wrapper" onSubmit={this.downloadUrl}>
<input className="download-url-input" type="text" onChange={ this.onUrlChange } value={this.state.url} disabled={isLoading} style={inputStyle} />
<Button className="download-url-button" onClick={ this.downloadUrl }>Explore</Button>
</div>
</form>
</div>
</div>
</div>
+5
View File
@@ -502,6 +502,11 @@ body
{
color: #fff !important;
}
.headerline
{
display: block;
}
}
.scheme-container
+5
View File
@@ -16,6 +16,8 @@
display: flex;
max-width: 300px;
text-decoration: none;
flex: 1;
@@ -33,8 +35,11 @@
{
display: flex;
flex: 3;
input[type=text]
{
width: 100%;
min-width: 350px;
margin: 0;
+2 -2
View File
@@ -1,3 +1,3 @@
This directory is used to build the `swagger-ui-dist` npm package.
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
+4 -1
View File
@@ -22,7 +22,10 @@ module.exports = require('./make-webpack-config.js')({
},
externals: function(context, request, cb) {
if(node_modules.indexOf(request) !== -1) {
// webpack injects some stuff into the resulting file,
// these libs need to be pulled in to keep that working.
var exceptionsForWebpack = ["ieee754", "base64-js"]
if(node_modules.indexOf(request) !== -1 || exceptionsForWebpack.indexOf(request) !== -1) {
cb(null, 'commonjs ' + request)
return;
}