Skip to content

Commit ec33480

Browse files
authored
Merge branch 'master' into bug/3361-non-required-integers
2 parents 6beaaca + 08e84a0 commit ec33480

File tree

27 files changed

+631
-403
lines changed

27 files changed

+631
-403
lines changed

.gitignore

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

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ To use swagger-ui's bundles, you should take a look at the [source of swagger-ui
8282

8383
```javascript
8484
const ui = SwaggerUIBundle({
85-
url: "http://petstore.swagger.io/v2/swagger.json",
86-
dom_id: '#swagger-ui',
87-
presets: [
88-
SwaggerUIBundle.presets.apis,
89-
SwaggerUIStandalonePreset
90-
],
91-
plugins: [
92-
SwaggerUIBundle.plugins.DownloadUrl
93-
],
94-
layout: "StandaloneLayout"
95-
})
85+
url: "http://petstore.swagger.io/v2/swagger.json",
86+
dom_id: '#swagger-ui',
87+
presets: [
88+
SwaggerUIBundle.presets.apis,
89+
SwaggerUIStandalonePreset
90+
],
91+
plugins: [
92+
SwaggerUIBundle.plugins.DownloadUrl
93+
],
94+
layout: "StandaloneLayout"
95+
})
9696
```
9797

9898
#### OAuth2 configuration
@@ -137,13 +137,16 @@ spec | A JSON object describing the OpenAPI Specification. When used, the `url`
137137
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.
138138
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
139139
oauth2RedirectUrl | OAuth redirect URL
140+
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.
140141
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.
141142
configUrl | Configs URL
142143
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
143144
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
144145
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'.
145146
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
146147
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
148+
maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations.
149+
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.
147150

148151
### Plugins
149152

dev-helpers/index.html

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
<style>
1212
html
1313
{
14-
box-sizing: border-box;
15-
overflow: -moz-scrollbars-vertical;
16-
overflow-y: scroll;
14+
box-sizing: border-box;
15+
overflow: -moz-scrollbars-vertical;
16+
overflow-y: scroll;
1717
}
1818
*,
1919
*:before,
2020
*:after
2121
{
22-
box-sizing: inherit;
22+
box-sizing: inherit;
2323
}
2424

2525
body {
@@ -34,7 +34,7 @@
3434
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
3535
<defs>
3636
<symbol viewBox="0 0 20 20" id="unlocked">
37-
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
37+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
3838
</symbol>
3939

4040
<symbol viewBox="0 0 20 20" id="locked">
@@ -70,34 +70,34 @@
7070
<script src="./swagger-ui-bundle.js"> </script>
7171
<script src="./swagger-ui-standalone-preset.js"> </script>
7272
<script>
73-
window.onload = function() {
74-
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
75-
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
76-
// Build a system
77-
const ui = SwaggerUIBundle({
78-
url: "http://petstore.swagger.io/v2/swagger.json",
79-
dom_id: '#swagger-ui',
80-
presets: [
81-
SwaggerUIBundle.presets.apis,
82-
SwaggerUIStandalonePreset
83-
],
84-
plugins: [
85-
SwaggerUIBundle.plugins.DownloadUrl
86-
],
87-
layout: "StandaloneLayout"
88-
})
89-
90-
window.ui = ui
91-
92-
ui.initOAuth({
93-
clientId: "your-client-id",
94-
clientSecret: "your-client-secret-if-required",
95-
realm: "your-realms",
96-
appName: "your-app-name",
97-
scopeSeparator: " ",
98-
additionalQueryStringParams: {}
99-
})
100-
}
73+
window.onload = function() {
74+
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
75+
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
76+
// Build a system
77+
const ui = SwaggerUIBundle({
78+
url: "http://petstore.swagger.io/v2/swagger.json",
79+
dom_id: '#swagger-ui',
80+
presets: [
81+
SwaggerUIBundle.presets.apis,
82+
SwaggerUIStandalonePreset
83+
],
84+
plugins: [
85+
SwaggerUIBundle.plugins.DownloadUrl
86+
],
87+
layout: "StandaloneLayout"
88+
})
89+
90+
window.ui = ui
91+
92+
ui.initOAuth({
93+
clientId: "your-client-id",
94+
clientSecret: "your-client-secret-if-required",
95+
realm: "your-realms",
96+
appName: "your-app-name",
97+
scopeSeparator: " ",
98+
additionalQueryStringParams: {}
99+
})
100+
}
101101
</script>
102102
</body>
103103

make-webpack-config.js

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

3-
var webpack = require('webpack')
4-
var ExtractTextPlugin = require('extract-text-webpack-plugin')
5-
var deepExtend = require('deep-extend')
6-
const {gitDescribeSync} = require('git-describe');
3+
var webpack = require("webpack")
4+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
5+
var deepExtend = require("deep-extend")
6+
const {gitDescribeSync} = require("git-describe")
7+
const os = require("os")
78

8-
var pkg = require('./package.json')
9+
var pkg = require("./package.json")
910

1011
let gitInfo
1112

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

2122
var commonRules = [
2223
{ test: /\.(js(x)?)(\?.*)?$/,
2324
use: [{
24-
loader: 'babel-loader',
25+
loader: "babel-loader",
2526
options: {
2627
retainLines: true
2728
}
2829
}],
29-
include: [ path.join(__dirname, 'src') ]
30+
include: [ path.join(__dirname, "src") ]
3031
},
3132
{ test: /\.(txt|yaml)(\?.*)?$/,
32-
loader: 'raw-loader' },
33+
loader: "raw-loader" },
3334
{ test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
34-
loader: 'url-loader?limit=10000' },
35+
loader: "url-loader?limit=10000" },
3536
{ test: /\.(woff|woff2)(\?.*)?$/,
36-
loader: 'url-loader?limit=100000' },
37+
loader: "url-loader?limit=100000" },
3738
{ test: /\.(ttf|eot)(\?.*)?$/,
38-
loader: 'file-loader' }
39+
loader: "file-loader" }
3940
]
4041

