Merge branch 'ft/dev-server-watch' into ft/oas3
This commit is contained in:
@@ -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.10 | 2017-03-19 | 2.0 | [tag v3.0.10](https://github.com/swagger-api/swagger-ui/tree/v3.0.10) |
|
3.0.12 | 2017-03-19 | 2.0 | [tag v3.0.12](https://github.com/swagger-api/swagger-ui/tree/v3.0.12) |
|
||||||
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) |
|
||||||
@@ -115,6 +115,8 @@ dom_id | The id of a dom element inside which SwaggerUi will put the user interf
|
|||||||
oauth2RedirectUrl | OAuth redirect URL
|
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.
|
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.
|
||||||
configUrl | Configs URL
|
configUrl | Configs URL
|
||||||
|
parameterMacro | MUST be a function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable
|
||||||
|
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
|
||||||
|
|
||||||
### Plugins
|
### Plugins
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ let preset = [
|
|||||||
#### Configs plugin
|
#### Configs plugin
|
||||||
Configs plugin allows to fetch external configs instead of passing them to `SwaggerUIBundle`. Fetched configs support two formats: JSON or yaml. The plugin is enabled by default.
|
Configs plugin allows to fetch external configs instead of passing them to `SwaggerUIBundle`. Fetched configs support two formats: JSON or yaml. The plugin is enabled by default.
|
||||||
There are three options of passing config:
|
There are three options of passing config:
|
||||||
- add a query parameter `config` with URL to a server where the configs are hosted. For ex. http://petstore.swagger.io/?configs=http://localhost:3001/config.yaml
|
- add a query parameter `config` with URL to a server where the configs are hosted. For ex. http://petstore.swagger.io/?config=http://localhost:3001/config.yaml
|
||||||
- add a config `configUrl` with URL to SwaggerUIBundle
|
- add a config `configUrl` with URL to SwaggerUIBundle
|
||||||
- change default configs in `swagger-config.yaml` *Note: after changing, the project must be re-built*
|
- change default configs in `swagger-config.yaml` *Note: after changing, the project must be re-built*
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ window.onload = function() {
|
|||||||
clientSecret: "your-client-secret-if-required",
|
clientSecret: "your-client-secret-if-required",
|
||||||
realm: "your-realms",
|
realm: "your-realms",
|
||||||
appName: "your-app-name",
|
appName: "your-app-name",
|
||||||
scopeSeparator: "-",
|
scopeSeparator: " ",
|
||||||
additionalQueryStringParams: {test: "hello"}
|
additionalQueryStringParams: {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
function run () {
|
function run () {
|
||||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||||
var sentState = oauth2.state;
|
var sentState = oauth2.state;
|
||||||
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
var isValid, qp, arr;
|
var isValid, qp, arr;
|
||||||
|
|
||||||
qp = (window.location.hash || location.search).substring(1);
|
qp = (window.location.hash || location.search).substring(1);
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
if (qp.code) {
|
if (qp.code) {
|
||||||
delete oauth2.state;
|
delete oauth2.state;
|
||||||
oauth2.auth.code = qp.code;
|
oauth2.auth.code = qp.code;
|
||||||
oauth2.callback(oauth2.auth);
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
} else {
|
} else {
|
||||||
oauth2.errCb({
|
oauth2.errCb({
|
||||||
authId: oauth2.auth.name,
|
authId: oauth2.auth.name,
|
||||||
@@ -45,9 +46,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
|
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||||
}
|
}
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
94
dist/swagger-ui-bundle.js
vendored
94
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;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAmrGA;AA4lFA;AAioFA;AA09CA;AAwhDA;AAkrCA;AAu4EA;;;;;AAykCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAsdA;;;;;;AAgtFA;AA+4FA;;;;;AAw7CA;AA2qFA;AAw2CA;AAqkCA;AAq9CA;AAu/EA;AA83FA;;;;;;;;;AA+mDA;AA2zIA;AAk4DA;AA8mDA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAizFA;AAqjCA;AA0nJA;AA67IA;AA0zGA;AA2xFA;AAujFA;AAysFA;AAu+CA;AAs/CA;AA6rCA;AAu2EA;;;;;AAsqCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAgRA;;;;;;AAs5FA;AA09FA;;;;;AA4jDA;AAgsFA;AAs2CA;AAilCA;AAm5CA;AA2iFA;AA87BA;AA62FA;;;;;;;;;AAymDA;AA2zIA;AAk5EA;AA6uFA;AA6kDA;AA8DA;;;;;;AA4xFA;AAquGA","sourceRoot":""}
|
||||||
20
dist/swagger-ui-standalone-preset.js
vendored
20
dist/swagger-ui-standalone-preset.js
vendored
File diff suppressed because one or more lines are too long
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;;;;;;AAm2CA;AAoyHA;AAmyHA;AAokGA;AA89BA;AAwhCA;AA2kCA;AAu5BA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAm2CA;AAoyHA;AAqyHA;AAykGA;AA+9BA;AA8iCA;AAuiCA;AA66BA","sourceRoot":""}
|
||||||
6912
package-lock.json
generated
Normal file
6912
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui",
|
"name": "swagger-ui",
|
||||||
"version": "3.0.10",
|
"version": "3.0.12",
|
||||||
"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": [
|
||||||
@@ -70,7 +70,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.10",
|
"swagger-client": "~3.0.12",
|
||||||
"url-parse": "^1.1.8",
|
"url-parse": "^1.1.8",
|
||||||
"whatwg-fetch": "0.11.1",
|
"whatwg-fetch": "0.11.1",
|
||||||
"worker-loader": "^0.7.1",
|
"worker-loader": "^0.7.1",
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ export default class Oauth2 extends React.Component {
|
|||||||
isAuthorized ? <code> { this.state.passwordType } </code>
|
isAuthorized ? <code> { this.state.passwordType } </code>
|
||||||
: <Col tablet={10} desktop={10}>
|
: <Col tablet={10} desktop={10}>
|
||||||
<select id="password_type" data-name="passwordType" onChange={ this.onInputChange }>
|
<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="request-body">Request body</option>
|
||||||
|
<option value="basic">Basic auth</option>
|
||||||
<option value="query">Query parameters</option>
|
<option value="query">Query parameters</option>
|
||||||
</select>
|
</select>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -5,14 +5,18 @@ import Collapse from "react-collapse"
|
|||||||
export default class Errors extends React.Component {
|
export default class Errors extends React.Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
jumpToLine: PropTypes.func,
|
editorActions: PropTypes.object,
|
||||||
errSelectors: PropTypes.object.isRequired,
|
errSelectors: PropTypes.object.isRequired,
|
||||||
layoutSelectors: PropTypes.object.isRequired,
|
layoutSelectors: PropTypes.object.isRequired,
|
||||||
layoutActions: PropTypes.object.isRequired
|
layoutActions: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { jumpToLine, errSelectors, layoutSelectors, layoutActions } = this.props
|
let { editorActions, errSelectors, layoutSelectors, layoutActions } = this.props
|
||||||
|
|
||||||
|
if(editorActions && editorActions.jumpToLine) {
|
||||||
|
var jumpToLine = editorActions.jumpToLine
|
||||||
|
}
|
||||||
|
|
||||||
let errors = errSelectors.allErrors()
|
let errors = errSelectors.allErrors()
|
||||||
|
|
||||||
@@ -37,10 +41,11 @@ export default class Errors extends React.Component {
|
|||||||
<Collapse isOpened={ isVisible } animated >
|
<Collapse isOpened={ isVisible } animated >
|
||||||
<div className="errors">
|
<div className="errors">
|
||||||
{ sortedJSErrors.map((err, i) => {
|
{ sortedJSErrors.map((err, i) => {
|
||||||
if(err.get("type") === "thrown") {
|
let type = err.get("type")
|
||||||
|
if(type === "thrown" || type === "auth") {
|
||||||
return <ThrownErrorItem key={ i } error={ err.get("error") || err } jumpToLine={jumpToLine} />
|
return <ThrownErrorItem key={ i } error={ err.get("error") || err } jumpToLine={jumpToLine} />
|
||||||
}
|
}
|
||||||
if(err.get("type") === "spec") {
|
if(type === "spec") {
|
||||||
return <SpecErrorItem key={ i } error={ err } jumpToLine={jumpToLine} />
|
return <SpecErrorItem key={ i } error={ err } jumpToLine={jumpToLine} />
|
||||||
}
|
}
|
||||||
}) }
|
}) }
|
||||||
@@ -95,7 +100,7 @@ const SpecErrorItem = ( { error, jumpToLine } ) => {
|
|||||||
<div>
|
<div>
|
||||||
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") } { locationMessage }</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 style={{ "text-decoration": "underline", "cursor": "pointer" }}>
|
||||||
{ jumpToLine ? (
|
{ jumpToLine ? (
|
||||||
<a onClick={jumpToLine.bind(null, error.get("line"))}>Jump to line { error.get("line") }</a>
|
<a onClick={jumpToLine.bind(null, error.get("line"))}>Jump to line { error.get("line") }</a>
|
||||||
) : null }
|
) : null }
|
||||||
|
|||||||
@@ -48,11 +48,10 @@ export default class Operations extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div className={showTag ? "opblock-tag-section is-open" : "opblock-tag-section"} key={"operation-" + tag}>
|
<div className={showTag ? "opblock-tag-section is-open" : "opblock-tag-section"} key={"operation-" + tag}>
|
||||||
|
|
||||||
<h4 className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
|
<h4 onClick={() => layoutActions.show(isShownKey, !showTag)} className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
|
||||||
<span onClick={() => layoutActions.show(isShownKey, !showTag)}>{tag}</span>
|
<span>{tag}</span>
|
||||||
|
|
||||||
{ !tagDescription ? null :
|
{ !tagDescription ? null :
|
||||||
<small onClick={() => layoutActions.show(isShownKey, !showTag)} >
|
<small>
|
||||||
{ tagDescription }
|
{ tagDescription }
|
||||||
</small>
|
</small>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import * as AllPlugins from "core/plugins/all"
|
|||||||
import { parseSeach, filterConfigs } from "core/utils"
|
import { parseSeach, filterConfigs } from "core/utils"
|
||||||
|
|
||||||
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||||
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id",
|
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
|
||||||
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders" ]
|
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro" ]
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
||||||
@@ -25,8 +25,8 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
url: "",
|
url: "",
|
||||||
layout: "BaseLayout",
|
layout: "BaseLayout",
|
||||||
validatorUrl: "https://online.swagger.io/validator",
|
validatorUrl: "https://online.swagger.io/validator",
|
||||||
configs: {
|
configs: {},
|
||||||
},
|
custom: {},
|
||||||
|
|
||||||
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
||||||
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
||||||
|
|||||||
@@ -3,26 +3,35 @@ import { btoa } from "core/utils"
|
|||||||
|
|
||||||
export default function authorize ( { auth, authActions, errActions, configs, authConfigs={} } ) {
|
export default function authorize ( { auth, authActions, errActions, configs, authConfigs={} } ) {
|
||||||
let { schema, scopes, name, clientId } = auth
|
let { schema, scopes, name, clientId } = auth
|
||||||
|
|
||||||
let { additionalQueryStringParams } = authConfigs
|
|
||||||
let redirectUrl = configs.oauth2RedirectUrl
|
|
||||||
let scopeSeparator = authConfigs.scopeSeparator || " "
|
|
||||||
let state = btoa(new Date())
|
|
||||||
let flow = schema.get("flow")
|
let flow = schema.get("flow")
|
||||||
let url
|
let query = []
|
||||||
|
|
||||||
if (flow === "password") {
|
switch (flow) {
|
||||||
authActions.authorizePassword(auth)
|
case "password":
|
||||||
return
|
authActions.authorizePassword(auth)
|
||||||
|
return
|
||||||
|
|
||||||
|
case "application":
|
||||||
|
authActions.authorizeApplication(auth)
|
||||||
|
return
|
||||||
|
|
||||||
|
case "accessCode":
|
||||||
|
query.push("response_type=code")
|
||||||
|
break
|
||||||
|
|
||||||
|
case "implicit":
|
||||||
|
query.push("response_type=token")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flow === "application") {
|
if (typeof clientId === "string") {
|
||||||
authActions.authorizeApplication(auth)
|
query.push("client_id=" + encodeURIComponent(clientId))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let redirectUrl = configs.oauth2RedirectUrl
|
||||||
|
|
||||||
// todo move to parser
|
// todo move to parser
|
||||||
if ( !redirectUrl ) {
|
if (typeof redirectUrl === "undefined") {
|
||||||
errActions.newAuthErr( {
|
errActions.newAuthErr( {
|
||||||
authId: name,
|
authId: name,
|
||||||
source: "validation",
|
source: "validation",
|
||||||
@@ -31,26 +40,38 @@ export default function authorize ( { auth, authActions, errActions, configs, au
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
query.push("redirect_uri=" + encodeURIComponent(redirectUrl))
|
||||||
|
|
||||||
if (flow === "implicit" || flow === "accessCode") {
|
if (Array.isArray(scopes) && 0 < scopes.length) {
|
||||||
url = schema.get("authorizationUrl") + "?response_type=" + (flow === "implicit" ? "token" : "code")
|
let scopeSeparator = authConfigs.scopeSeparator || " "
|
||||||
|
|
||||||
|
query.push("scope=" + encodeURIComponent(scopes.join(scopeSeparator)))
|
||||||
}
|
}
|
||||||
|
|
||||||
url += "&redirect_uri=" + encodeURIComponent(redirectUrl)
|
let state = btoa(new Date())
|
||||||
+ "&realm=" + encodeURIComponent(authConfigs.realm);
|
|
||||||
+ "&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
|
query.push("state=" + encodeURIComponent(state))
|
||||||
+ "&state=" + encodeURIComponent(state)
|
|
||||||
+ "&client_id=" + encodeURIComponent(clientId)
|
if (typeof authConfigs.realm !== "undefined") {
|
||||||
|
query.push("realm=" + encodeURIComponent(authConfigs.realm))
|
||||||
|
}
|
||||||
|
|
||||||
|
let { additionalQueryStringParams } = authConfigs
|
||||||
|
|
||||||
for (let key in additionalQueryStringParams) {
|
for (let key in additionalQueryStringParams) {
|
||||||
url += "&" + key + "=" + encodeURIComponent(additionalQueryStringParams[key])
|
if (typeof additionalQueryStringParams[key] !== "undefined") {
|
||||||
|
query.push([key, additionalQueryStringParams[key]].map(encodeURIComponent).join("="))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let url = [schema.get("authorizationUrl"), query.join("&")].join("?")
|
||||||
|
|
||||||
// pass action authorizeOauth2 and authentication data through window
|
// pass action authorizeOauth2 and authentication data through window
|
||||||
// to authorize with oauth2
|
// to authorize with oauth2
|
||||||
win.swaggerUIRedirectOauth2 = {
|
win.swaggerUIRedirectOauth2 = {
|
||||||
auth: auth,
|
auth: auth,
|
||||||
state: state,
|
state: state,
|
||||||
|
redirectUrl: redirectUrl,
|
||||||
callback: flow === "implicit" ? authActions.preAuthorizeImplicit : authActions.authorizeAccessCode,
|
callback: flow === "implicit" ? authActions.preAuthorizeImplicit : authActions.authorizeAccessCode,
|
||||||
errCb: errActions.newAuthErr
|
errCb: errActions.newAuthErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,12 +81,17 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
|
|||||||
if ( passwordType === "basic") {
|
if ( passwordType === "basic") {
|
||||||
headers.Authorization = "Basic " + btoa(username + ":" + password)
|
headers.Authorization = "Basic " + btoa(username + ":" + password)
|
||||||
} else {
|
} else {
|
||||||
Object.assign(form, {username}, {password})
|
Object.assign(form, {username}, {password})
|
||||||
|
|
||||||
if ( passwordType === "query") {
|
if ( passwordType === "query") {
|
||||||
if ( clientId ) { query.client_id = clientId }
|
if ( clientId ) {
|
||||||
if ( clientSecret ) { query.client_secret = clientSecret }
|
query.client_id = clientId
|
||||||
|
}
|
||||||
|
if ( clientSecret ) {
|
||||||
|
query.client_secret = clientSecret
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Object.assign(form, {client_id: clientId}, {client_secret: clientSecret})
|
headers.Authorization = "Basic " + btoa(clientId + ":" + clientSecret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,27 +100,28 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
|
|||||||
|
|
||||||
export const authorizeApplication = ( auth ) => ( { authActions } ) => {
|
export const authorizeApplication = ( auth ) => ( { authActions } ) => {
|
||||||
let { schema, scopes, name, clientId, clientSecret } = auth
|
let { schema, scopes, name, clientId, clientSecret } = auth
|
||||||
|
let headers = {
|
||||||
|
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
|
||||||
|
}
|
||||||
let form = {
|
let form = {
|
||||||
grant_type: "client_credentials",
|
grant_type: "client_credentials",
|
||||||
client_id: clientId,
|
|
||||||
client_secret: clientSecret,
|
|
||||||
scope: scopes.join(scopeSeparator)
|
scope: scopes.join(scopeSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth })
|
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authorizeAccessCode = ( auth ) => ( { authActions } ) => {
|
export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions } ) => {
|
||||||
let { schema, name, clientId, clientSecret } = auth
|
let { schema, name, clientId, clientSecret } = auth
|
||||||
let form = {
|
let form = {
|
||||||
grant_type: "authorization_code",
|
grant_type: "authorization_code",
|
||||||
code: auth.code,
|
code: auth.code,
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
client_secret: clientSecret
|
client_secret: clientSecret,
|
||||||
}
|
redirect_uri: redirectUrl
|
||||||
|
}
|
||||||
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
|
|
||||||
|
|
||||||
|
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
|
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
|
||||||
@@ -140,41 +146,42 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut
|
|||||||
query: query,
|
query: query,
|
||||||
body: body
|
body: body
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
let token = JSON.parse(response.data)
|
let token = JSON.parse(response.data)
|
||||||
let error = token && ( token.error || "" )
|
let error = token && ( token.error || "" )
|
||||||
let parseError = token && ( token.parseError || "" )
|
let parseError = token && ( token.parseError || "" )
|
||||||
|
|
||||||
if ( !response.ok ) {
|
if ( !response.ok ) {
|
||||||
errActions.newAuthErr( {
|
|
||||||
authId: name,
|
|
||||||
level: "error",
|
|
||||||
source: "auth",
|
|
||||||
message: response.statusText
|
|
||||||
} )
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( error || parseError ) {
|
|
||||||
errActions.newAuthErr({
|
|
||||||
authId: name,
|
|
||||||
level: "error",
|
|
||||||
source: "auth",
|
|
||||||
message: JSON.stringify(token)
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
authActions.authorizeOauth2({ auth, token})
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
let err = new Error(e)
|
|
||||||
errActions.newAuthErr( {
|
errActions.newAuthErr( {
|
||||||
authId: name,
|
authId: name,
|
||||||
level: "error",
|
level: "error",
|
||||||
source: "auth",
|
source: "auth",
|
||||||
message: err.message
|
message: response.statusText
|
||||||
} ) })
|
} )
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( error || parseError ) {
|
||||||
|
errActions.newAuthErr({
|
||||||
|
authId: name,
|
||||||
|
level: "error",
|
||||||
|
source: "auth",
|
||||||
|
message: JSON.stringify(token)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
authActions.authorizeOauth2({ auth, token})
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
let err = new Error(e)
|
||||||
|
errActions.newAuthErr( {
|
||||||
|
authId: name,
|
||||||
|
level: "error",
|
||||||
|
source: "auth",
|
||||||
|
message: err.message
|
||||||
|
} )
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function configureAuth(payload) {
|
export function configureAuth(payload) {
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ export const parseToJson = (str) => ({specActions, specSelectors, errActions}) =
|
|||||||
return specActions.updateJsonSpec(json)
|
return specActions.updateJsonSpec(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }}) => {
|
export const resolveSpec = (json, url) => ({specActions, specSelectors, errActions, fn: { fetch, resolve, AST }, getConfigs}) => {
|
||||||
|
const { modelPropertyMacro, parameterMacro } = getConfigs()
|
||||||
|
|
||||||
if(typeof(json) === "undefined") {
|
if(typeof(json) === "undefined") {
|
||||||
json = specSelectors.specJson()
|
json = specSelectors.specJson()
|
||||||
}
|
}
|
||||||
@@ -89,7 +91,7 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
|
|||||||
|
|
||||||
let specStr = specSelectors.specStr()
|
let specStr = specSelectors.specStr()
|
||||||
|
|
||||||
return resolve({fetch, spec: json, baseDoc: url})
|
return resolve({fetch, spec: json, baseDoc: url, modelPropertyMacro, parameterMacro })
|
||||||
.then( ({spec, errors}) => {
|
.then( ({spec, errors}) => {
|
||||||
errActions.clear({
|
errActions.clear({
|
||||||
type: "thrown"
|
type: "thrown"
|
||||||
|
|||||||
@@ -13,13 +13,18 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p
|
p, li, table
|
||||||
{
|
{
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
@include text_body();
|
@include text_body();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5
|
||||||
|
{
|
||||||
|
@include text_body();
|
||||||
|
}
|
||||||
|
|
||||||
code
|
code
|
||||||
{
|
{
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
|
|||||||
@@ -541,11 +541,18 @@ body
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
|
|
||||||
|
word-wrap: break-word;
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
hyphens: auto;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
|
||||||
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: #41444e;
|
background: #41444e;
|
||||||
|
|
||||||
|
overflow-wrap: break-word;
|
||||||
@include text_code(#fff);
|
@include text_code(#fff);
|
||||||
span
|
span
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
|
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module. Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
||||||
|
|
||||||
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
|
||||||
|
```javascript
|
||||||
|
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from 'swagger-ui-dist'
|
||||||
|
```
|
||||||
|
|
||||||
|
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ else
|
|||||||
npm pack .
|
npm pack .
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find . -not -name .npmignore -not -name .npmrc -not -name deploy.sh -not -name package.json -not -name README.md -not -name *.tgz -delete
|
find . -not -name .npmignore -not -name .npmrc -not -name deploy.sh -not -name index.js -not -name package.json -not -name README.md -not -name *.tgz -delete
|
||||||
|
|||||||
2
swagger-ui-dist-package/index.js
Normal file
2
swagger-ui-dist-package/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module.exports.SwaggerUIBundle = require('./swagger-ui-bundle.js')
|
||||||
|
module.exports.SwaggerUIStandalonePreset = require('./swagger-ui-standalone-preset.js')
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui-dist",
|
"name": "swagger-ui-dist",
|
||||||
"version": "$$VERSION",
|
"version": "$$VERSION",
|
||||||
"main": "dist/swagger-ui.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"(in alphabetical order)",
|
"(in alphabetical order)",
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ module.exports = require("./make-webpack-config")({
|
|||||||
devtool: "eval",
|
devtool: "eval",
|
||||||
entry: {
|
entry: {
|
||||||
'swagger-ui-bundle': [
|
'swagger-ui-bundle': [
|
||||||
|
'webpack/hot/dev-server',
|
||||||
'babel-polyfill',
|
'babel-polyfill',
|
||||||
'./src/core/index.js'
|
'./src/core/index.js',
|
||||||
],
|
],
|
||||||
'swagger-ui-standalone-preset': [
|
'swagger-ui-standalone-preset': [
|
||||||
'./src/standalone/index.js'
|
'webpack/hot/dev-server',
|
||||||
|
'./src/standalone/index.js',
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
Reference in New Issue
Block a user