Skip to content

Commit b7bbead

Browse files
committed
Merge branch 'master' into issue-1334
# Conflicts: # .gitignore # make-webpack-config.js
2 parents 7cb6bdd + ad8bad6 commit b7bbead

File tree

96 files changed

+2596
-1044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2596
-1044
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ node_modules
55
npm-debug.log*
66
.eslintcache
77
package-lock.json
8-
selenium-debug.log
8+
*.iml

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ deploy:
1616
1717
skip_cleanup: true
1818
api_key:
19-
secure: "IJkLaACa+rfERf1O5nwlqOyuo9sbul3FBhBt4Un9P+DvEet3AoDPV9NQVLd8SkmQYKGbGQWF4BIdjrO5nqFD6Te+JTeUX5Uo/DFS/fu9qw1xv0dQpvbJFuoYnnFlbzGTEs4CFa8lbu3ZromFHQGOQxRobjsG1Kf0dWFSSzmND3g="
19+
secure: "YKk5L1BL4oAixvLjWp+i85fNFXK85HKOlUt6QypkZkt23My5aywuYsv5VCLjjOtuWc72zbmOzP82DTBsuRswCRViXWCiNYhl42QTdvadHu0uIlM/FL6aNlvPpzXIws4bMvz1aYOTzFTnSnNuvCTzF1daW0+2ClOo3r0nLEdDfFg="
2020
on:
2121
tags: true
2222
repo: swagger-api/swagger-ui

README.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ This repo publishes to two different NPM packages:
1818
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
1919

2020
## Compatibility
21-
The OpenAPI Specification has undergone 4 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
21+
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between swagger-ui and the OpenAPI Specification is as follows:
2222

23-
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
24-
------------------ | ------------ | -------------------------- | ----- | ------
25-
3.0.17 | 2017-06-23 | 2.0 | [tag v3.0.17](https://github.com/swagger-api/swagger-ui/tree/v3.0.17) |
26-
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) |
27-
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) |
28-
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) |
29-
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
30-
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
23+
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
24+
------------------ | ------------ | -------------------------- | -----
25+
3.1.2 | 2017-07-31 | 2.0, 3.0 | [tag v3.1.2](https://github.com/swagger-api/swagger-ui/tree/v3.1.2)
26+
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
27+
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)
28+
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)
29+
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)
30+
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13)
31+
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1)
3132

3233

3334
### How to run
@@ -74,7 +75,6 @@ To help with the migration, here are the currently known issues with 3.X. This l
7475

