Przeglądaj źródła

Merge branch 'master' into bug/3102-unguarded-expressions

bubble
shockey 7 lat temu
committed by GitHub
rodzic
commit
025ec662c0
17 zmienionych plików z 92 dodań i 35 usunięć
  1. +2
    -2
      README.md
  2. +8
    -8
      dist/swagger-ui-bundle.js
  3. +1
    -1
      dist/swagger-ui-bundle.js.map
  4. +3
    -3
      dist/swagger-ui-standalone-preset.js
  5. +1
    -1
      dist/swagger-ui.css
  6. +2
    -2
      dist/swagger-ui.js
  7. +1
    -1
      dist/swagger-ui.js.map
  8. +2
    -2
      package.json
  9. +5
    -1
      postcss.config.js
  10. +7
    -3
      src/core/components/param-body.jsx
  11. +1
    -1
      src/core/components/parameter-row.jsx
  12. +6
    -3
      src/core/plugins/spec/selectors.js
  13. +13
    -2
      src/core/utils.js
  14. +2
    -1
      src/style/_form.scss
  15. +1
    -1
      src/style/_layout.scss
  16. +12
    -2
      swagger-ui-dist-package/index.js
  17. +25
    -1
      test/core/utils.js

+ 2
- 2
README.md Wyświetl plik