4142
module.exports = function(rules, options) {
@@ -54,7 +55,7 @@ module.exports = function(rules, options) {
5455

5556
if( specialOptions.separateStylesheets ) {
5657
plugins.push(new ExtractTextPlugin({
57-
filename: '[name].css' + (specialOptions.longTermCaching ? '?[contenthash]' : ''),
58+
filename: "[name].css" + (specialOptions.longTermCaching ? "?[contenthash]" : ""),
5859
allChunks: true
5960
}))
6061
}
@@ -78,61 +79,62 @@ module.exports = function(rules, options) {
7879

7980
plugins.push(
8081
new webpack.DefinePlugin({
81-
'process.env': {
82-
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
83-
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
84-
82+
"process.env": {
83+
NODE_ENV: specialOptions.minimize ? JSON.stringify("production") : null,
84+
WEBPACK_INLINE_STYLES: !specialOptions.separateStylesheets
8585
},
86-
'buildInfo': JSON.stringify({
86+
"buildInfo": JSON.stringify({
8787
PACKAGE_VERSION: (pkg.version),
8888
GIT_COMMIT: gitInfo.hash,
89-
GIT_DIRTY: gitInfo.dirty
89+
GIT_DIRTY: gitInfo.dirty,
90+
HOSTNAME: os.hostname(),
91+
BUILD_TIME: new Date().toUTCString()
9092
})
9193
}))
9294

9395
delete options._special
9496

95-
var completeConfig = deepExtend({
97+
var completeConfig = deepExtend({
9698
entry: {},
9799

98100
output: {
99-
path: path.join(__dirname, 'dist'),
100-
publicPath: '/',
101-
filename: '[name].js',
102-
chunkFilename: '[name].js'
101+
path: path.join(__dirname, "dist"),
102+
publicPath: "/",
103+
filename: "[name].js",
104+
chunkFilename: "[name].js"
103105
},
104106

105-
target: 'web',
107+
target: "web",
106108

107109
// yaml-js has a reference to `fs`, this is a workaround
108110
node: {
109-
fs: 'empty'
111+
fs: "empty"
110112
},
111113

112114
module: {
113115
rules: commonRules.concat(rules),
114116
},
115117

116118
resolveLoader: {
117-
modules: [path.join(__dirname, 'node_modules')],
119+
modules: [path.join(__dirname, "node_modules")],
118120
},
119121

120122
externals: {
121-
'buffertools': true // json-react-schema/deeper depends on buffertools, which fails.
123+
"buffertools": true // json-react-schema/deeper depends on buffertools, which fails.
122124
},
123125

124126
resolve: {
125127
modules: [
126-
path.join(__dirname, './src'),
127-
'node_modules'
128+
path.join(__dirname, "./src"),
129+
"node_modules"
128130
],
129131
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
130132
alias: {
131133
base: "getbase/src/less/base",
132134
}
133135
},
134136

135-
devtool: specialOptions.sourcemaps ? 'cheap-module-source-map' : null,
137+
devtool: specialOptions.sourcemaps ? "cheap-module-source-map" : null,
136138

137139
plugins,
138140

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 } = this.props
19+
let items = schema.get("items")
20+
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
21+
22+
const ModelCollapse = getComponent("ModelCollapse")
23+
const Model = getComponent("Model")
24+
25+
return <span className="model">
26+
<span className="model-title">
27+
<span className="model-title__text">{ schema.get("title") }</span>
28+
</span>
29+
<ModelCollapse collapsed={ depth > expandDepth } collapsedContent="[...]">
30+
[
31+
<span><Model { ...this.props } schema={ items } required={ false }/></span>
32+
]
33+
{
34+
properties.size ? <span>
35+
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
36+
<br />{ `${key}:`}{ String(v) }</span>)
37+
}<br /></span>
38+
: null
39+
}
40+
</ModelCollapse>
41+
{ required && <span style={{ color: "red" }}>*</span>}
42+
</span>
43+
}
44+
}

src/core/components/enum-model.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react"
2+
import ImPropTypes from "react-immutable-proptypes"
3+
4+
const EnumModel = ({ value, getComponent }) => {
5+
let ModelCollapse = getComponent("ModelCollapse")
6+
let collapsedContent = <span>Array [ { value.count() } ]</span>
7+
return <span className="prop-enum">
8+
Enum:<br />
9+
<ModelCollapse collapsedContent={ collapsedContent }>
10+
[ { value.join(", ") } ]
11+
</ModelCollapse>
12+
</span>
13+
}
14+
EnumModel.propTypes = {
15+
value: ImPropTypes.iterable,
16+
getComponent: ImPropTypes.func
17+
}
18+
19+
export default EnumModel

0 commit comments

Comments
 (0)