7576
- Only part of the [parameters](#parameters) previously supported are available.
7677
- The JSON Form Editor is not implemented.
77-
- Shebang URL support for operations is missing.
7878
- Support for `collectionFormat` is partial.
7979
- l10n (translations) is not implemented.
8080
- Relative path support for external files is not implemented.
@@ -89,22 +89,23 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
8989

9090
```javascript
9191
const ui = SwaggerUIBundle({
92-
url: "http://petstore.swagger.io/v2/swagger.json",
93-
dom_id: '#swagger-ui',
94-
presets: [
95-
SwaggerUIBundle.presets.apis,
96-
SwaggerUIStandalonePreset
97-
],
98-
plugins: [
99-
SwaggerUIBundle.plugins.DownloadUrl
100-
],
101-
layout: "StandaloneLayout"
102-
})
92+
url: "http://petstore.swagger.io/v2/swagger.json",
93+
dom_id: '#swagger-ui',
94+
presets: [
95+
SwaggerUIBundle.presets.apis,
96+
SwaggerUIStandalonePreset
97+
],
98+
plugins: [
99+
SwaggerUIBundle.plugins.DownloadUrl
100+
],
101+
layout: "StandaloneLayout"
102+
})
103103
```
104104

105105
#### OAuth2 configuration
106106
You can configure OAuth2 authorization by calling `initOAuth` method with passed configs under the instance of `SwaggerUIBundle`
107-
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`.
107+
default `client_id` and `client_secret`, `realm`, an application name `appName`, `scopeSeparator`, `additionalQueryStringParams`,
108+
`useBasicAuthenticationWithAccessCodeGrant`.
108109

109110
Config Name | Description
110111
--- | ---
@@ -114,6 +115,7 @@ realm | realm query parameter (for oauth1) added to `authorizationUrl` and `toke
114115
appName | application name, displayed in authorization popup. MUST be a string
115116
scopeSeparator | scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string
116117
additionalQueryStringParams | Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
118+
useBasicAuthenticationWithAccessCodeGrant | Only activated for the `accessCode` flow. During the `authorization_code` request to the `tokenUrl`, pass the [Client Password](https://tools.ietf.org/html/rfc6749#section-2.3.1) using the HTTP Basic Authentication scheme (`Authorization` header with `Basic base64encoded[client_id:client_secret]`). The default is `false`
117119

118120
```
119121
const ui = SwaggerUIBundle({...})
@@ -144,13 +146,17 @@ spec | A JSON object describing the OpenAPI Specification. When used, the `url`
144146
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.
145147
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
146148
oauth2RedirectUrl | OAuth redirect URL
149+
tagsSorter | Apply a sort to the tag list of each API. It can be 'alpha' (sort by paths alphanumerically) or a function (see [Array.prototype.sort()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) to learn how to write a sort function). Two tag name strings are passed to the sorter for each pass. Default is the order determined by Swagger-UI.
147150
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.
148151
configUrl | Configs URL
149152
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
150153
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
151154
docExpansion | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default is 'list'.
152155
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
153-
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
156+
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
157+
maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations.
158+
filter | If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be true/false to enable or disable, or an explicit filter string in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag.
159+
deepLinking | If set to `true`, enables dynamic deep linking for tags and operations. [Docs](https://github.com/swagger-api/swagger-ui/blob/master/docs/deep-linking.md)
154160

155161
### Plugins
156162

@@ -240,6 +246,10 @@ Access-Control-Allow-Headers: Content-Type, api_key, Authorization
240246

241247
Only headers with these names will be allowed to be sent by Swagger-UI.
242248

249+
## Security contact
250+
251+
Please disclose any security-related issues or vulnerabilities by emailing [[email protected]](mailto:[email protected]), instead of using the public issue tracker.
252+
243253
## License
244254

245255
Copyright 2017 SmartBear Software

docs/deep-linking.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Deep linking
2+
3+
Swagger-UI allows you to deeply link into tags and operations within a spec. When Swagger-UI is provided a URL fragment at runtime, it will automatically expand and scroll to a specified tag or operation.
4+
5+
## Usage
6+
7+
👉🏼 Add `deepLinking: true` to your Swagger-UI configuration to enable this functionality.
8+
9+
When you expand a tag or operation, Swagger-UI will automatically update its URL fragment with a deep link to the item.
10+
Conversely, when you collapse a tag or operation, Swagger-UI will clear the URL fragment.
11+
12+
You can also right-click a tag name or operation path in order to copy a link to that tag or operation.
13+
14+
#### Fragment format
15+
16+
The fragment is formatted in one of two ways:
17+
18+
- `#/{tagName}`, to trigger the focus of a specific tag
19+
- `#/{tagName}/{operationId}`, to trigger the focus of a specific operation within a tag
20+
21+
`operationId` is the explicit operationId provided in the spec, if one exists.
22+
Otherwise, Swagger-UI generates an implicit operationId by combining the operation's path and method, and escaping non-alphanumeric characters.
23+
24+
## FAQ
25+
26+
> I'm using Swagger-UI in an application that needs control of the URL fragment. How do I disable deep-linking?
27+
28+
This functionality is disabled by default, but you can pass `deepLinking: false` into Swagger-UI as a configuration item to be sure.
29+
30+
> Can I link to multiple tags or operations?
31+
32+
No, this is not supported.
33+
34+
> Can I collapse everything except the operation or tag I'm linking to?
35+
36+
Sure - use `docExpansion: none` to collapse all tags and operations. Your deep link will take precedence over the setting, so only the tag or operation you've specified will be expanded.

make-webpack-config.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
1-
var path = require('path')
1+
var path = require("path")
22

33
var webpack = require('webpack')
44
var ExtractTextPlugin = require('extract-text-webpack-plugin')
55
const CopyWebpackPlugin = require('copy-webpack-plugin')
66
var deepExtend = require('deep-extend')
77
const {gitDescribeSync} = require('git-describe')
8+
const os = require("os")
89

9-
var pkg = require('./package.json')
10+
var pkg = require("./package.json")
1011

1112
let gitInfo
1213

1314
try {
1415
gitInfo = gitDescribeSync(__dirname)
1516
} catch(e) {
1617
gitInfo = {
17-
hash: 'noGit',
18+
hash: "noGit",
1819
dirty: false
1920
}
2021
}
2122

2223
var commonRules = [
2324
{ test: /\.(js(x)?)(\?.*)?$/,
2425
use: [{
25-
loader: 'babel-loader',
26+
loader: "babel-loader",
2627
options: {
2728
retainLines: true
2829
}
2930
}],
30-
include: [ path.join(__dirname, 'src') ]
31+
include: [ path.join(__dirname, "src") ]
3132
},
3233
{ test: /\.(txt|yaml)(\?.*)?$/,
33-
loader: 'raw-loader' },
34+
loader: "raw-loader" },
3435
{ test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
35-
loader: 'url-loader?limit=10000' },
36+
loader: "url-loader?limit=10000" },
3637
{ test: /\.(woff|woff2)(\?.*)?$/,
37-
loader: 'url-loader?limit=100000' },
38+
loader: "url-loader?limit=100000" },
3839
{ test: /\.(ttf|eot)(\?.*)?$/,
39-
loader: 'file-loader' }
40+
loader: "file-loader" }
4041
]
4142

