Compare commits

...
Author SHA1 Message Date
Kyle Shockey 5576752399 add babel-plugin-transform-react-remove-prop-types 2018-07-10 23:19:07 -05:00
Kyle Shockey 2b4b941814 use remarkable for all Markdown rendering 2018-07-10 23:19:07 -05:00
Kyle Shockey dea6d03969 set HTML content directly, instead of using React-Markdown 2018-07-10 23:19:07 -05:00
Kyle Shockey 8466409235 use js-yaml fork that doesn't require esprima 2018-07-10 23:19:07 -05:00
Kyle Shockey db9dde85e9 preserve GeneratorFunction instead of all function names 2018-07-10 23:19:06 -05:00
Kyle Shockey 4b44505378 set new bundlesize goal 2018-07-10 23:19:06 -05:00
kyle 5b7e422d75 housekeeping: remove Q&A section from feature template (#4708) 2018-07-09 17:06:43 -05:00
kyle 9709df82d3 v3.17.3 (#4706)
* fix: handle formencoded array data correctly

* v3.17.3

* rebuild dist
2018-07-07 02:56:54 -05:00
kyle 4055f51b93 fix: support multimedia media types for file upload (#4705) 2018-07-07 02:36:48 -05:00
kyle 8f65483510 fix: handle urlencoded array data correctly + don't stringify non-object sample values (#4704)
* fix: handle urlencoded array data correctly

* fix: don't stringify non-object sample values

* fix linter
2018-07-07 02:30:40 -05:00
19 changed files with 143 additions and 113 deletions
+3
View File
@@ -7,6 +7,9 @@
"plugins": [
"transform-runtime",
"babel-plugin-transform-es2015-constants",
["transform-react-remove-prop-types", {
"additionalLibraries": ["react-immutable-proptypes"]
}],
[
"module-alias",
[
@@ -4,14 +4,6 @@ about: Suggest an new feature or enhancement for this project
---
### Q&A (please complete the following information)
- OS: [e.g. macOS]
- Browser: [e.g. chrome, safari]
- Version: [e.g. 22]
- Method of installation: [e.g. npm, dist assets]
- Swagger-UI version: [e.g. 3.10.0]
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]
### Content & configuration
Swagger/OpenAPI definition:
+1 -1
View File
@@ -20,7 +20,7 @@ The OpenAPI Specification has undergone 5 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ | ------------ | -------------------------- | -----
3.17.2 | 2018-06-16 | 2.0, 3.0 | [tag v3.17.2](https://github.com/swagger-api/swagger-ui/tree/v3.17.2)
3.17.3 | 2018-06-16 | 2.0, 3.0 | [tag v3.17.3](https://github.com/swagger-api/swagger-ui/tree/v3.17.3)
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10)
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5)
+7 -7
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+8 -3
View File
@@ -71,10 +71,13 @@ module.exports = function(rules, options) {
plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
mangle: specialOptions.mangle,
mangle: specialOptions.mangle ? {
reserved: ["GeneratorFunction"]
} : false,
compress: specialOptions.mangle,
beautify: !specialOptions.mangle,
keep_fnames: true
},
sourceMap: true,
}),
new webpack.LoaderOptionsPlugin({
@@ -142,7 +145,9 @@ module.exports = function(rules, options) {
"node_modules"
],
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
alias: {}
alias: {
"js-yaml": "@kyleshockey/js-yaml"
}
},
devtool: specialOptions.sourcemaps ? "nosource-source-map" : false,
+58 -65
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.17.2",
"version": "3.17.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -9,6 +9,14 @@
"resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-2.1.0.tgz",
"integrity": "sha1-VJqdH5I8m8eVOlhdPpqpQpvo/ig="
},
"@kyleshockey/js-yaml": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@kyleshockey/js-yaml/-/js-yaml-1.0.1.tgz",
"integrity": "sha512-coFyIk1LvTscq1cUU4nCCfYwv+cmG4fCP+wgDKgYZjhM4f++YwZy+g0k+1tUqa4GuUpBTEOGH2KUqKFFWdT73g==",
"requires": {
"argparse": "^1.0.7"
}
},
"@kyleshockey/object-assign-deep": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/@kyleshockey/object-assign-deep/-/object-assign-deep-0.4.2.tgz",
@@ -1523,6 +1531,12 @@
"babel-runtime": "^6.22.0"
}
},
"babel-plugin-transform-react-remove-prop-types": {
"version": "0.4.13",
"resolved": "https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.13.tgz",
"integrity": "sha1-Mxz8BQmagII4MR14MZwnRg1IEYk=",
"dev": true
},
"babel-plugin-transform-regenerator": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz",
@@ -2919,28 +2933,6 @@
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
"dev": true
},
"commonmark": {
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/commonmark/-/commonmark-0.28.1.tgz",
"integrity": "sha1-Buq41SM4uDn6Gi11rwCF7tGxvq4=",
"requires": {
"entities": "~ 1.1.1",
"mdurl": "~ 1.0.1",
"minimist": "~ 1.2.0",
"string.prototype.repeat": "^0.2.0"
}
},
"commonmark-react-renderer": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/commonmark-react-renderer/-/commonmark-react-renderer-4.3.4.tgz",
"integrity": "sha512-+/Rzo3sI37NR8LaVdkUiqBH3+CEW75hc86shwY4E9eEERg78VCy4rSkaP/p7OG5bTvosUMkvhn5d1ZJ5iyt/ag==",
"requires": {
"lodash.assign": "^4.2.0",
"lodash.isplainobject": "^4.0.6",
"pascalcase": "^0.1.1",
"xss-filters": "^1.2.6"
}
},
"compressible": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.13.tgz",
@@ -4220,7 +4212,8 @@
"entities": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
"integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA="
"integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=",
"dev": true
},
"enzyme": {
"version": "2.9.1",
@@ -4543,6 +4536,36 @@
}
}
},
"eslint-plugin-import": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz",
"integrity": "sha512-t6hGKQDMIt9N8R7vLepsYXgDfeuhp6ZJSgtrLEDxonpSubyxUZHjhm6LsAaZX8q6GYVxkbT3kTsV9G5mBCFR6A==",
"dev": true,
"requires": {
"contains-path": "^0.1.0",
"debug": "^2.6.8",
"doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.3.1",
"eslint-module-utils": "^2.2.0",
"has": "^1.0.1",
"lodash": "^4.17.4",
"minimatch": "^3.0.3",
"read-pkg-up": "^2.0.0",
"resolve": "^1.6.0"
},
"dependencies": {
"doctrine": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
"dev": true,
"requires": {
"esutils": "^2.0.2",
"isarray": "^1.0.0"
}
}
}
},
"eslint-plugin-mocha": {
"version": "4.12.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-4.12.1.tgz",
@@ -6764,7 +6787,8 @@
"in-publish": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.0.tgz",
"integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E="
"integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E=",
"dev": true
},
"indent-string": {
"version": "2.1.0",
@@ -8185,7 +8209,8 @@
"lodash.assign": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
"integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc="
"integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=",
"dev": true
},
"lodash.assignin": {
"version": "4.2.0",
@@ -8299,7 +8324,8 @@
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
"integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=",
"dev": true
},
"lodash.keys": {
"version": "3.1.2",
@@ -8563,11 +8589,6 @@
"inherits": "^2.0.1"
}
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -15967,29 +15988,6 @@
"is-dom": "^1.0.9"
}
},
"react-markdown": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-2.5.0.tgz",
"integrity": "sha1-scYZBP7liViGgDvZ332yPD3DqJ4=",
"requires": {
"commonmark": "^0.24.0",
"commonmark-react-renderer": "^4.2.4",
"in-publish": "^2.0.0",
"prop-types": "^15.5.1"
},
"dependencies": {
"commonmark": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/commonmark/-/commonmark-0.24.0.tgz",
"integrity": "sha1-uA3gGCxUY1VkOqFdsSv7KCNoJ48=",
"requires": {
"entities": "~ 1.1.1",
"mdurl": "~ 1.0.1",
"string.prototype.repeat": "^0.2.0"
}
}
}
},
"react-motion": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/react-motion/-/react-motion-0.5.2.tgz",
@@ -16494,6 +16492,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"reselect": {
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-2.5.4.tgz",
"integrity": "sha1-t9I/3wC4P6etAnlUb427vXZccEc="
},
"resolve": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
@@ -17911,11 +17914,6 @@
"function-bind": "^1.0.2"
}
},
"string.prototype.repeat": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-0.2.0.tgz",
"integrity": "sha1-q6Nt4I3O5qWjN9SbLqHaGyj8Ds8="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@@ -19672,11 +19670,6 @@
"integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=",
"dev": true
},
"xss-filters": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/xss-filters/-/xss-filters-1.2.7.tgz",
"integrity": "sha1-Wfod4gHzby80cNysX1jMwoMLCpo="
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+4 -5
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.17.2",
"version": "3.17.3",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -43,9 +43,9 @@
},
"dependencies": {
"@braintree/sanitize-url": "^2.0.2",
"@kyleshockey/js-yaml": "^1.0.1",
"base64-js": "^1.2.0",
"classnames": "^2.2.5",
"commonmark": "^0.28.1",
"core-js": "^2.5.1",
"css.escape": "1.5.1",
"deep-extend": "0.5.1",
@@ -53,7 +53,6 @@
"ieee754": "^1.1.8",
"immutable": "^3.x.x",
"js-file-download": "^0.4.1",
"js-yaml": "^3.5.5",
"lodash": "^4.17.10",
"memoizee": "^0.4.12",
"prop-types": "^15.5.10",
@@ -65,7 +64,6 @@
"react-immutable-proptypes": "2.1.0",
"react-immutable-pure-component": "^1.1.1",
"react-inspector": "^2.3.0",
"react-markdown": "^2.5.0",
"react-motion": "^0.5.2",
"react-redux": "^4.x.x",
"react-split-pane": "^0.1.77",
@@ -88,6 +86,7 @@
"babel-loader": "^7.1.0",
"babel-plugin-module-alias": "^1.6.0",
"babel-plugin-transform-es2015-constants": "^6.1.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2015-ie": "^6.6.2",
@@ -158,7 +157,7 @@
"bundlesize": [
{
"path": "./dist/swagger-ui-bundle.js",
"maxSize": "1.5 MB",
"maxSize": "1 MB",
"compression": "none"
}
]
+7 -3
View File
@@ -111,7 +111,7 @@ export class JsonSchema_array extends PureComponent {
constructor(props, context) {
super(props, context)
this.state = {value: props.value}
this.state = { value: valueOrEmptyList(props.value)}
}
componentWillReceiveProps(props) {
@@ -135,7 +135,7 @@ export class JsonSchema_array extends PureComponent {
addItem = () => {
this.setState(state => {
state.value = state.value || List()
state.value = valueOrEmptyList(state.value)
return {
value: state.value.push("")
}
@@ -174,7 +174,7 @@ export class JsonSchema_array extends PureComponent {
return (
<div>
{ !value || value.count() < 1 ? null :
{ !value || !value.count || value.count() < 1 ? null :
value.map( (item,i) => {
let schema = Object.assign({}, itemSchema)
if ( errors.length ) {
@@ -264,3 +264,7 @@ export class JsonSchema_object extends PureComponent {
}
}
function valueOrEmptyList(value) {
return List.isList(value) ? value : List()
}
+1 -1
View File
@@ -1,4 +1,4 @@
import YAML from "js-yaml"
import YAML from "@kyleshockey/js-yaml"
export const parseYamlConfig = (yaml, system) => {
try {
@@ -10,6 +10,7 @@ const RequestBody = ({
getComponent,
getConfigs,
specSelectors,
fn,
contentType,
isExecute,
specPath,
@@ -35,7 +36,12 @@ const RequestBody = ({
return null
}
if(contentType === "application/octet-stream") {
if(
contentType === "application/octet-stream"
|| contentType.indexOf("image/") === 0
|| contentType.indexOf("audio/") === 0
|| contentType.indexOf("video/") === 0
) {
const Input = getComponent("Input")
if(!isExecute) {
@@ -85,6 +91,7 @@ const RequestBody = ({
<td className="col parameters-col_description">
{isExecute ?
<JsonSchemaForm
fn={fn}
dispatchInitialValue={!isFile}
schema={prop}
getComponent={getComponent}
@@ -132,6 +139,7 @@ RequestBody.propTypes = {
requestBodyValue: ImPropTypes.orderedMap.isRequired,
getComponent: PropTypes.func.isRequired,
getConfigs: PropTypes.func.isRequired,
fn: PropTypes.object.isRequired,
specSelectors: PropTypes.object.isRequired,
contentType: PropTypes.string,
isExecute: PropTypes.bool.isRequired,
@@ -1,25 +1,22 @@
import React from "react"
import PropTypes from "prop-types"
import ReactMarkdown from "react-markdown"
import cx from "classnames"
import { Parser, HtmlRenderer } from "commonmark"
import Remarkable from "remarkable"
import { OAS3ComponentWrapFactory } from "../helpers"
import { sanitizer } from "core/components/providers/markdown"
const parser = new Remarkable("commonmark")
export const Markdown = ({ source, className = "" }) => {
if ( source ) {
const parser = new Parser()
const writer = new HtmlRenderer()
const html = writer.render(parser.parse(source || ""))
const html = parser.render(source)
const sanitized = sanitizer(html)
if ( !source || !html || !sanitized ) {
return null
}
return (
<ReactMarkdown
source={sanitized}
<div
dangerouslySetInnerHTML={{
__html: sanitized
}}
className={cx(className, "renderedMarkdown")}
/>
)
+1 -1
View File
@@ -1,4 +1,4 @@
import YAML from "js-yaml"
import YAML from "@kyleshockey/js-yaml"
import { Map } from "immutable"
import parseUrl from "url-parse"
import serializeError from "serialize-error"
+3 -1
View File
@@ -628,7 +628,9 @@ export const getSampleSchema = (schema, contentType="", config={}) => {
return memoizedCreateXMLExample(schema, config)
}
return JSON.stringify(memoizedSampleFromSchema(schema, config), null, 2)
const res = memoizedSampleFromSchema(schema, config)
return typeof res === "object" ? JSON.stringify(res, null, 2) : res
}
export const parseSearch = () => {
+1
View File
@@ -3,3 +3,4 @@ env:
rules:
"react/prop-types": 1 # bah humbug
"no-unused-vars": 1 # unused vars in tests can be useful for indicating a full signature
"no-global-assign": 1
+27 -1
View File
@@ -24,7 +24,8 @@ import {
getCommonExtensions,
sanitizeUrl,
extractFileNameFromContentDispositionHeader,
deeplyStripKey
deeplyStripKey,
getSampleSchema
} from "core/utils"
import win from "core/window"
@@ -1186,5 +1187,30 @@ describe("utils", function() {
expect(sanitizeUrl({})).toEqual("")
})
})
describe("getSampleSchema", function() {
const oriDate = Date
before(function() {
Date = function () {
this.toISOString = function () {
return "2018-07-07T07:07:05.189Z"
}
}
})
after(function() {
Date = oriDate
})
it("should not unnecessarily stringify non-object values", function() {
// Given
const res = getSampleSchema({
type: "string",
format: "date-time"
})
// Then
expect(res).toEqual(new Date().toISOString())
})
})
})