Compare commits

...
71 Commits
Author SHA1 Message Date
shockey eec04f4ce2 Merge pull request #3180 from shockey/v/3.0.13
v/3.0.13
2017-06-03 00:41:15 -07:00
Kyle Shockey 58422825c9 Rebuild dist 2017-06-03 00:18:15 -07:00
Kyle Shockey 5952bb6cbf Bump fast-json-patch in lockfile 2017-06-03 00:16:44 -07:00
Kyle Shockey b4cb0ce247 Rebuild dist 2017-06-03 00:11:32 -07:00
Kyle Shockey 19f7668b48 Bump declared version and upstream minimum versions 2017-06-02 22:42:18 -07:00
shockey f862caa599 Merge pull request #3178 from shockey/build
Rebuild dist
2017-06-02 15:55:09 -07:00
Kyle Shockey c471f59c53 Rebuild dist 2017-06-02 15:49:04 -07:00
shockey 9a08904574 Merge pull request #3165 from shockey/bug/3163-markdown-xss
Sanitize Markdown inputs
2017-06-01 23:47:18 -07:00
Kyle Shockey bec97cfaf5 Fix style error 2017-06-01 22:24:31 -07:00
Kyle Shockey 6ccd037197 Merge branch 'bug/3163-markdown-xss' of github.com:shockey/swagger-ui into bug/3163-markdown-xss 2017-06-01 22:18:37 -07:00
Kyle Shockey af2b1e20f1 Sanitize Markdown inputs 2017-06-01 22:14:44 -07:00
Kyle Shockey 23b1a8aabd Finish rewiring Markdown provider 2017-06-01 21:41:28 -07:00
Kyle Shockey a2eed69ee7 Create providers directory; Markdown provider 2017-06-01 21:37:00 -07:00
shockey 6ae7eb4591 Merge branch 'master' into bug/3163-markdown-xss 2017-06-01 09:47:12 -07:00
Kyle Shockey df47e0e956 Disable HTML rendering in React-Markdown 2017-06-01 09:43:13 -07:00
shockey 5752ffcdab Merge pull request #3161 from shockey/ft/dev-server-watch
Dev server: remove 'watch' call, fix HMR
2017-05-31 23:53:38 -07:00
shockey 2bc6c45f83 Merge branch 'master' into ft/dev-server-watch 2017-05-31 18:54:38 -07:00
shockey 01124b07ad Merge pull request #3162 from swagger-api/readme-updates-0531
Update README.md
2017-05-31 18:15:33 -07:00
Kyle Shockey 1280abe737 Merge branch 'ft/dev-server-watch' of github.com:shockey/swagger-ui into ft/dev-server-watch 2017-05-31 18:14:30 -07:00
Kyle Shockey f4d1d28dd8 HMR for dev server 2017-05-31 18:13:43 -07:00
shockey 4dc966870d Update README.md 2017-05-31 17:25:51 -07:00
shockey 1d07a4b764 Merge branch 'master' into ft/dev-server-watch 2017-05-31 17:21:27 -07:00
shockey 65a4f9aaf2 Merge pull request #3160 from shockey/ft/package-lock
Add package-lock.json
2017-05-31 17:19:49 -07:00
shockey fa01f2b45d Merge branch 'master' into ft/package-lock 2017-05-31 17:16:55 -07:00
Kyle Shockey 1b7d94a54b Dev server: remove 'watch' call 2017-05-31 17:11:04 -07:00
Kyle Shockey f583469876 Add package-lock.json 2017-05-31 17:10:37 -07:00
Ron b242917e3e Merge pull request #2886 from gierschv/fix.info-font
fix(info): font for title, li and table
2017-05-31 12:35:02 -07:00
Ron d1c1b000bf Merge branch 'master' into fix.info-font 2017-05-31 12:31:00 -07:00
Anna 8eb5461664 Merge pull request #3156 from bodnia/fix-3128-password
#3128 make request-body type default for aouth2 password flow
2017-05-31 18:58:09 +03:00
Anna Bodnia 676fd99960 #3128 make request-body type default for aouth2 password flow 2017-05-31 18:53:45 +03:00
Anna 49705f3441 Merge pull request #3155 from bodnia/fix-3128
fix #3128
2017-05-31 18:18:21 +03:00
Anna Bodnia 5f2eaffbc3 fix #3128 2017-05-31 17:31:29 +03:00
Vincent Giersch 0ea14189c0 fix(info): font for title, li and table 2017-05-31 10:46:07 +02:00
Anna 88df65533c Merge pull request #3148 from bodnia/master
typo in README
2017-05-30 14:49:07 +03:00
Anna Bodnia 8340f5d06c typo in README 2017-05-30 14:45:04 +03:00
shockey 39501c8d82 Merge pull request #3140 from shockey/v/3.0.12
v3.0.12
2017-05-26 19:43:55 -07:00
Kyle Shockey d68dd5f7d6 Rebuild dist 2017-05-26 19:38:03 -07:00
Kyle Shockey 2567e5168d v3.0.12 2017-05-26 19:36:30 -07:00
shockey bf6681c914 Merge pull request #3133 from shockey/ft/dist-npm-packaging
packaging: fix swagger-ui-dist entry point
2017-05-26 00:59:16 -07:00
Roman Bolshakov b23c999d01 packaging: fix swagger-ui-dist entry point
Entry point was missing. This change allows importing SwaggerUIBundle
and SwaggerUIStandalonePreset directly from package. Correct entry point
is also needed for module bundlers like webpack to perform tree-shaking.
2017-05-25 17:45:01 -07:00
Anna 41d8089d0e Merge pull request #3130 from bodnia/fix-3067
Fix 3067
2017-05-25 18:30:12 +03:00
Anna Bodnia c5d2faa3a2 build 2017-05-25 18:10:40 +03:00
Anna Bodnia df4ea9b3d6 Merge remote-tracking branch 'upstream/master' into fix-3067 2017-05-25 18:06:07 +03:00
Anna Bodnia 62cb9ec581 Read me for modelPropertyMacro, changed for parameterMacro 2017-05-25 18:04:21 +03:00
shockey 1db8e498b7 Merge pull request #3116 from Minasokoni/clickfix
Updated click area
2017-05-24 09:01:34 -07:00
Anna Bodnia 918e0e46c0 read me for parameterMacro 2017-05-23 15:36:42 +03:00
Robert Barnwell 760d1eba80 Merge branch 'master' into clickfix 2017-05-22 09:57:19 -07:00
Minasokoni a2a2f76199 updated click area 2017-05-22 09:12:13 -07:00
Anna Bodnia d5b9552a5a removed debugger 2017-05-22 17:13:31 +03:00
shockey 753134ec49 Merge pull request #3114 from shockey/v/3.0.11
v3.0.11
2017-05-19 20:25:59 -07:00
Kyle Shockey 612078ac8c Rebuild dist 2017-05-19 20:17:37 -07:00
Kyle Shockey e45570b6c8 v3.0.11 2017-05-19 20:09:34 -07:00
shockey daef38d2e3 Merge pull request #3092 from Minasokoni/wordwrapfix
Long single line responses wrapped with css
2017-05-19 18:46:28 -07:00
shockey eb8a64a66f Merge branch 'master' into wordwrapfix 2017-05-19 18:43:27 -07:00
Anna Bodnia edfe88d299 modelPropertyMacro, parameterMacro 2017-05-19 18:50:51 +03:00
shockey c66436e7d5 Merge pull request #3108 from swagger-api/shockey-patch-3
Add custom namespace to config whitelist
2017-05-18 23:41:34 -07:00
shockey b530ac8593 Default value for custom key 2017-05-18 23:35:02 -07:00
shockey d30b3a9ba1 Add custom namespace to config whitelist 2017-05-18 23:33:12 -07:00
shockey e326a99001 Merge pull request #3106 from shockey/ft/error-jump-to-line
Jump to Line
2017-05-18 15:32:44 -07:00
Kyle Shockey a28dc13191 Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/error-jump-to-line 2017-05-18 15:21:09 -07:00
Kyle Shockey c942f382fb Rebuild dist 2017-05-18 15:15:01 -07:00
Kyle Shockey b6bb1deab8 Rewire jump to line for Errors component 2017-05-18 15:13:04 -07:00
Anna 6224617984 Merge pull request #3099 from bodnia/fix-3089
fixes #3089
2017-05-17 18:16:31 +03:00
Anna Bodnia b85d9a8c24 fixes #3089 2017-05-17 18:13:04 +03:00
Robert Barnwell b28a649457 Merge branch 'master' into wordwrapfix 2017-05-16 11:38:48 -07:00
Minasokoni bb6bc00012 Long single line responses wrapped 2017-05-16 11:33:59 -07:00
Anna f235430f30 Merge pull request #3049 from furkanayhan/send_redirect_url_for_oauth2
Send redirect url for oauth2
2017-05-16 17:01:28 +03:00
Furkan Ayhan 0c7119e855 Send redirect url when authenticating with oauth2-authorization_code
also fix indentations of files
2017-05-16 16:50:13 +03:00
Anna d64e920665 Merge pull request #3084 from tcaesvk/feature/oauth2-authorize-query
fix OAuth2 authorize issue + remove redundant parameters
2017-05-16 15:18:20 +03:00
김 재석 c81fdaec57 fix lint errors 2017-05-16 15:31:02 +09:00
김 재석 960a99a5ea remove undefined parameters for OAuth2 authorize request 2017-05-16 15:20:58 +09:00
35 changed files with 7288 additions and 173 deletions
+8 -3
View File
@@ -15,7 +15,8 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
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.13 | 2017-06-02 | 2.0 | [tag
v3.0.13](https://github.com/swagger-api/swagger-ui/tree/v3.0.13) |
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) |
@@ -41,7 +42,9 @@ Will start nginx with swagger-ui on port 80.
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`. A development server will open on `3200`.
If you'd like to rebuild the `/dist` folder with your codebase changes, run `npm run build`.
##### Browser support
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.
@@ -115,6 +118,8 @@ dom_id | The id of a dom element inside which SwaggerUi will put the user interf
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.
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
@@ -136,7 +141,7 @@ let preset = [
#### 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.
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
- change default configs in `swagger-config.yaml` *Note: after changing, the project must be re-built*
+2 -2
View File
@@ -94,8 +94,8 @@ window.onload = function() {
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: "-",
additionalQueryStringParams: {test: "hello"}
scopeSeparator: " ",
additionalQueryStringParams: {}
})
}
</script>
+3 -3
View File
@@ -8,6 +8,7 @@
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
@@ -35,7 +36,7 @@
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
oauth2.errCb({
authId: oauth2.auth.name,
@@ -45,9 +46,8 @@
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
</script>
+43 -41
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;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAyrGA;AA0lFA;AA4nFA;AA+9CA;AA+gDA;AAwrCA;AA60EA;;;;;AA6oCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAu9CA;AAy8EA;AAsiCA;AA+yFA;;;;;;;;;AAgkDA;AA2zIA;AAu7FA;AAmrFA;AAu0EA","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
+8 -8
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;;;;;;AA0yCA;AAoyHA;AA8xHA;AAokGA;AA+9BA;AA0hCA;AAmjCA;AA65BA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AAmyHA;AAykGA;AA+9BA;AA6iCA;AAojCA;AAu5BA","sourceRoot":""}
+7033
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.10",
"version": "3.0.13",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -19,7 +19,7 @@
"build-core": "webpack --config webpack-dist.config.js --colors",
"build-standalone": "webpack --config webpack-dist-standalone.config.js --colors",
"predev": "npm install",
"dev": "npm-run-all --parallel hot-server watch open-localhost",
"dev": "npm-run-all --parallel hot-server open-localhost",
"watch": "webpack --config webpack-watch.config.js --watch --progress",
"open-localhost": "node -e 'require(\"open\")(\"http://localhost:3200\")'",
"hot-server": "webpack-dev-server --host 0.0.0.0 --config webpack-hot-dev-server.config.js --inline --hot --progress --content-base dev-helpers/",
@@ -67,9 +67,10 @@
"redux-immutable": "3.0.8",
"redux-logger": "*",
"reselect": "2.5.3",
"sanitize-html": "^1.14.1",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "~3.0.10",
"swagger-client": "~3.0.13",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
+1 -2
View File
@@ -53,8 +53,7 @@ export default class ApiKeyAuth extends React.Component {
<h4>Api key authorization<JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ value && <h6>Authorized</h6>}
<Row>
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
<Markdown source={ schema.get("description") } />
</Row>
<Row>
<p>Name: <code>{ schema.get("name") }</code></p>
+1 -2
View File
@@ -59,8 +59,7 @@ export default class BasicAuth extends React.Component {
<h4>Basic authorization<JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ username && <h6>Authorized</h6> }
<Row>
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
<Markdown source={ schema.get("description") } />
</Row>
<Row>
<label>Username:</label>
+2 -3
View File
@@ -102,8 +102,7 @@ export default class Oauth2 extends React.Component {
<div>
<h4>OAuth2.0 <JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ !this.state.appName ? null : <h5>Application: { this.state.appName } </h5> }
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ schema.get("description") } />
<Markdown source={ schema.get("description") } />
{ isAuthorized && <h6>Authorized</h6> }
@@ -141,8 +140,8 @@ export default class Oauth2 extends React.Component {
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="basic">Basic auth</option>
<option value="query">Query parameters</option>
</select>
</Col>
+10 -5
View File
@@ -5,14 +5,18 @@ import Collapse from "react-collapse"
export default class Errors extends React.Component {
static propTypes = {
jumpToLine: PropTypes.func,
editorActions: PropTypes.object,
errSelectors: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired
}
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()
@@ -37,10 +41,11 @@ export default class Errors extends React.Component {
<Collapse isOpened={ isVisible } animated >
<div className="errors">
{ 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} />
}
if(err.get("type") === "spec") {
if(type === "spec") {
return <SpecErrorItem key={ i } error={ err } jumpToLine={jumpToLine} />
}
}) }
@@ -95,7 +100,7 @@ const SpecErrorItem = ( { error, jumpToLine } ) => {
<div>
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }&nbsp;{ locationMessage }</h4>
<span style={{ whiteSpace: "pre-line"}}>{ error.get("message") }</span>
<div>
<div style={{ "text-decoration": "underline", "cursor": "pointer" }}>
{ jumpToLine ? (
<a onClick={jumpToLine.bind(null, error.get("line"))}>Jump to line { error.get("line") }</a>
) : null }
+1 -1
View File
@@ -99,7 +99,7 @@ export default class Info extends React.Component {
</hgroup>
<div className="description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ description } />
<Markdown source={ description } />
</div>
{
-3
View File
@@ -1,13 +1,10 @@
import React, { PropTypes } from "react"
import OriCollapse from "react-collapse"
import _Markdown from "react-remarkable"
function xclass(...args) {
return args.filter(a => !!a).join(" ").trim()
}
export const Markdown = _Markdown
export class Container extends React.Component {
render() {
let { fullscreen, full, ...rest } = this.props
+1 -1
View File
@@ -173,7 +173,7 @@ export default class Operation extends React.Component {
{ description &&
<div className="opblock-description-wrapper">
<div className="opblock-description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ description } />
<Markdown source={ description } />
</div>
</div>
}
+3 -4
View File
@@ -48,11 +48,10 @@ export default class Operations extends React.Component {
return (
<div className={showTag ? "opblock-tag-section is-open" : "opblock-tag-section"} key={"operation-" + tag}>
<h4 className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
<span onClick={() => layoutActions.show(isShownKey, !showTag)}>{tag}</span>
<h4 onClick={() => layoutActions.show(isShownKey, !showTag)} className={!tagDescription ? "opblock-tag no-desc" : "opblock-tag" }>
<span>{tag}</span>
{ !tagDescription ? null :
<small onClick={() => layoutActions.show(isShownKey, !showTag)} >
<small>
{ tagDescription }
</small>
}
+1 -2
View File
@@ -99,8 +99,7 @@ export default class ParameterRow extends Component {
</td>
<td className="col parameters-col_description">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={ param.get("description") }/>
<Markdown source={ param.get("description") }/>
{(isFormData && !isFormDataSupported) && <div>Error: your browser does not support FormData</div>}
{ bodyParam || !isExecute ? null
+6
View File
@@ -0,0 +1,6 @@
# Providers
Providers are generic bridges to third-party components. They provide two benefits:
1. ability for plugins to override third-party components, because providers are loaded through `getComponent`
2. allows us to avoid painting ourselves into a corner with a third-party component
@@ -0,0 +1,17 @@
import React, { PropTypes } from "react"
import Remarkable from "react-remarkable"
import sanitize from "sanitize-html"
function Markdown({ source }) {
const sanitized = sanitize(source)
return <Remarkable
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={sanitized}
></Remarkable>
}
Markdown.propTypes = {
source: PropTypes.string.isRequired
}
export default Markdown
+1 -1
View File
@@ -76,7 +76,7 @@ export default class Response extends React.Component {
<td className="col response-col_description">
<div className="response-col_description__inner">
<Markdown options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} source={ response.get( "description" ) } />
<Markdown source={ response.get( "description" ) } />
</div>
{ example ? (
+4 -4
View File
@@ -7,8 +7,8 @@ import * as AllPlugins from "core/plugins/all"
import { parseSeach, filterConfigs } from "core/utils"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id",
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders" ]
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro" ]
// eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
@@ -25,8 +25,8 @@ module.exports = function SwaggerUI(opts) {
url: "",
layout: "BaseLayout",
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.
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
+42 -21
View File
@@ -3,26 +3,35 @@ import { btoa } from "core/utils"
export default function authorize ( { auth, authActions, errActions, configs, authConfigs={} } ) {
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 url
let query = []
if (flow === "password") {
authActions.authorizePassword(auth)
return
switch (flow) {
case "password":
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") {
authActions.authorizeApplication(auth)
return
if (typeof clientId === "string") {
query.push("client_id=" + encodeURIComponent(clientId))
}
let redirectUrl = configs.oauth2RedirectUrl
// todo move to parser
if ( !redirectUrl ) {
if (typeof redirectUrl === "undefined") {
errActions.newAuthErr( {
authId: name,
source: "validation",
@@ -31,26 +40,38 @@ export default function authorize ( { auth, authActions, errActions, configs, au
})
return
}
query.push("redirect_uri=" + encodeURIComponent(redirectUrl))
if (flow === "implicit" || flow === "accessCode") {
url = schema.get("authorizationUrl") + "?response_type=" + (flow === "implicit" ? "token" : "code")
if (Array.isArray(scopes) && 0 < scopes.length) {
let scopeSeparator = authConfigs.scopeSeparator || " "
query.push("scope=" + encodeURIComponent(scopes.join(scopeSeparator)))
}
url += "&redirect_uri=" + encodeURIComponent(redirectUrl)
+ "&realm=" + encodeURIComponent(authConfigs.realm);
+ "&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
+ "&state=" + encodeURIComponent(state)
+ "&client_id=" + encodeURIComponent(clientId)
let state = btoa(new Date())
query.push("state=" + encodeURIComponent(state))
if (typeof authConfigs.realm !== "undefined") {
query.push("realm=" + encodeURIComponent(authConfigs.realm))
}
let { additionalQueryStringParams } = authConfigs
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
// to authorize with oauth2
win.swaggerUIRedirectOauth2 = {
auth: auth,
state: state,
redirectUrl: redirectUrl,
callback: flow === "implicit" ? authActions.preAuthorizeImplicit : authActions.authorizeAccessCode,
errCb: errActions.newAuthErr
}
+54 -47
View File
@@ -81,12 +81,17 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
if ( passwordType === "basic") {
headers.Authorization = "Basic " + btoa(username + ":" + password)
} else {
Object.assign(form, {username}, {password})
Object.assign(form, {username}, {password})
if ( passwordType === "query") {
if ( clientId ) { query.client_id = clientId }
if ( clientSecret ) { query.client_secret = clientSecret }
if ( clientId ) {
query.client_id = clientId
}
if ( clientSecret ) {
query.client_secret = clientSecret
}
} 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 } ) => {
let { schema, scopes, name, clientId, clientSecret } = auth
let headers = {
Authorization: "Basic " + btoa(clientId + ":" + clientSecret)
}
let form = {
grant_type: "client_credentials",
client_id: clientId,
client_secret: clientSecret,
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 } ) => {
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 authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions } ) => {
let { schema, name, clientId, clientSecret } = auth
let form = {
grant_type: "authorization_code",
code: auth.code,
client_id: clientId,
client_secret: clientSecret,
redirect_uri: redirectUrl
}
return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth})
}
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
@@ -140,41 +146,42 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, aut
query: query,
body: body
})
.then(function (response) {
let token = JSON.parse(response.data)
let error = token && ( token.error || "" )
let parseError = token && ( token.parseError || "" )
.then(function (response) {
let token = JSON.parse(response.data)
let error = token && ( token.error || "" )
let parseError = token && ( token.parseError || "" )
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)
if ( !response.ok ) {
errActions.newAuthErr( {
authId: name,
level: "error",
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) {
+4 -2
View File
@@ -77,7 +77,9 @@ export const parseToJson = (str) => ({specActions, specSelectors, errActions}) =
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") {
json = specSelectors.specJson()
}
@@ -89,7 +91,7 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
let specStr = specSelectors.specStr()
return resolve({fetch, spec: json, baseDoc: url})
return resolve({fetch, spec: json, baseDoc: url, modelPropertyMacro, parameterMacro })
.then( ({spec, errors}) => {
errActions.clear({
type: "thrown"
+3
View File
@@ -46,6 +46,8 @@ import Model from "core/components/model"
import Models from "core/components/models"
import TryItOutButton from "core/components/try-it-out-button"
import Markdown from "core/components/providers/markdown"
import BaseLayout from "core/components/layouts/base"
import * as LayoutUtils from "core/components/layout-utils"
@@ -89,6 +91,7 @@ export default function() {
model: Model,
models: Models,
TryItOutButton,
Markdown,
BaseLayout
}
}
+6 -1
View File
@@ -13,13 +13,18 @@
font-size: 12px;
}
}
p
p, li, table
{
font-size: 14px;
@include text_body();
}
h1, h2, h3, h4, h5
{
@include text_body();
}
code
{
padding: 3px 5px;
+7
View File
@@ -492,11 +492,18 @@ body
margin: 0;
padding: 10px;
word-wrap: break-word;
word-break: break-all;
word-break: break-word;
hyphens: auto;
white-space: pre-wrap;
border-radius: 4px;
background: #41444e;
overflow-wrap: break-word;
@include text_code(#fff);
span
{
+7 -2
View File
@@ -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.
+1 -1
View File
@@ -18,4 +18,4 @@ else
npm pack .
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
View File
@@ -0,0 +1,2 @@
module.exports.SwaggerUIBundle = require('./swagger-ui-bundle.js')
module.exports.SwaggerUIStandalonePreset = require('./swagger-ui-standalone-preset.js')
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "swagger-ui-dist",
"version": "$$VERSION",
"main": "dist/swagger-ui.js",
"main": "index.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
"(in alphabetical order)",
+4 -2
View File
@@ -10,11 +10,13 @@ module.exports = require("./make-webpack-config")({
devtool: "eval",
entry: {
'swagger-ui-bundle': [
'webpack/hot/dev-server',
'babel-polyfill',
'./src/core/index.js'
'./src/core/index.js',
],
'swagger-ui-standalone-preset': [
'./src/standalone/index.js'
'webpack/hot/dev-server',
'./src/standalone/index.js',
]
},
output: {