4243
module.exports = function(rules, options) {
@@ -55,7 +56,7 @@ module.exports = function(rules, options) {
5556

5657
if( specialOptions.separateStylesheets ) {
5758
plugins.push(new ExtractTextPlugin({
58-
filename: '[name].css' + (specialOptions.longTermCaching ? '?[contenthash]' : ''),
59+
filename: "[name].css" + (specialOptions.longTermCaching ? "?[contenthash]" : ""),
5960
allChunks: true
6061
}))
6162
}
@@ -81,61 +82,62 @@ module.exports = function(rules, options) {
8182

8283
plugins.push(
8384
new webpack.DefinePlugin({
84-
'process.env': {
85-
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
86-
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
87-
85+
"process.env": {
86+
NODE_ENV: specialOptions.minimize ? JSON.stringify("production") : null,
87+
WEBPACK_INLINE_STYLES: !specialOptions.separateStylesheets
8888
},
89-
'buildInfo': JSON.stringify({
89+
"buildInfo": JSON.stringify({
9090
PACKAGE_VERSION: (pkg.version),
9191
GIT_COMMIT: gitInfo.hash,
92-
GIT_DIRTY: gitInfo.dirty
92+
GIT_DIRTY: gitInfo.dirty,
93+
HOSTNAME: os.hostname(),
94+
BUILD_TIME: new Date().toUTCString()
9395
})
9496
}))
9597

9698
delete options._special
9799

98-
var completeConfig = deepExtend({
100+
var completeConfig = deepExtend({
99101
entry: {},
100102

101103
output: {
102-
path: path.join(__dirname, 'dist'),
103-
publicPath: '/',
104-
filename: '[name].js',
105-
chunkFilename: '[name].js'
104+
path: path.join(__dirname, "dist"),
105+
publicPath: "/",
106+
filename: "[name].js",
107+
chunkFilename: "[name].js"
106108
},
107109

108-
target: 'web',
110+
target: "web",
109111

110112
// yaml-js has a reference to `fs`, this is a workaround
111113
node: {
112-
fs: 'empty'
114+
fs: "empty"
113115
},
114116

115117
module: {
116118
rules: commonRules.concat(rules),
117119
},
118120

119121
resolveLoader: {
120-
modules: [path.join(__dirname, 'node_modules')],
122+
modules: [path.join(__dirname, "node_modules")],
121123
},
122124

123125
externals: {
124-
'buffertools': true // json-react-schema/deeper depends on buffertools, which fails.
126+
"buffertools": true // json-react-schema/deeper depends on buffertools, which fails.
125127
},
126128

127129
resolve: {
128130
modules: [
129-
path.join(__dirname, './src'),
130-
'node_modules'
131+
path.join(__dirname, "./src"),
132+
"node_modules"
131133
],
132134
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
133135
alias: {
134136
base: "getbase/src/less/base",
135137
}
136138
},
137139

138-
devtool: specialOptions.sourcemaps ? 'cheap-module-source-map' : null,
140+
devtool: specialOptions.sourcemaps ? "cheap-module-source-map" : null,
139141

140142
plugins,
141143

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
"karma-sourcemap-loader": "^0.3.7",
117117
"karma-webpack": "2.0.3",
118118
"less": "2.7.2",
119-
"less-loader": "4.0.4",
120119
"license-checker": "^11.0.0",
121120
"mocha": "^3.4.2",
122121
"nightwatch": "^0.9.16",

postcss.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
module.exports = {};
1+
module.exports = {
2+
plugins: [
3+
require("autoprefixer")
4+
]
5+
}

src/core/components/array-model.jsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, { Component } from "react"
2+
import PropTypes from "prop-types"
3+
4+
const propStyle = { color: "#999", fontStyle: "italic" }
5+
6+
export default class ArrayModel extends Component {
7+
static propTypes = {
8+
schema: PropTypes.object.isRequired,
9+
getComponent: PropTypes.func.isRequired,
10+
specSelectors: PropTypes.object.isRequired,
11+
name: PropTypes.string,
12+
required: PropTypes.bool,
13+
expandDepth: PropTypes.number,
14+
depth: PropTypes.number
15+
}
16+
17+
render(){
18+
let { getComponent, required, schema, depth, expandDepth, name } = this.props
19+
let items = schema.get("items")
20+
let title = schema.get("title") || name
21+
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
22+
23+
const ModelCollapse = getComponent("ModelCollapse")
24+
const Model = getComponent("Model")
25+
26+
const titleEl = title &&
27+
<span className="model-title">
28+
<span className="model-title__text">{ title }</span>
29+
</span>
30+
31+
return <span className="model">
32+
<ModelCollapse title={titleEl} collapsed={ depth > expandDepth } collapsedContent="[...]">
33+
[
34+
<span><Model { ...this.props } schema={ items } required={ false }/></span>
35+
]
36+
{
37+
properties.size ? <span>
38+
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
39+
<br />{ `${key}:`}{ String(v) }</span>)
40+
}<br /></span>
41+
: null
42+
}
43+
</ModelCollapse>
44+
{ required && <span style={{ color: "red" }}>*</span>}
45+
</span>
46+
}
47+
}

src/core/components/content-type.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const noop = ()=>{}
88
export default class ContentType extends React.Component {
99

1010
static propTypes = {
11-
contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set]),
11+
contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]),
1212
value: PropTypes.string,
1313
onChange: PropTypes.func,
1414
className: PropTypes.string
@@ -22,7 +22,9 @@ export default class ContentType extends React.Component {
2222

2323
componentDidMount() {
2424
// Needed to populate the form, initially
25-
this.props.onChange(this.props.contentTypes.first())
25+
if(this.props.contentTypes) {
26+
this.props.onChange(this.props.contentTypes.first())
27+
}
2628
}
2729

2830
onChangeWrapper = e => this.props.onChange(e.target.value)

0 commit comments

Comments
 (0)