Skip to content

master into ft/performance #3672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Sep 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
54b383a
Updated docs for correct usage of SWAGGER_JSON
MSeal Aug 16, 2017
f7efd58
Removed href attribute from anchor tag if deeplinking is disabled
Aug 25, 2017
f63d2b1
If deeplinking is disabled the anchor tag has no href attribute as a …
Aug 25, 2017
5da3843
Refactor: use ternary operators at attribute level instead of element…
shockey Aug 25, 2017
f5df9ff
Merge pull request #3612 from invictusmaneo/bug/3610
shockey Aug 25, 2017
db4aa95
Only polyfill Promise if it doesn't exist at all
shockey Aug 25, 2017
e37d4a5
Merge pull request #3613 from swagger-api/bug/3586-promise-polyfill-s…
shockey Aug 25, 2017
2b644af
v3.1.7
shockey Aug 26, 2017
f0fdc66
Merge pull request #3614 from shockey/v/3.1.7
shockey Aug 26, 2017
6c03655
Typo fix
vanta Aug 28, 2017
de64123
Merge pull request #3619 from vanta/patch-1
shockey Aug 29, 2017
947953d
fix #3624
heldersepu Sep 2, 2017
7a2c7d2
Squash commit: OAS3 Try-It-Out changes
shockey Sep 5, 2017
f618ed6
Merge pull request #3632 from heldersepu/master
shockey Sep 5, 2017
d14ae62
Parse JSON requestBodies so Client can consume them correctly
shockey Sep 5, 2017
e2fcadf
Use Client branch
shockey Sep 6, 2017
a58e6eb
Fix typo in swagger-client dependency
shockey Sep 6, 2017
3b99405
Fix property names being displayed in array models
owenconti Sep 8, 2017
e9f46e6
Working on refactoring of model.jsx
owenconti Sep 8, 2017
5bc096d
Fit linter and tests
shockey Sep 9, 2017
a2b5728
Merge branch 'master' into ft/oas3-tio
shockey Sep 9, 2017
3f9b999
Merge pull request #3648 from swagger-api/ft/oas3-tio
shockey Sep 9, 2017
12c96e3
Add comment to array-model for to clarify change. Rework logic in `Mo…
owenconti Sep 9, 2017
3f04d2d
Merge branch 'master' into bug/3490-anyOf-oneOf-not
owenconti Sep 9, 2017
560d566
v3.2.0
shockey Sep 9, 2017
23cb5c9
Merge pull request #3651 from shockey/v/3.2.0
shockey Sep 9, 2017
93fcf06
Merge branch 'master' into bug/SWAGGER_JSON-doc-fix
webron Sep 11, 2017
65ff161
Merge pull request #3579 from OpenGov/bug/SWAGGER_JSON-doc-fix
webron Sep 11, 2017
408e038
fromJS does not maintain order of object properties. Use a reviver fu…
owenconti Sep 12, 2017
72f01b6
Merge branch 'master' into bug/3032-wrong-properties-order
shockey Sep 12, 2017
8a4d246
Merge branch 'master' into bug/3490-anyOf-oneOf-not
shockey Sep 12, 2017
746e247
Merge pull request #3650 from owenconti/bug/3490-anyOf-oneOf-not
shockey Sep 12, 2017
7cd4299
Merge branch 'master' of github.com:swagger-api/swagger-ui
owenconti Sep 12, 2017
26edaa5
OAS3 Accept header control: Component-side
shockey Sep 13, 2017
277cc81
OAS3 Accept header control: State-side
shockey Sep 13, 2017
a47cc28
Update response.jsx to use already existing, fromJSOrdered function
owenconti Sep 13, 2017
cb88cd5
Added test for response.jsx to make sure properties are passed to `Mo…
owenconti Sep 13, 2017
cade510
Merge branch 'master' of github.com:swagger-api/swagger-ui into bug/3…
owenconti Sep 13, 2017
ef99b7e
Remove `it.only` from new test
owenconti Sep 13, 2017
c7cb902
Merge pull request #3655 from owenconti/bug/3032-wrong-properties-order
shockey Sep 13, 2017
430e2a9
Fixes #3596
owenconti Sep 13, 2017
16364fb
Merge branch 'master' of github.com:swagger-api/swagger-ui into bug/3…
owenconti Sep 13, 2017
a6e070a
Replace spaces with underscores when setting the hash value and inser…
owenconti Sep 14, 2017
840912c
Handle null value in createDeepLinkPath
owenconti Sep 14, 2017
78ed1e6
Merge branch 'master' of github.com:swagger-api/swagger-ui
owenconti Sep 14, 2017
11d8a34
Merge pull request #3661 from owenconti/bug/3596-permalink-encoding
shockey Sep 15, 2017
acac3ee
Merge branch 'master' of github.com:swagger-api/swagger-ui
owenconti Sep 15, 2017
33ee880
Add extra check for String types in `createDeepLinkPath`. Add `trim()…
owenconti Sep 15, 2017
fa312cb
Merge branch 'master' into bug/oas3-accept-controls
shockey Sep 16, 2017
ef8b37a
LINTING!
shockey Sep 16, 2017
ef5904f
Merge pull request #3668 from owenconti/test/3667-escaping-utils-tests
shockey Sep 16, 2017
bd54243
Merge branch 'master' into bug/oas3-accept-controls
shockey Sep 16, 2017
6010245
Roll back win import removal
shockey Sep 16, 2017
ae5ad48
More merge oversights...
shockey Sep 16, 2017
a777e9b
Merge pull request #3669 from shockey/bug/oas3-accept-controls
shockey Sep 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ or anything that violates the specifications.
| Which Swagger/OpenAPI version? |
| Which Swagger-UI version? |
| How did you install Swagger-UI? |
| Which broswer & version? |
| Which browser & version? |
| Which operating system? |


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The OpenAPI Specification has undergone 5 revisions since initial creation in 20

Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ | ------------ | -------------------------- | -----
3.1.6 | 2017-08-18 | 2.0, 3.0 | [tag v3.1.6](https://github.com/swagger-api/swagger-ui/tree/v3.1.6)
3.2.0 | 2017-09-08 | 2.0, 3.0 | [tag v3.2.0](https://github.com/swagger-api/swagger-ui/tree/v3.2.0)
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
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)
Expand All @@ -46,7 +46,7 @@ Will start nginx with swagger-ui on port 80.
Or you can provide your own swagger.json on your host

```
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
```

##### Prerequisites
Expand Down
6 changes: 5 additions & 1 deletion dev-helpers/oauth2-redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;

qp = (window.location.hash || location.search).substring(1);
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
qp = location.search.substring(1);
}

arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
Expand Down
6 changes: 5 additions & 1 deletion dist/oauth2-redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;

qp = (window.location.hash || location.search).substring(1);
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
qp = location.search.substring(1);
}

arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
Expand Down
22 changes: 11 additions & 11 deletions dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-standalone-preset.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/swagger-ui.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.1.6",
"version": "3.2.0",
"main": "dist/swagger-ui.js",
"repository": "[email protected]:swagger-api/swagger-ui.git",
"contributors": [
Expand Down Expand Up @@ -41,6 +41,8 @@
"dependencies": {
"base64-js": "^1.2.0",
"brace": "0.7.0",
"classnames": "^2.2.5",
"css.escape": "1.5.1",
"deep-extend": "0.4.1",
"expect": "1.20.2",
"getbase": "^2.8.2",
Expand Down Expand Up @@ -75,7 +77,7 @@
"scroll-to-element": "^2.0.0",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "3.0.20",
"swagger-client": "3.1.0",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
Expand Down
7 changes: 6 additions & 1 deletion src/core/components/array-model.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ export default class ArrayModel extends Component {
<span className="model-title__text">{ title }</span>
</span>

/*
Note: we set `name={null}` in <Model> below because we don't want
the name of the current Model passed (and displayed) as the name of the array element Model
*/

return <span className="model">
<ModelCollapse title={titleEl} collapsed={ depth > expandDepth } collapsedContent="[...]">
[
<span><Model { ...this.props } schema={ items } required={ false } depth={ depth + 1 } /></span>
<span><Model { ...this.props } name={null} schema={ items } required={ false } depth={ depth + 1 } /></span>
]
{
properties.size ? <span>
Expand Down
29 changes: 28 additions & 1 deletion src/core/components/layouts/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export default class BaseLayout extends React.Component {
errActions: PropTypes.object.isRequired,
specActions: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
oas3Selectors: PropTypes.object.isRequired,
oas3Actions: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired
Expand All @@ -19,7 +21,14 @@ export default class BaseLayout extends React.Component {
}

render() {
let { specSelectors, specActions, getComponent, layoutSelectors } = this.props
let {
specSelectors,
specActions,
getComponent,
layoutSelectors,
oas3Selectors,
oas3Actions
} = this.props

let info = specSelectors.info()
let url = specSelectors.url()
Expand All @@ -28,13 +37,15 @@ export default class BaseLayout extends React.Component {
let securityDefinitions = specSelectors.securityDefinitions()
let externalDocs = specSelectors.externalDocs()
let schemes = specSelectors.schemes()
let servers = specSelectors.servers()

let Info = getComponent("info")
let Operations = getComponent("operations", true)
let Models = getComponent("Models", true)
let AuthorizeBtn = getComponent("authorizeBtn", true)
let Row = getComponent("Row")
let Col = getComponent("Col")
let Servers = getComponent("Servers")
let Errors = getComponent("errors", true)

let isLoading = specSelectors.loadingStatus() === "loading"
Expand Down Expand Up @@ -82,6 +93,22 @@ export default class BaseLayout extends React.Component {
</div>
) : null }

{ servers && servers.size ? (
<div className="server-container">
<Col className="servers wrapper" mobile={12}>
<Servers
servers={servers}
currentServer={oas3Selectors.selectedServer()}
setSelectedServer={oas3Actions.setSelectedServer}
setServerVariableValue={oas3Actions.setServerVariableValue}
getServerVariable={oas3Selectors.serverVariableValue}
getEffectiveServerValue={oas3Selectors.serverEffectiveValue}
/>
</Col>
</div>

) : null}

{
filter === null || filter === false ? null :
<div className="filter-container">
Expand Down
50 changes: 25 additions & 25 deletions src/core/components/model.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,38 @@ export default class Model extends Component {

render () {
let { getComponent, specSelectors, schema, required, name, isRef } = this.props
let ObjectModel = getComponent("ObjectModel")
let ArrayModel = getComponent("ArrayModel")
let PrimitiveModel = getComponent("PrimitiveModel")
const ObjectModel = getComponent("ObjectModel")
const ArrayModel = getComponent("ArrayModel")
const PrimitiveModel = getComponent("PrimitiveModel")
let type = "object"
let $$ref = schema && schema.get("$$ref")
let modelName = $$ref && this.getModelName( $$ref )
let modelSchema, type

const deprecated = specSelectors.isOAS3() && schema.get("deprecated")

if ( schema && (schema.get("type") || schema.get("properties")) ) {
modelSchema = schema
} else if ( $$ref ) {
modelSchema = this.getRefSchema( modelName )

// If we weren't passed a `name` but have a ref, grab the name from the ref
if ( !name && $$ref ) {
name = this.getModelName( $$ref )
}

type = modelSchema && modelSchema.get("type")
if ( !type && modelSchema && modelSchema.get("properties") ) {
type = "object"
// If we weren't passed a `schema` but have a ref, grab the schema from the ref
if ( !schema && $$ref ) {
schema = this.getRefSchema( name )
}


const deprecated = specSelectors.isOAS3() && schema.get("deprecated")
isRef = isRef !== undefined ? isRef : !!$$ref
type = schema && schema.get("type") || type

switch(type) {
case "object":
return <ObjectModel
className="object" { ...this.props }
schema={ modelSchema }
name={ modelName || name }
schema={ schema }
name={ name }
deprecated={deprecated}
isRef={ isRef!== undefined ? isRef : !!$$ref } />
isRef={ isRef } />
case "array":
return <ArrayModel
className="array" { ...this.props }
schema={ modelSchema }
name={ modelName || name }
schema={ schema }
name={ name }
deprecated={deprecated}
required={ required } />
case "string":
Expand All @@ -73,9 +72,10 @@ export default class Model extends Component {
return <PrimitiveModel
{ ...this.props }
getComponent={ getComponent }
schema={ modelSchema }
name={ modelName || name }
schema={ schema }
name={ name }
deprecated={deprecated}
required={ required }/> }
required={ required }/>
}
}
}
1 change: 0 additions & 1 deletion src/core/components/models.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default class Models extends Component {
return <div className="model-container" key={ `models-section-${name}` }>
<ModelWrapper name={ name }
schema={ model }
isRef={ true }
getComponent={ getComponent }
specSelectors={ specSelectors }/>
</div>
Expand Down
17 changes: 10 additions & 7 deletions src/core/components/operation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class Operation extends PureComponent {
authSelectors: PropTypes.object,
specActions: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
oas3Actions: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
layoutSelectors: PropTypes.object.isRequired,
fn: PropTypes.object.isRequired,
Expand Down Expand Up @@ -117,7 +118,8 @@ export default class Operation extends PureComponent {
specSelectors,
authActions,
authSelectors,
getConfigs
getConfigs,
oas3Actions
} = this.props

let summary = operation.get("summary")
Expand Down Expand Up @@ -161,12 +163,12 @@ export default class Operation extends PureComponent {
<div className={`opblock-summary opblock-summary-${method}`} onClick={this.toggleShown} >
<span className="opblock-summary-method">{method.toUpperCase()}</span>
<span className={ deprecated ? "opblock-summary-path__deprecated" : "opblock-summary-path" } >
<a
className="nostyle"
onClick={(e) => e.preventDefault()}
href={ isDeepLinkingEnabled ? `#/${isShownKey[1]}/${isShownKey[2]}` : ""} >
<span>{path}</span>
</a>
<a
className="nostyle"
onClick={isDeepLinkingEnabled ? (e) => e.preventDefault() : null}
href={isDeepLinkingEnabled ? `#/${isShownKey[1]}/${isShownKey[2]}` : null}>
<span>{path}</span>
</a>
<JumpToPath path={jumpToKey} />
</span>