@@ -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.17 | 2017-06-23 | 2.0 | [tag v3.0.17](https://github.com/swagger-api/swagger-ui/tree/v3.0.17) |
3.0.18 | 2017-07-07 | 2.0 | [tag v3.0.18](https://github.com/swagger-api/swagger-ui/tree/v3.0.18) |
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) |
@@ -143,7 +143,7 @@ parameterMacro | MUST be a function. Function to set default value to parameters
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
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'.
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.
displayRequestDuration | Controls the display of the request duration (in milliseconds) for `Try it out` requests. The default is `false`.

### Plugins



+ 8
- 8
dist/swagger-ui-bundle.js
Plik diff jest za duży
Wyświetl plik


+ 1
- 1
dist/swagger-ui-bundle.js.map Wyświetl plik

@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AAmqEA;;;;;;;;;;;;;;;;;;;;;;;;;;AA6nTA;;;;;;;;;;;;;;AAu8JA;;;;;;;;;AA8/mBA;;;;;AA6/PA;;;;;;AAqpVA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAsyKA;;;;;;AA8qEA;;;;;;;;;;;;;;;;;;;;;;;;;;AA6nTA;;;;;;;;;;;;;;AAu8JA;;;;;;;;;AAkgnBA;;;;;AAigQA;;;;;;AAqpVA","sourceRoot":""}

+ 3
- 3
dist/swagger-ui-standalone-preset.js
Plik diff jest za duży
Wyświetl plik


+ 1
- 1
dist/swagger-ui.css
Plik diff jest za duży
Wyświetl plik


+ 2
- 2
dist/swagger-ui.js
Plik diff jest za duży
Wyświetl plik


+ 1
- 1
dist/swagger-ui.js.map Wyświetl plik

@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAkoaA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAopaA","sourceRoot":""}

+ 2
- 2
package.json Wyświetl plik

@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.0.17",
"version": "3.0.18",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -70,7 +70,7 @@
"sanitize-html": "^1.14.1",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "3.0.16",
"swagger-client": "3.0.17",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",


+ 5
- 1
postcss.config.js Wyświetl plik

@@ -1 +1,5 @@
module.exports = {};
module.exports = {
plugins: [
require("autoprefixer")
]
}

+ 7
- 3
src/core/components/param-body.jsx Wyświetl plik

@@ -49,10 +49,11 @@ export default class ParamBody extends PureComponent {
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {}
let isXml = /xml/i.test(consumesValue)
let isJson = /json/i.test(consumesValue)
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")

if ( paramValue !== undefined ) {
let val = !paramValue && !isXml ? "{}" : paramValue
let val = !paramValue && isJson ? "{}" : paramValue
this.setState({ value: val })
this.onChange(val, {isXml: isXml, isEditBox: isExecute})
} else {
@@ -79,8 +80,11 @@ export default class ParamBody extends PureComponent {
_onChange = (val, isXml) => { (this.props.onChange || NOOP)(this.props.param, val, isXml) }

handleOnChange = e => {
let {consumesValue} = this.props
this.onChange(e.target.value.trim(), {isXml: /xml/i.test(consumesValue)})
const {consumesValue} = this.props
const isJson = /json/i.test(consumesValue)
const isXml = /xml/i.test(consumesValue)
const inputValue = isJson ? e.target.value.trim() : e.target.value
this.onChange(inputValue, {isXml})
}

toggleIsEditBox = () => this.setState( state => ({isEditBox: !state.isEditBox}))


+ 1
- 1
src/core/components/parameter-row.jsx Wyświetl plik

@@ -94,7 +94,7 @@ export default class ParameterRow extends Component {
{ param.get("name") }
{ !required ? null : <span style={{color: "red"}}>&nbsp;*</span> }
</div>
<div className="parаmeter__type">{ param.get("type") } { itemType && `[${itemType}]` }</div>
<div className="parameter__type">{ param.get("type") } { itemType && `[${itemType}]` }</div>
<div className="parameter__in">({ param.get("in") })</div>
</td>



+ 6
- 3
src/core/plugins/spec/selectors.js Wyświetl plik

@@ -1,6 +1,6 @@
import { createSelector } from "reselect"
import { sorters } from "core/utils"
import { fromJS, Set, Map, List } from "immutable"
import { fromJS, Set, Map, OrderedMap, List } from "immutable"

const DEFAULT_TAG = "default"

@@ -187,13 +187,16 @@ export const tagDetails = (state, tag) => {

export const operationsWithTags = createSelector(
operationsWithRootInherited,
operations => {
tags,
(operations, tags) => {
return operations.reduce( (taggedMap, op) => {
let tags = Set(op.getIn(["operation","tags"]))
if(tags.count() < 1)
return taggedMap.update(DEFAULT_TAG, List(), ar => ar.push(op))
return tags.reduce( (res, tag) => res.update(tag, List(), (ar) => ar.push(op)), taggedMap )
}, Map())
}, tags.reduce( (taggedMap, tag) => {
return taggedMap.set(tag.get("name"), List())
} , OrderedMap()))
}
)



+ 13
- 2
src/core/utils.js Wyświetl plik

@@ -462,6 +462,12 @@ export const validateInteger = ( val ) => {
}
}

export const validateFile = ( val ) => {
if ( val && !(val instanceof win.File) ) {
return "Value must be a file"
}
}

// validation of parameters before execute
export const validateParam = (param, isXml) => {
let errors = []
@@ -472,7 +478,9 @@ export const validateParam = (param, isXml) => {
let stringCheck = type === "string" && !value
let arrayCheck = type === "array" && Array.isArray(value) && !value.length
let listCheck = type === "array" && Im.List.isList(value) && !value.count()
if ( required && (stringCheck || arrayCheck || listCheck) ) {
let fileCheck = type === "file" && !(value instanceof win.File)

if ( required && (stringCheck || arrayCheck || listCheck || fileCheck) ) {
errors.push("Required field is not provided")
return errors
}
@@ -505,7 +513,10 @@ export const validateParam = (param, isXml) => {
errors.push({ index: index, error: err})
}
})

} else if ( type === "file" ) {
let err = validateFile(value)
if (!err) return errors
errors.push(err)
}

return errors


+ 2
- 1
src/style/_form.scss Wyświetl plik

@@ -42,7 +42,8 @@ label
input[type=text],
input[type=password],
input[type=search],
input[type=email]
input[type=email],
input[type=file]
{
min-width: 100px;
margin: 5px 0;


+ 1
- 1
src/style/_layout.scss Wyświetl plik

@@ -113,7 +113,7 @@ body
}
}

.parаmeter__type
.parameter__type
{
font-size: 12px;



+ 12
- 2
swagger-ui-dist-package/index.js Wyświetl plik

@@ -1,3 +1,13 @@
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
try {
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
} catch(e) {
// swallow the error if there's a problem loading the assets.
// allows this module to support providing the assets for browserish contexts,
// without exploding in a Node context.
//
// see https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
// for more information.
}

module.exports.absolutePath = require("./absolute-path.js")

+ 25
- 1
test/core/utils.js Wyświetl plik

@@ -1,7 +1,8 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS } from "immutable"
import { mapToList, validateNumber, validateInteger, validateParam } from "core/utils"
import { mapToList, validateNumber, validateInteger, validateParam, validateFile } from "core/utils"
import win from "core/window"

describe("utils", function(){

@@ -157,6 +158,19 @@ describe("utils", function(){
})
})

describe("validateFile", function() {
let errorMessage = "Value must be a file"

it("validates against objects which are instances of 'File'", function() {
let fileObj = new win.File([], "Test File")
expect(validateFile(fileObj)).toBeFalsy()
expect(validateFile(null)).toBeFalsy()
expect(validateFile(undefined)).toBeFalsy()
expect(validateFile(1)).toEqual(errorMessage)
expect(validateFile("string")).toEqual(errorMessage)
})
})

describe("validateParam", function() {
let param = null
let result = null
@@ -171,6 +185,16 @@ describe("utils", function(){
expect( result ).toEqual( ["Required field is not provided"] )
})

it("validates required files", function() {
param = fromJS({
required: true,
type: "file",
value: undefined
})
result = validateParam( param, false )
expect( result ).toEqual( ["Required field is not provided"] )
})

it("validates required arrays", function() {
param = fromJS({
required: true,


Ładowanie…
Anuluj
Zapisz