Compare commits

..
73 Commits
Author SHA1 Message Date
shockey e45edc56dc Merge pull request #3443 from shockey/v/3.0.20
v3.0.20
2017-07-21 21:52:35 -07:00
Kyle Shockey 2e773f0654 Rebuild dist 2017-07-21 21:47:32 -07:00
Kyle Shockey f4f8ee5f57 Merge branch 'master' of github.com:swagger-api/swagger-ui into v/3.0.20 2017-07-21 21:45:50 -07:00
Kyle Shockey 4b404f63ec v3.0.20 2017-07-21 21:35:02 -07:00
shockey b448c4881e Merge pull request #3442 from owenconti/bug/3435-image-png-responses
Add max-width
2017-07-21 20:01:52 -07:00
Owen Conti ae901bc19d Merge branch 'master' into bug/3435-image-png-responses 2017-07-21 20:58:16 -06:00
Owen Conti e24300c8de Merge branch 'bug/3435-image-png-responses' of github.com:owenconti/swagger-ui into bug/3435-image-png-responses 2017-07-21 20:56:33 -06:00
Owen Conti 454e9af16b Added max-width style to scale down large images 2017-07-21 20:56:00 -06:00
shockey ae2c4e813c Merge pull request #3441 from owenconti/bug/3435-image-png-responses
Fixes #3435 - Fix rendering of image/* content types
2017-07-21 19:53:19 -07:00
Owen Conti 84e6cec9c1 Merge branch 'master' into bug/3435-image-png-responses 2017-07-21 20:49:23 -06:00
shockey 3b880e900f Merge pull request #3425 from scottohara/remove-array-model-name
Remove fallback to name for array model title (Fixes #3424)
2017-07-21 19:35:26 -07:00
shockey 49a0cd5488 Merge branch 'master' into remove-array-model-name 2017-07-21 19:31:52 -07:00
shockey 89306801ef Merge pull request #3345 from owenconti/bug/3100-sub-objects-as-required
Fixes #3100 - Required sub objects
2017-07-21 19:25:38 -07:00
shockey 2caa915fb5 Merge branch 'master' into bug/3100-sub-objects-as-required 2017-07-21 19:21:58 -07:00
shockey df43e961f9 Merge branch 'master' into remove-array-model-name 2017-07-21 19:18:13 -07:00
shockey 0c28a50f53 Merge pull request #3411 from owenconti/bug/3405-default-scheme-change
Fixes #3405 - Fixed selecting default scheme in schemes.jsx
2017-07-21 19:17:16 -07:00
Owen Conti defc45f7a6 Fixes #3435 - Update image/ response types to create a proper blob url from the content returned. 2017-07-21 20:16:51 -06:00
shockey e64e438948 Merge branch 'master' into bug/3405-default-scheme-change 2017-07-21 19:13:26 -07:00
Owen Conti ca937f4bdd Add name fallback, fix name extraction from props 2017-07-21 20:13:12 -06:00
shockey 94da83d4ba Merge pull request #3420 from AutoScout24/fix-orderedmap-length
Fix length issue in OrderedMaps
2017-07-21 19:12:23 -07:00
shockey 10f12c287e Merge branch 'master' into fix-orderedmap-length 2017-07-21 19:07:36 -07:00
shockey d40351ce54 Merge branch 'master' into remove-array-model-name 2017-07-21 19:04:20 -07:00
shockey 99d368673b Merge pull request #3427 from owenconti/bug/3414-validate-params-reworked
validateParam() fixes
2017-07-21 18:42:13 -07:00
shockey 8704db7d0f Merge branch 'master' into bug/3414-validate-params-reworked 2017-07-21 18:35:02 -07:00
Owen Conti d9c07a6c30 Merge branch 'master' into fix-orderedmap-length 2017-07-21 19:18:37 -06:00
Owen Conti 8bf9037bbc Merge pull request #3440 from owenconti/bug/3434-links-in-response-style
Fixes #3434 - Change link style color
2017-07-21 19:12:56 -06:00
Owen Conti 3f7145b8b1 Merge branch 'master' into bug/3434-links-in-response-style 2017-07-21 19:07:37 -06:00
shockey 2145ab1408 Merge pull request #3438 from swagger-api/ux-ui
Update topbar.jsx
2017-07-21 18:02:31 -07:00
shockey e04b96fde4 Merge branch 'master' into ux-ui 2017-07-21 17:58:08 -07:00
Owen Conti b9bb4c124e Fixes #3434 - Change link style color for .response-col_description__inner links 2017-07-21 18:46:50 -06:00
Owen Conti 9939c01f80 Merge pull request #3439 from owenconti/bug/3422-expand-collapse-arrows-on-models
Fixes #3422 - Expand/collapse arrows fix
2017-07-21 18:30:53 -06:00
Owen Conti eb1f3b1fa6 Fixes #3422 - Fixed regression bug on models.jsx expand/collapse arrows due to bad merge 2017-07-21 17:23:28 -06:00
shockey 0010bf20a6 Update add-plugin.md 2017-07-21 16:04:58 -07:00
shockey c82f85f123 Update topbar.jsx 2017-07-21 16:01:52 -07:00
Owen Conti e60ae7bbbb Merge branch 'master' into bug/3414-validate-params-reworked 2017-07-20 21:40:43 -06:00
Owen Conti 666e22f989 Update parameter <select> elements to render 'invalid' classes. Add '.invalid' CSS for <select> elements. Rework validateParam() function. Added .btn-sm class for "Add item" and "Remove item" buttons in array parameters. Reduce border-width on <select> elements inside parameters. Update tests for utils.validateParam(). 2017-07-20 21:33:57 -06:00
Scott O'Hara c4409c58d8 Remove fallback to name for array model title (Fixes #3424) 2017-07-21 11:42:06 +10:00
shockey 4353e321ad Merge pull request #3423 from swagger-api/dist-index-deep-linking
Enable deep linking in dist/index.html
2017-07-20 17:25:08 -07:00
shockey 1e5304790e Enable deep linking in dist/index.html 2017-07-20 17:20:01 -07:00
shockey 6102718306 Merge pull request #3404 from MugeSo/fix-oauth2-password-flow
Fix oauth2 password flow
2017-07-20 16:56:26 -07:00
shockey 5affa2572d Merge branch 'master' into fix-oauth2-password-flow 2017-07-20 16:46:49 -07:00
Leon Weidauer 25c63b5f76 Fix length issue in OrderedMaps
Previously, a definiton with a 'length' property with numeric value
would result in an OrderedMap of that length.

This is now fixed and covered by tests
2017-07-20 12:01:00 +02:00
shockey 8775c63fb4 Merge pull request #3408 from dalbani/patch-1
Embellish "base URL" caption
2017-07-19 12:22:20 -07:00
shockey 2a8e7b9752 Merge branch 'master' into patch-1 2017-07-19 12:02:12 -07:00
shockey 3d79fcf79f Merge branch 'master' into bug/3405-default-scheme-change 2017-07-18 21:40:34 -07:00
shockey a1c82ebc1b Merge pull request #3412 from shockey/remove-path-translator
Remove path translator
2017-07-18 20:47:25 -07:00
Kyle Shockey 6a48e43ca5 Delete path translator tests 2017-07-18 20:42:46 -07:00
Kyle Shockey 2ef7b2ad8d Remove path translator 2017-07-18 20:32:09 -07:00
Owen Conti c10702d24e Merge branch 'master' of github.com:swagger-api/swagger-ui into bug/3405-default-scheme-change 2017-07-18 19:59:11 -06:00
Owen Conti 2c35ba2c8f Fixes #3405 - Changed logic for schemes.jsx component to select default scheme when there is no selected scheme. Added test for functionality. 2017-07-18 19:58:02 -06:00
shockey 7b5a327171 Merge pull request #3352 from owenconti/bug/3329-duplicate-css
Fixes #3329 - Fix duplicate CSS in production builds
2017-07-18 11:14:48 -07:00
shockey b1ab6b007b Merge branch 'master' into bug/3329-duplicate-css 2017-07-18 11:11:31 -07:00
Damiano Albani c076a07092 Embellish "base URL" caption 2017-07-18 15:23:44 +02:00
TANAKA Koichi 0bc382b78a Fix oauth2 password flow
fix filed name for scope of grant request body.
2017-07-18 16:52:29 +09:00
shockey 904d3ece8e Merge pull request #3402 from swagger-api/readme-deeplinking-config
Add deepLinking to README
2017-07-17 20:27:34 -07:00
shockey f7e6cadff3 Add deepLinking to README 2017-07-17 20:20:46 -07:00
shockey eecf4fafe9 Merge pull request #3401 from swagger-api/readme-security-contact
Add security contact to README
2017-07-17 20:07:31 -07:00
shockey a8f1f4979a Add security contact to README 2017-07-17 20:03:11 -07:00
Owen Conti b1605a0177 Merge branch 'master' into bug/3329-duplicate-css
# Conflicts:
#	make-webpack-config.js
2017-07-17 18:49:19 -06:00
Owen Conti a18c100d3f Reimplemented fixes after merge with master 2017-07-17 18:46:29 -06:00
Owen Conti 97b8123610 Merge branch 'master' into bug/3100-sub-objects-as-required
# Conflicts:
#	src/core/components/model.jsx
2017-07-17 18:43:58 -06:00
shockey aab1403ba5 Merge pull request #3399 from wmarshall/bug/3398-parseSearch-typo
Fix parseSearch typo
2017-07-17 16:37:40 -07:00
Will Marshall 1d9e71ff3e parseSeach -> parseSearch in index.js 2017-07-17 13:39:06 -07:00
Will Marshall 7363776079 parseSeach -> parseSearch 2017-07-17 13:35:26 -07:00
shockey 9ec121d98b Merge pull request #3389 from shockey/include-apis-preset-by-default
Add Api preset in constructor by default
2017-07-15 09:31:51 -07:00
shockey 0d2c457153 Merge branch 'master' into include-apis-preset-by-default 2017-07-15 09:27:27 -07:00
Kyle Shockey 0dccd48474 Add Api preset in constructor by default 2017-07-14 15:33:49 -07:00
Owen Conti 87bb4420e2 Add main.scss as an entry point for the dev build 2017-07-11 20:30:52 -06:00
Owen Conti 7000c20765 Moved split-pane-mode.less file into a .scss file. Removed remaining unused .less files. Removed reference to less file in webpack config. Removed dependency on less-loader. Updated standalone and bundle builds to no longer compile any styles. 2017-07-11 20:17:06 -06:00
Owen Conti 10aae17c82 Merge branch 'master' of github.com:swagger-api/swagger-ui into bug/3329-duplicate-css 2017-07-10 19:53:53 -06:00
Owen Conti 63b2a9751c Fixes #3329 - Tweak webpack config to share CSS loaders for production builders. Updated production builds to use ExtractTextPlugin so styles are not built into JS. 2017-07-08 08:29:34 -06:00
Owen Conti 4ddb3cd597 Remove unused required prop from ObjectModel 2017-07-06 18:49:47 -06:00
Owen Conti 0862369c56 Fixes #3100 - Style changes for required properties. Pass required prop down to ObjectModel properly. Remove passing of required prop to "type" models. 2017-07-06 06:38:57 -06:00
50 changed files with 628 additions and 650 deletions
+6 -1
View File
@@ -22,7 +22,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
3.0.19 | 2017-07-14 | 2.0 | [tag v3.0.19](https://github.com/swagger-api/swagger-ui/tree/v3.0.19) |
3.0.20 | 2017-07-21 | 2.0 | [tag v3.0.20](https://github.com/swagger-api/swagger-ui/tree/v3.0.20) |
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) |
@@ -146,6 +146,7 @@ displayOperationId | Controls the display of operationId in operations list. The
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
maxDisplayedTags | If set, limits the number of tagged operations displayed to at most this many. The default is to show all operations.
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.
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)
### Plugins
@@ -235,6 +236,10 @@ Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Only headers with these names will be allowed to be sent by Swagger-UI.
## Security contact
Please disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker.
## License
Copyright 2017 SmartBear Software
+1
View File
@@ -76,6 +76,7 @@ window.onload = function() {
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
+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-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AAktEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAkqTA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AA4tnBA;;;;;AAmpQA;;;;;;AA+mXA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AA4uEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAkqTA;;;;;;;;;;;;;;AA+5JA;;;;;;;;;AAmwnBA;;;;;AA+kQA;;;;;;AA+gXA","sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA40CA;;;;;;AAqlFA","sourceRoot":""}
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA40CA;;;;;;AAmlFA","sourceRoot":""}
+1 -4
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":";;;","sourceRoot":""}
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":"","sourceRoot":""}
+2 -2
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;;;;;;AAk/aA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAw8aA","sourceRoot":""}
-1
View File
@@ -61,7 +61,6 @@ module.exports = function(rules, options) {
}
if( specialOptions.minimize ) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
+2 -3
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.19",
"version": "3.0.20",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -71,7 +71,7 @@
"scroll-to-element": "^2.0.0",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "3.0.18",
"swagger-client": "3.0.19",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
@@ -109,7 +109,6 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "2.0.3",
"less": "2.7.2",
"less-loader": "4.0.4",
"license-checker": "^11.0.0",
"mocha": "^3.4.2",
"node-sass": "^4.5.0",
+3 -3
View File
@@ -15,7 +15,7 @@ export default class ArrayModel extends Component {
}
render(){
let { getComponent, required, schema, depth, expandDepth } = this.props
let { getComponent, required, schema, depth, expandDepth, name } = this.props
let items = schema.get("items")
let title = schema.get("title") || name
let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 )
@@ -23,7 +23,7 @@ export default class ArrayModel extends Component {
const ModelCollapse = getComponent("ModelCollapse")
const Model = getComponent("Model")
const titleEl = title &&
const titleEl = title &&
<span className="model-title">
<span className="model-title__text">{ title }</span>
</span>
@@ -44,4 +44,4 @@ export default class ArrayModel extends Component {
{ required && <span style={{ color: "red" }}>*</span>}
</span>
}
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ class Path extends React.Component {
return (
<pre className="base-url">
[ Base url: {host}{basePath}]
[ Base URL: {host}{basePath} ]
</pre>
)
}
+4 -3
View File
@@ -129,7 +129,8 @@ export class Select extends React.Component {
value: PropTypes.any,
onChange: PropTypes.func,
multiple: PropTypes.bool,
allowEmptyValue: PropTypes.bool
allowEmptyValue: PropTypes.bool,
className: PropTypes.string
}
static defaultProps = {
@@ -142,7 +143,7 @@ export class Select extends React.Component {
let value
if (props.value !== undefined) {
if (props.value) {
value = props.value
} else {
value = props.multiple ? [""] : ""
@@ -178,7 +179,7 @@ export class Select extends React.Component {
let value = this.state.value.toJS ? this.state.value.toJS() : this.state.value
return (
<select multiple={ multiple } value={ value } onChange={ this.onChange } >
<select className={this.props.className} multiple={ multiple } value={ value } onChange={ this.onChange } >
{ allowEmptyValue ? <option value="">--</option> : null }
{
allowedValues.map(function (item, key) {
+1 -1
View File
@@ -48,7 +48,7 @@ export default class Model extends Component {
switch(type) {
case "object":
return <ObjectModel className="object" { ...this.props } schema={ modelSchema }
name={ name || modelName }
name={ name || modelName } required={ required }
isRef={ isRef!== undefined ? isRef : !!$$ref }/>
case "array":
return <ArrayModel className="array" { ...this.props } schema={ modelSchema } required={ required } />
+2 -2
View File
@@ -24,8 +24,8 @@ export default class Models extends Component {
return <section className={ showModels ? "models is-open" : "models"}>
<h4 onClick={() => layoutActions.show("models", !showModels)}>
<span>Models</span>
<svg width="20" height="20">
<use xlinkHref="#large-arrow" />
<svg className="arrow" width="20" height="20">
<use xlinkHref={showModels ? "#large-arrow-down" : "#large-arrow"} />
</svg>
</h4>
<Collapse isOpened={showModels}>
+5 -3
View File
@@ -23,7 +23,7 @@ export default class ObjectModel extends Component {
let properties = schema.get("properties")
let additionalProperties = schema.get("additionalProperties")
let title = schema.get("title") || name
let required = schema.get("required")
let requiredProperties = schema.get("required")
const JumpToPath = getComponent("JumpToPath", true)
const Markdown = getComponent("Markdown")
@@ -63,14 +63,16 @@ export default class ObjectModel extends Component {
{
!(properties && properties.size) ? null : properties.entrySeq().map(
([key, value]) => {
let isRequired = List.isList(required) && required.contains(key)
let isRequired = List.isList(requiredProperties) && requiredProperties.contains(key)
let propertyStyle = { verticalAlign: "top", paddingRight: "0.2em" }
if ( isRequired ) {
propertyStyle.fontWeight = "bold"
}
return (<tr key={key}>
<td style={ propertyStyle }>{ key }:</td>
<td style={ propertyStyle }>
{ key }{ isRequired && <span style={{ color: "red" }}>*</span> }
</td>
<td style={{ verticalAlign: "top" }}>
<Model key={ `object-${name}-${key}_${value}` } { ...props }
required={ isRequired }
+1 -1
View File
@@ -40,7 +40,7 @@ export default class ResponseBody extends React.Component {
// Image
} else if (/^image\//i.test(contentType)) {
bodyEl = <img src={ url } />
bodyEl = <img style={{ maxWidth: "100%" }} src={ window.URL.createObjectURL(content) } />
// Audio
} else if (/^audio\//i.test(contentType)) {
+3 -2
View File
@@ -19,8 +19,9 @@ export default class Schemes extends React.Component {
}
componentWillReceiveProps(nextProps) {
if ( this.props.operationScheme && !nextProps.schemes.has(this.props.operationScheme) ) {
//fire 'change' event if our selected scheme is no longer an option
if ( !this.props.operationScheme || !nextProps.schemes.has(this.props.operationScheme) ) {
// if we don't have a selected operationScheme or if our selected scheme is no longer an option,
// then fire 'change' event and select the first scheme in the list of options
this.setScheme(nextProps.schemes.first())
}
}
+3 -2
View File
@@ -4,7 +4,7 @@ import System from "core/system"
import win from "core/window"
import ApisPreset from "core/presets/apis"
import * as AllPlugins from "core/plugins/all"
import { parseSeach, filterConfigs } from "core/utils"
import { parseSearch, filterConfigs } from "core/utils"
const CONFIGS = [
"url",
@@ -67,6 +67,7 @@ module.exports = function SwaggerUI(opts) {
// 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.
presets: [
ApisPreset
],
// Plugins; ( loaded after presets )
@@ -82,7 +83,7 @@ module.exports = function SwaggerUI(opts) {
store: { },
}
let queryConfig = parseSeach()
let queryConfig = parseSearch()
const constructorConfig = deepExtend({}, defaults, opts, queryConfig)
+13 -11
View File
@@ -57,7 +57,8 @@ export class JsonSchema_string extends Component {
if ( enumValue ) {
const Select = getComponent("Select")
return (<Select allowedValues={ enumValue }
return (<Select className={ errors.length ? "invalid" : ""}
allowedValues={ enumValue }
value={ value }
allowEmptyValue={ !required }
onChange={ this.onEnumChange }/>)
@@ -121,6 +122,7 @@ export class JsonSchema_array extends PureComponent {
render() {
let { getComponent, required, schema, fn } = this.props
let errors = schema.errors || []
let itemSchema = fn.inferSchema(schema.items)
const JsonSchemaForm = getComponent("JsonSchemaForm")
@@ -131,19 +133,17 @@ export class JsonSchema_array extends PureComponent {
if ( enumValue ) {
const Select = getComponent("Select")
return (<Select multiple={ true }
return (<Select className={ errors.length ? "invalid" : ""}
multiple={ true }
value={ value }
allowedValues={ enumValue }
allowEmptyValue={ !required }
onChange={ this.onEnumChange }/>)
}
let errors = schema.errors || []
return (
<div>
{ !value || value.count() < 1 ?
(errors.length ? <span style={{ color: "red", fortWeight: "bold" }}>{ errors[0] }</span> : null) :
{ !value || value.count() < 1 ? null :
value.map( (item,i) => {
let schema = Object.assign({}, itemSchema)
if ( errors.length ) {
@@ -153,12 +153,12 @@ export class JsonSchema_array extends PureComponent {
return (
<div key={i} className="json-schema-form-item">
<JsonSchemaForm fn={fn} getComponent={getComponent} value={item} onChange={(val) => this.onItemChange(val, i)} schema={schema} />
<Button className="json-schema-form-item-remove" onClick={()=> this.removeItem(i)} > - </Button>
<Button className="btn btn-sm json-schema-form-item-remove" onClick={()=> this.removeItem(i)} > - </Button>
</div>
)
}).toArray()
}
<Button className="json-schema-form-item-add" onClick={this.addItem}> Add item </Button>
<Button className={`btn btn-sm json-schema-form-item-add ${errors.length ? "invalid" : null}`} onClick={this.addItem}> Add item </Button>
</div>
)
}
@@ -170,12 +170,14 @@ export class JsonSchema_boolean extends Component {
onEnumChange = (val) => this.props.onChange(val)
render() {
let { getComponent, required, value } = this.props
let { getComponent, value, schema } = this.props
let errors = schema.errors || []
const Select = getComponent("Select")
return (<Select value={ String(value) }
return (<Select className={ errors.length ? "invalid" : ""}
value={ String(value) }
allowedValues={ fromJS(["true", "false"]) }
allowEmptyValue={ !required }
allowEmptyValue={true}
onChange={ this.onEnumChange }/>)
}
}
-67
View File
@@ -1,67 +0,0 @@
import get from "lodash/get"
export function transformPathToArray(property, jsSpec) {
if(property.slice(0,9) === "instance.") {
var str = property.slice(9)
} else { // eslint-disable-next-line no-redeclare
var str = property
}
var pathArr = []
str
.split(".")
.map(item => {
// "key[0]" becomes ["key", "0"]
if(item.includes("[")) {
let index = parseInt(item.match(/\[(.*)\]/)[1])
let keyName = item.slice(0, item.indexOf("["))
return [keyName, index.toString()]
} else {
return item
}
})
.reduce(function(a, b) {
// flatten!
return a.concat(b)
}, [])
.concat([""]) // add an empty item into the array, so we don't get stuck with something in our buffer below
.reduce((buffer, curr) => {
let obj = pathArr.length ? get(jsSpec, pathArr) : jsSpec
if(get(obj, makeAccessArray(buffer, curr))) {
if(buffer.length) {
pathArr.push(buffer)
}
if(curr.length) {
pathArr.push(curr)
}
return ""
} else {
// attach key to buffer
return `${buffer}${buffer.length ? "." : ""}${curr}`
}
}, "")
if(typeof get(jsSpec, pathArr) !== "undefined") {
return pathArr
} else {
// if our path is not correct (there is no value at the path),
// return null
return null
}
}
function makeAccessArray(buffer, curr) {
let arr = []
if(buffer.length) {
arr.push(buffer)
}
if(curr.length) {
arr.push(curr)
}
return arr
}
+1 -1
View File
@@ -73,7 +73,7 @@ export const authorizePassword = ( auth ) => ( { authActions } ) => {
let { schema, name, username, password, passwordType, clientId, clientSecret } = auth
let form = {
grant_type: "password",
scopes: encodeURIComponent(auth.scopes.join(scopeSeparator))
scope: encodeURIComponent(auth.scopes.join(scopeSeparator))
}
let query = {}
let headers = {}
@@ -1,7 +1,6 @@
import React from "react"
import PropTypes from "prop-types"
import SplitPane from "react-split-pane"
import "./split-pane-mode.less"
const MODE_KEY = ["split-pane-mode"]
const MODE_LEFT = "left"
@@ -1,5 +0,0 @@
.swagger-ui {
.Resizer.vertical.disabled {
display: none;
}
}
+1 -2
View File
@@ -1,8 +1,7 @@
import { shallowEqualKeys } from "core/utils"
import { transformPathToArray } from "core/path-translator"
export default function() {
return {
fn: { shallowEqualKeys, transformPathToArray }
fn: { shallowEqualKeys }
}
}
+67 -41
View File
@@ -41,7 +41,7 @@ export function fromJSOrdered (js) {
return !isObject(js) ? js :
Array.isArray(js) ?
Im.Seq(js).map(fromJSOrdered).toList() :
Im.Seq(js).map(fromJSOrdered).toOrderedMap()
Im.OrderedMap(js).map(fromJSOrdered)
}
export function bindToState(obj, state) {
@@ -468,6 +468,18 @@ export const validateFile = ( val ) => {
}
}
export const validateBoolean = ( val ) => {
if ( !(val === "true" || val === "false" || val === true || val === false) ) {
return "Value must be a boolean"
}
}
export const validateString = ( val ) => {
if ( val && typeof val !== "string" ) {
return "Value must be a string"
}
}
// validation of parameters before execute
export const validateParam = (param, isXml) => {
let errors = []
@@ -475,52 +487,66 @@ export const validateParam = (param, isXml) => {
let required = param.get("required")
let type = param.get("type")
let stringCheck = type === "string" && !value
let arrayCheck = type === "array" && Array.isArray(value) && !value.length
let listCheck = type === "array" && Im.List.isList(value) && !value.count()
let fileCheck = type === "file" && !(value instanceof win.File)
// If the parameter is required OR the parameter has a value (meaning optional, but filled in)
// then we should do our validation routine
if ( required || value ) {
// These checks should evaluate to true if the parameter's value is valid
let stringCheck = type === "string" && value && !validateString(value)
let arrayCheck = type === "array" && Array.isArray(value) && value.length
let listCheck = type === "array" && Im.List.isList(value) && value.count()
let fileCheck = type === "file" && value instanceof win.File
let booleanCheck = type === "boolean" && !validateBoolean(value)
let numberCheck = type === "number" && !validateNumber(value) // validateNumber returns undefined if the value is a number
let integerCheck = type === "integer" && !validateInteger(value) // validateInteger returns undefined if the value is an integer
if ( required && (stringCheck || arrayCheck || listCheck || fileCheck) ) {
errors.push("Required field is not provided")
return errors
}
if ( required && !(stringCheck || arrayCheck || listCheck || fileCheck || booleanCheck || numberCheck || integerCheck) ) {
errors.push("Required field is not provided")
return errors
}
if ( value === null || value === undefined ) {
return errors
}
if ( type === "string" ) {
let err = validateString(value)
if (!err) return errors
errors.push(err)
} else if ( type === "boolean" ) {
let err = validateBoolean(value)
if (!err) return errors
errors.push(err)
} else if ( type === "number" ) {
let err = validateNumber(value)
if (!err) return errors
errors.push(err)
} else if ( type === "integer" ) {
let err = validateInteger(value)
if (!err) return errors
errors.push(err)
} else if ( type === "array" ) {
let itemType
if ( type === "number" ) {
let err = validateNumber(value)
if (!err) return errors
errors.push(err)
} else if ( type === "integer" ) {
let err = validateInteger(value)
if (!err) return errors
errors.push(err)
} else if ( type === "array" ) {
let itemType
if ( !value.count() ) { return errors }
if ( !value.count() ) { return errors }
itemType = param.getIn(["items", "type"])
itemType = param.getIn(["items", "type"])
value.forEach((item, index) => {
let err
value.forEach((item, index) => {
let err
if (itemType === "number") {
err = validateNumber(item)
} else if (itemType === "integer") {
err = validateInteger(item)
} else if (itemType === "string") {
err = validateString(item)
}
if (itemType === "number") {
err = validateNumber(item)
} else if (itemType === "integer") {
err = validateInteger(item)
}
if ( err ) {
errors.push({ index: index, error: err})
}
})
} else if ( type === "file" ) {
let err = validateFile(value)
if (!err) return errors
errors.push(err)
if ( err ) {
errors.push({ index: index, error: err})
}
})
} else if ( type === "file" ) {
let err = validateFile(value)
if (!err) return errors
errors.push(err)
}
}
return errors
@@ -546,7 +572,7 @@ export const getSampleSchema = (schema, contentType="", config={}) => {
return JSON.stringify(memoizedSampleFromSchema(schema, config), null, 2)
}
export const parseSeach = () => {
export const parseSearch = () => {
let map = {}
let search = window.location.search
+1 -1
View File
@@ -20,7 +20,7 @@ SwaggerUI({
})
```
Or if you're updating the core plugins.. you'll add it to [src/js/bootstrap-plugin](https://github.com/SmartBear/swagger-ux/blob/master/src/js/bootstrap-plugin.js)
Or if you're updating the core plugins.. you'll add it to the base preset: [src/core/presets/base.js](https://github.com/swagger-api/swagger-ui/blob/master/src/core/presets/base.js)
Each Plugin is a function that returns an object. That object will get merged with the `system` and later bound to the state.
Here is an example of each `type`
+1 -1
View File
@@ -130,7 +130,7 @@ export default class Topbar extends React.Component {
<div className="wrapper">
<div className="topbar-wrapper">
<Link href="#" title="Swagger UX">
<img height="30" width="30" src={ Logo } alt="Swagger UX"/>
<img height="30" width="30" src={ Logo } alt="Swagger UI"/>
<span>swagger</span>
</Link>
<form className="download-url-wrapper" onSubmit={formOnSubmit}>
-52
View File
@@ -1,52 +0,0 @@
.swagger-ui {
.topbar {
background-color: #89bf04;
}
.topbar-wrapper {
padding: 0.7em;
}
.topbar-logo__img {
float: left;
}
.topbar-logo__title {
display: inline-block;
color: #fff;
font-size: 1.5em;
font-weight: bold;
margin: 0.15em 0 0 0.5em;
}
.download-url-wrapper {
text-align: right;
float: right;
}
.topbar .download-url__text {
width: 28em;
height: 2em;
margin-right: 0.5em;
}
.download-url__btn {
background-color: #547f00;
border-color: #547f00;
text-decoration: none;
font-weight: bold;
padding: 0.2em 0.3em;
color: white;
border-radius: 0.1em;
&:hover {
&:extend(.download-url__btn);
}
}
.center-700 {
display: block;
margin: 0 auto;
width: 45em;
}
}
-2
View File
@@ -1,6 +1,4 @@
import StandaloneLayout from "./layout"
import "../style/main.scss"
import TopbarPlugin from "plugins/topbar"
import ConfigsPlugin from "plugins/configs"
+9 -1
View File
@@ -14,6 +14,11 @@
@include text_headline();
&.btn-sm {
font-size: 12px;
padding: 4px 23px;
}
&[disabled]
{
cursor: not-allowed;
@@ -165,6 +170,9 @@
button
{
cursor: pointer;
outline: none;
&.invalid {
@include invalidFormElement();
}
}
+6 -6
View File
@@ -21,6 +21,10 @@ select
background: #f7f7f7;
}
&.invalid {
@include invalidFormElement();
}
}
.opblock-body select
@@ -53,12 +57,8 @@ input[type=file]
border-radius: 4px;
background: #fff;
&.invalid
{
animation: shake .4s 1;
border-color: $_color-delete;
background: lighten($_color-delete, 35%);
&.invalid {
@include invalidFormElement();
}
}
+9
View File
@@ -508,6 +508,15 @@ body
{
margin: 0;
}
a
{
@include text_code(#89bf04);
text-decoration: underline;
&:hover {
color: #81b10c;
}
}
}
}
+6
View File
@@ -166,3 +166,9 @@ $browser-context: 16;
@warn 'Breakpoint mixin supports: tablet, mobile, desktop';
}
}
@mixin invalidFormElement() {
animation: shake .4s 1;
border-color: $_color-delete;
background: lighten($_color-delete, 35%);
}
+3
View File
@@ -0,0 +1,3 @@
.Resizer.vertical.disabled {
display: none;
}
+4
View File
@@ -97,6 +97,10 @@ table
width: 100%;
max-width: 340px;
}
select {
border-width: 1px;
}
}
.parameter__name
+1
View File
@@ -14,4 +14,5 @@
@import 'information';
@import 'authorize';
@import 'errors';
@import 'split-pane-mode';
}
+41
View File
@@ -0,0 +1,41 @@
/* eslint-env mocha */
import React from "react"
import expect, { createSpy } from "expect"
import { shallow } from "enzyme"
import { fromJS } from "immutable"
import Schemes from "components/schemes"
describe("<Schemes/>", function(){
it("calls props.specActions.setScheme() when no operationScheme is selected", function(){
// Given
let props = {
specActions: {
setScheme: createSpy()
},
schemes: fromJS([
"http",
"https"
]),
operationScheme: undefined,
path: "/test",
method: "get"
}
// When
let wrapper = shallow(<Schemes {...props}/>)
// Then operationScheme should default to first scheme in options list
expect(props.specActions.setScheme).toHaveBeenCalledWith("http", "/test" , "get")
// When the operationScheme is no longer in the list of options
props.schemes = fromJS([
"https"
])
wrapper.setProps(props)
// Then operationScheme should default to first scheme in options list
expect(props.specActions.setScheme).toHaveBeenCalledWith("https", "/test", "get")
})
})
-183
View File
@@ -1,183 +0,0 @@
/* eslint-env mocha */
import expect from "expect"
import { transformPathToArray } from "core/path-translator"
describe("validation plugin - path translator", function(){
describe("string paths", function(){
it("should translate a simple string path to an array", function(){
// Given
let jsSpec = {
one: {
a: "a thing",
b: "another thing",
c: "one more thing"
},
two: 2
}
let path = "instance.one.a"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["one", "a"])
})
it("should translate an ambiguous string path to an array", function(){
// Since JSONSchema uses periods to mark different properties,
// a key with a period in it is ambiguous, because it can mean at least two things.
// In our case, the path can mean:
// ["google", "com", "a"] or ["google.com", "a"]
// Given
let jsSpec = {
"google.com": {
a: "a thing",
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.google.com.a"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a"])
})
it("should translate an doubly ambiguous string path to an array", function(){
// Since JSONSchema uses periods to mark different properties,
// a key with two periods in it (like "www.google.com") is doubly ambiguous,
// because it can mean at least three things.
// Given
let jsSpec = {
"www.google.com": {
a: "a thing",
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.www.google.com.a"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["www.google.com", "a"])
})
it("should return null for an invalid path", function(){
// Given
let jsSpec = {
"google.com": {
a: "a thing",
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.google.net.a"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(null)
})
it("should return inline array indices in their own value", function(){
// "a[1]" => ["a", "1"]
// Given
let jsSpec = {
"google.com": {
a: [
"hello",
"here is the target"
],
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.google.com.a[1]"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1"])
})
it("should return the correct path when the last part is ambiguous", function(){
// Given
let jsSpec = {
"google.com": {
a: [
"hello",
{
"gmail.com": 1234
}
],
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.google.com.a[1].gmail.com"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1", "gmail.com"])
})
it("should return the correct path when the last part is doubly ambiguous", function(){
// Given
let jsSpec = {
"google.com": {
a: [
"hello",
{
"www.gmail.com": 1234
}
],
b: "another thing",
c: "one more thing"
},
"gmail.com": {
d: "more stuff",
e: "even more stuff"
}
}
let path = "instance.google.com.a[1].www.gmail.com"
// Then
expect(transformPathToArray(path, jsSpec)).toEqual(["google.com", "a", "1", "www.gmail.com"])
})
})
})
+319 -54
View File
@@ -1,10 +1,10 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS } from "immutable"
import { mapToList, validateNumber, validateInteger, validateParam, validateFile } from "core/utils"
import { mapToList, validateNumber, validateInteger, validateParam, validateFile, fromJSOrdered } from "core/utils"
import win from "core/window"
describe("utils", function(){
describe("utils", function() {
describe("mapToList", function(){
@@ -176,6 +176,7 @@ describe("utils", function(){
let result = null
it("validates required strings", function() {
// invalid string
param = fromJS({
required: true,
type: "string",
@@ -183,9 +184,39 @@ describe("utils", function(){
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// valid string
param = fromJS({
required: true,
type: "string",
value: "test string"
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates optional strings", function() {
// valid (empty) string
param = fromJS({
required: false,
type: "string",
value: ""
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid string
param = fromJS({
required: false,
type: "string",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates required files", function() {
// invalid file
param = fromJS({
required: true,
type: "file",
@@ -193,9 +224,48 @@ describe("utils", function(){
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// valid file
param = fromJS({
required: true,
type: "file",
value: new win.File()
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates optional files", function() {
// invalid file
param = fromJS({
required: false,
type: "file",
value: "not a file"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be a file"] )
// valid (empty) file
param = fromJS({
required: false,
type: "file",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid file
param = fromJS({
required: false,
type: "file",
value: new win.File()
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates required arrays", function() {
// invalid (empty) array
param = fromJS({
required: true,
type: "array",
@@ -204,75 +274,51 @@ describe("utils", function(){
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// invalid (not an array)
param = fromJS({
required: true,
type: "array",
value: []
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
})
it("validates numbers", function() {
// string instead of a number
// invalid array, items do not match correct type
param = fromJS({
required: false,
type: "number",
value: "test"
required: true,
type: "array",
value: [1],
items: {
type: "string"
}
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be a number"] )
expect( result ).toEqual( [{index: 0, error: "Value must be a string"}] )
// undefined value
// valid array, with no 'type' for items
param = fromJS({
required: false,
type: "number",
value: undefined
required: true,
type: "array",
value: ["1"]
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// null value
// valid array, items match type
param = fromJS({
required: false,
type: "number",
value: null
required: true,
type: "array",
value: ["1"],
items: {
type: "string"
}
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates integers", function() {
// string instead of integer
param = fromJS({
required: false,
type: "integer",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be an integer"] )
// undefined value
param = fromJS({
required: false,
type: "integer",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// null value
param = fromJS({
required: false,
type: "integer",
value: null
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates arrays", function() {
// empty array
it("validates optional arrays", function() {
// valid, empty array
param = fromJS({
required: false,
type: "array",
@@ -281,7 +327,7 @@ describe("utils", function(){
result = validateParam( param, false )
expect( result ).toEqual( [] )
// numbers
// invalid, items do not match correct type
param = fromJS({
required: false,
type: "array",
@@ -293,17 +339,236 @@ describe("utils", function(){
result = validateParam( param, false )
expect( result ).toEqual( [{index: 0, error: "Value must be a number"}] )
// integers
// valid
param = fromJS({
required: false,
type: "array",
value: ["not", "numbers"],
value: ["test"],
items: {
type: "integer"
type: "string"
}
})
result = validateParam( param, false )
expect( result ).toEqual( [{index: 0, error: "Value must be an integer"}, {index: 1, error: "Value must be an integer"}] )
expect( result ).toEqual( [] )
})
it("validates required booleans", function() {
// invalid boolean value
param = fromJS({
required: true,
type: "boolean",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// invalid boolean value (not a boolean)
param = fromJS({
required: true,
type: "boolean",
value: "test string"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// valid boolean value
param = fromJS({
required: true,
type: "boolean",
value: "true"
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid boolean value
param = fromJS({
required: true,
type: "boolean",
value: false
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates optional booleans", function() {
// valid (empty) boolean value
param = fromJS({
required: false,
type: "boolean",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// invalid boolean value (not a boolean)
param = fromJS({
required: false,
type: "boolean",
value: "test string"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be a boolean"] )
// valid boolean value
param = fromJS({
required: false,
type: "boolean",
value: "true"
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid boolean value
param = fromJS({
required: false,
type: "boolean",
value: false
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates required numbers", function() {
// invalid number, string instead of a number
param = fromJS({
required: true,
type: "number",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// invalid number, undefined value
param = fromJS({
required: true,
type: "number",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// valid number
param = fromJS({
required: true,
type: "number",
value: 10
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates optional numbers", function() {
// invalid number, string instead of a number
param = fromJS({
required: false,
type: "number",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be a number"] )
// valid (empty) number
param = fromJS({
required: false,
type: "number",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid number
param = fromJS({
required: false,
type: "number",
value: 10
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates required integers", function() {
// invalid integer, string instead of an integer
param = fromJS({
required: true,
type: "integer",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// invalid integer, undefined value
param = fromJS({
required: true,
type: "integer",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
// valid integer
param = fromJS({
required: true,
type: "integer",
value: 10
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
it("validates optional integers", function() {
// invalid integer, string instead of an integer
param = fromJS({
required: false,
type: "integer",
value: "test"
})
result = validateParam( param, false )
expect( result ).toEqual( ["Value must be an integer"] )
// valid (empty) integer
param = fromJS({
required: false,
type: "integer",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
// valid number
param = fromJS({
required: false,
type: "integer",
value: 10
})
result = validateParam( param, false )
expect( result ).toEqual( [] )
})
})
describe("fromJSOrdered", () => {
it("should create an OrderedMap from an object", () => {
const param = {
value: "test"
}
const result = fromJSOrdered(param).toJS()
expect( result ).toEqual( { value: "test" } )
})
it("should not use an object's length property for Map size", () => {
const param = {
length: 5
}
const result = fromJSOrdered(param).toJS()
expect( result ).toEqual( { length: 5 } )
})
it("should create an OrderedMap from an array", () => {
const param = [1, 1, 2, 3, 5, 8]
const result = fromJSOrdered(param).toJS()
expect( result ).toEqual( [1, 1, 2, 3, 5, 8] )
})
})
})
+12 -44
View File
@@ -1,64 +1,32 @@
var path = require('path')
var rules = [
const path = require("path")
const styleRules = require("./webpack.dist-style.config.js")
let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
inline: true,
name: '[name].js'
name: "[name].js"
}
},
{ loader: 'babel-loader' }
]
},
{ test: /\.(css)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
},
{ test: /\.(scss)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: { sourceMap: true }
},
{ loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true,
sourceMapContents: 'true'
}
}
]
},
{ test: /\.(less)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
},
'less-loader'
{ loader: "babel-loader" }
]
}
]
module.exports = require('./make-webpack-config.js')(rules, {
module.exports = require("./make-webpack-config.js")(rules, {
_special: {
separateStylesheets: false,
separateStylesheets: true,
minimize: true,
sourcemaps: true,
},
entry: {
'swagger-ui-bundle': [
'./src/polyfills',
'./src/core/index.js'
"swagger-ui-bundle": [
"./src/polyfills",
"./src/core/index.js"
]
},
+11 -44
View File
@@ -1,65 +1,32 @@
var path = require('path')
const path = require("path")
const styleRules = require("./webpack.dist-style.config.js")
var rules = [
let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
inline: true,
name: '[name].js'
name: "[name].js"
}
},
{ loader: 'babel-loader' }
]
},
{ test: /\.(css)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
},
{ test: /\.(scss)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: { sourceMap: true }
},
{ loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true,
sourceMapContents: 'true'
}
}
]
},
{ test: /\.(less)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
},
'less-loader'
{ loader: "babel-loader" }
]
}
]
module.exports = require('./make-webpack-config.js')(rules, {
module.exports = require("./make-webpack-config.js")(rules, {
_special: {
separateStylesheets: false,
separateStylesheets: true,
minimize: true,
sourcemaps: true,
},
entry: {
'swagger-ui-standalone-preset': [
'./src/polyfills',
'./src/standalone/index.js'
"swagger-ui-standalone-preset": [
"./src/polyfills",
"./src/standalone/index.js"
]
},
+9 -50
View File
@@ -1,66 +1,25 @@
var path = require('path')
var fs = require('fs')
const path = require("path")
const fs = require("fs")
const nodeModules = fs.readdirSync("node_modules").filter(function(x) { return x !== ".bin" })
var ExtractTextPlugin = require('extract-text-webpack-plugin')
const styleRules = require("./webpack.dist-style.config.js")
var rules = [
let rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
inline: true,
name: '[name].js'
name: "[name].js"
}
},
{ loader: 'babel-loader' }
{ loader: "babel-loader" }
]
},
{ test: /\.(css)(\?.*)?$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
'postcss-loader'
]
})
},
{ test: /\.(scss)(\?.*)?$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { minimize: true }
},
{
loader: 'postcss-loader',
options: { sourceMap: true }
},
{ loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true,
sourceMapContents: 'true'
}
}
]
})
},
{ test: /\.(less)(\?.*)?$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader',
{
loader: 'postcss-loader',
},
'less-loader'
]
})
}
]
rules = rules.concat(styleRules)
module.exports = require('./make-webpack-config.js')(rules, {
module.exports = require("./make-webpack-config.js")(rules, {
_special: {
separateStylesheets: true,
minimize: true,
+24 -33
View File
@@ -1,56 +1,46 @@
var path = require('path')
const path = require("path")
var rules = [
const rules = [
{ test: /\.(worker\.js)(\?.*)?$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
inline: true
}
},
{ loader: 'babel-loader' }
{ loader: "babel-loader" }
]
},
{ test: /\.(jsx)(\?.*)?$/,
use: [
{ loader: 'react-hot-loader' },
{ loader: 'babel-loader' }
{ loader: "react-hot-loader" },
{ loader: "babel-loader" }
]
},
{ test: /\.(css)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
"style-loader",
"css-loader",
"postcss-loader"
]
},
{ test: /\.(scss)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
"style-loader",
"css-loader",
{
loader: 'postcss-loader',
loader: "postcss-loader",
options: { sourceMap: true }
},
{ loader: 'sass-loader',
{ loader: "sass-loader",
options: {
outputStyle: 'expanded',
outputStyle: "expanded",
sourceMap: true,
sourceMapContents: 'true'
sourceMapContents: "true"
}
}
]
},
{ test: /\.(less)(\?.*)?$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
},
'less-loader'
]
}
]
@@ -60,25 +50,26 @@ module.exports = require("./make-webpack-config")(rules, {
},
devtool: "eval",
entry: {
'swagger-ui-bundle': [
'./src/polyfills',
'./src/core/index.js'
"swagger-ui-bundle": [
"./src/polyfills",
"./src/core/index.js"
],
'swagger-ui-standalone-preset': [
'./src/polyfills',
'./src/standalone/index.js',
"swagger-ui-standalone-preset": [
"./src/style/main.scss",
"./src/polyfills",
"./src/standalone/index.js",
]
},
output: {
pathinfo: true,
filename: '[name].js',
filename: "[name].js",
library: "[name]",
libraryTarget: "umd",
chunkFilename: "[id].js"
},
devServer: {
port: 3200,
contentBase: path.join(__dirname, 'dev-helpers'),
contentBase: path.join(__dirname, "dev-helpers"),
publicPath: "/",
noInfo: true,
hot: true,
+1 -1
View File
@@ -1,3 +1,3 @@
var config = require("./webpack-dist.config.js")
const config = require("./webpack-dist.config.js")
module.exports = config
+4 -5
View File
@@ -1,8 +1,7 @@
const webpack = require('webpack')
const path = require('path')
const deepMerge = require('deepmerge')
const webpackConfig = require('./webpack-dist-bundle.config.js')
const DEPS_CHECK_DIR = require('./package.json').config.deps_check_dir
const path = require("path")
const deepMerge = require("deepmerge")
const webpackConfig = require("./webpack-dist-bundle.config.js")
const DEPS_CHECK_DIR = require("./package.json").config.deps_check_dir
module.exports = deepMerge(
webpackConfig, {
+1 -1
View File
@@ -1,3 +1,3 @@
module.exports = require("./make-webpack-config")({
});
})
+34
View File
@@ -0,0 +1,34 @@
const ExtractTextPlugin = require("extract-text-webpack-plugin")
module.exports = [{
test: /\.(css)(\?.*)?$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
"css-loader",
"postcss-loader"
]
})
},
{ test: /\.(scss)(\?.*)?$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: { minimize: true }
},
{
loader: "postcss-loader",
options: { sourceMap: true }
},
{ loader: "sass-loader",
options: {
outputStyle: "expanded",
sourceMap: true,
sourceMapContents: "true"
}
}
]
})
}]