Expand Down Expand Up @@ -265,6 +267,7 @@ export default class Operation extends PureComponent {
getComponent={ getComponent }
getConfigs={ getConfigs }
specSelectors={ specSelectors }
oas3Actions={oas3Actions}
specActions={ specActions }
produces={ produces }
producesValue={ operation.get("produces_value") }
Expand Down
14 changes: 9 additions & 5 deletions src/core/components/operations.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from "react"
import PropTypes from "prop-types"
import { helpers } from "swagger-client"

import { createDeepLinkPath } from "core/utils"
const { opId } = helpers

export default class Operations extends React.Component {

static propTypes = {
specSelectors: PropTypes.object.isRequired,
specActions: PropTypes.object.isRequired,
oas3Actions: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired,
layoutSelectors: PropTypes.object.isRequired,
layoutActions: PropTypes.object.isRequired,
Expand All @@ -21,6 +22,7 @@ export default class Operations extends React.Component {
let {
specSelectors,
specActions,
oas3Actions,
getComponent,
layoutSelectors,
layoutActions,
Expand Down Expand Up @@ -69,7 +71,7 @@ export default class Operations extends React.Component {
let tagExternalDocsDescription = tagObj.getIn(["tagDetails", "externalDocs", "description"])
let tagExternalDocsUrl = tagObj.getIn(["tagDetails", "externalDocs", "url"])

let isShownKey = ["operations-tag", tag]
let isShownKey = ["operations-tag", createDeepLinkPath(tag)]
let showTag = layoutSelectors.isShown(isShownKey, docExpansion === "full" || docExpansion === "list")

return (
Expand All @@ -81,8 +83,8 @@ export default class Operations extends React.Component {
id={isShownKey.join("-")}>
<a
className="nostyle"
onClick={(e) => e.preventDefault()}
href={ isDeepLinkingEnabled ? `#/${tag}` : ""}>
onClick={isDeepLinkingEnabled ? (e) => e.preventDefault() : null}
href= {isDeepLinkingEnabled ? `#/${tag}` : null}>
<span>{tag}</span>
</a>
{ !tagDescription ? null :
Expand Down Expand Up @@ -124,7 +126,7 @@ export default class Operations extends React.Component {

const operationId =
op.getIn(["operation", "operationId"]) || op.getIn(["operation", "__originalOperationId"]) || opId(op.get("operation"), path, method) || op.get("id")
const isShownKey = ["operations", tag, operationId]
const isShownKey = ["operations", createDeepLinkPath(tag), createDeepLinkPath(operationId)]

const allowTryItOut = specSelectors.allowTryItOutFor(op.get("path"), op.get("method"))
const response = specSelectors.responseFor(op.get("path"), op.get("method"))
Expand All @@ -147,6 +149,8 @@ export default class Operations extends React.Component {
specActions={ specActions }
specSelectors={ specSelectors }

oas3Actions={oas3Actions}

layoutActions={ layoutActions }
layoutSelectors={ layoutSelectors }

Expand Down
3 changes: 1 addition & 2 deletions src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ export default class ParameterRow extends Component {
const Markdown = getComponent("Markdown")

let schema = param.get("schema")

let type = isOAS3 && isOAS3() ? param.getIn(["schema", "type"]) : param.get("type")
let isFormData = inType === "formData"
let isFormDataSupported = "FormData" in win
let required = param.get("required")
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
let parameter = specSelectors.getParameter(pathMethod, param.get("name"))
let value = parameter ? parameter.get("value") : ""

Expand Down
Loading