Merge branch 'master' into webpack-migration-2.x
# Conflicts: # dist/swagger-ui-bundle.js # dist/swagger-ui-bundle.js.map # dist/swagger-ui-standalone-preset.js # dist/swagger-ui-standalone-preset.js.map # dist/swagger-ui.js # dist/swagger-ui.js.map # package.json # webpack-dist.config.js # webpack-hot-dev-server.config.js
This commit is contained in:
1
.babelrc
1
.babelrc
@@ -5,6 +5,7 @@
|
||||
"stage-0"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-runtime",
|
||||
[
|
||||
"module-alias",
|
||||
[
|
||||
|
||||
12
README.md
12
README.md
@@ -6,6 +6,8 @@
|
||||
|
||||
**This is the new version of swagger-ui, 3.x. Want to learn more? Check out our [FAQ](http://swagger.io/new-ui-faq/).**
|
||||
|
||||
**👉🏼 Want to score an easy open-source contribution?** Check out our [Good first contribution](https://github.com/swagger-api/swagger-ui/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+contribution%22) label.
|
||||
|
||||
As a brand new version, written from the ground up, there are some known issues and unimplemented features. Check out the [Known Issues](#known-issues) section for more details.
|
||||
|
||||
This repo publishes to two different NPM packages:
|
||||
@@ -20,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.16 | 2017-06-17 | 2.0 | [tag v3.0.16](https://github.com/swagger-api/swagger-ui/tree/v3.0.16) |
|
||||
3.0.17 | 2017-06-23 | 2.0 | [tag v3.0.17](https://github.com/swagger-api/swagger-ui/tree/v3.0.17) |
|
||||
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) |
|
||||
@@ -124,9 +126,13 @@ If you'd like to use the bundle files via npm, check out the [`swagger-ui-dist`
|
||||
|
||||
#### Parameters
|
||||
|
||||
Parameters with dots in their names are single strings used to organize subordinate parameters, and are not indicative of a nested structure.
|
||||
|
||||
Parameter Name | Description
|
||||
--- | ---
|
||||
url | The url pointing to API definition (normally `swagger.json` or `swagger.yaml`).
|
||||
url | The url pointing to API definition (normally `swagger.json` or `swagger.yaml`). Will be ignored if `urls` or `spec` is used.
|
||||
urls | An array of API definition objects (`{url: "<url>", name: "<name>"}`) used by Topbar plugin. When used and Topbar plugin is enabled, the `url` parameter will not be parsed. Names and URLs must be unique among all items in this array, since they're used as identifiers.
|
||||
urls.primaryName | When using `urls`, you can use this subparameter. If the value matches the name of a spec provided in `urls`, that spec will be displayed when Swagger-UI loads, instead of defaulting to the first spec in `urls`.
|
||||
spec | A JSON object describing the OpenAPI Specification. When used, the `url` parameter will not be parsed. This is useful for testing manually-generated specifications without hosting them.
|
||||
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.
|
||||
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
|
||||
@@ -141,7 +147,7 @@ displayOperationId | Controls the display of operationId in operations list. The
|
||||
### Plugins
|
||||
|
||||
#### Topbar plugin
|
||||
Topbar plugin enables top bar with input for spec path and explore button. By default the plugin is enabled, and to disable it you need to remove Topbar plugin from presets in `src/standalone/index.js`:
|
||||
Topbar plugin enables top bar with input for spec path and explore button or a dropdown if `urls` is used. By default the plugin is enabled, and to disable it you need to remove Topbar plugin from presets in `src/standalone/index.js`:
|
||||
|
||||
```
|
||||
let preset = [
|
||||
|
||||
1
dist/index.html
vendored
1
dist/index.html
vendored
@@ -71,6 +71,7 @@
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
|
||||
// Build a system
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "http://petstore.swagger.io/v2/swagger.json",
|
||||
|
||||
16
dist/swagger-ui-bundle.js
vendored
16
dist/swagger-ui-bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-bundle.js.map
vendored
2
dist/swagger-ui-bundle.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAqvKA;;;;;;AAswEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAq/WA;;;;;;;;;;;;;;AAq3JA;;;;;;;;;AA+yqBA;;;;;AAgwNA;;;;;;AA0qeA","sourceRoot":""}
|
||||
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAkwKA;;;;;;AA6pEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAitTA;;;;;;;;;;;;;;AA25JA;;;;;;;;;AAwsoBA;;;;;AAghNA;;;;;;AAqlYA","sourceRoot":""}
|
||||
6
dist/swagger-ui-standalone-preset.js
vendored
6
dist/swagger-ui-standalone-preset.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui-standalone-preset.js.map
vendored
2
dist/swagger-ui-standalone-preset.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AAw6BA;;;;;;AAi+BA","sourceRoot":""}
|
||||
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8zCA;;;;;;AA4+DA","sourceRoot":""}
|
||||
28
dist/swagger-ui.css
vendored
28
dist/swagger-ui.css
vendored
@@ -1169,10 +1169,10 @@
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
max-width: 300px;
|
||||
text-decoration: none;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
font-family: 'Titillium Web', sans-serif;
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1185,6 +1185,7 @@
|
||||
.swagger-ui .topbar .download-url-wrapper {
|
||||
display: flex;
|
||||
flex: 3;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper input[type=text] {
|
||||
@@ -1196,6 +1197,29 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper .select-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper .select-label span {
|
||||
font-size: 16px;
|
||||
flex: 1;
|
||||
padding: 0 10px 0 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper .select-label select {
|
||||
flex: 2;
|
||||
width: 100%;
|
||||
border: 2px solid #547f00;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper .download-url-button {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
|
||||
2
dist/swagger-ui.css.map
vendored
2
dist/swagger-ui.css.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","sourceRoot":""}
|
||||
4
dist/swagger-ui.js
vendored
4
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui.js.map
vendored
2
dist/swagger-ui.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAgoUA","sourceRoot":""}
|
||||
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAy9XA","sourceRoot":""}
|
||||
@@ -128,7 +128,7 @@ module.exports = function(rules, options) {
|
||||
],
|
||||
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
|
||||
alias: {
|
||||
base: "getbase/src/less/base"
|
||||
base: "getbase/src/less/base",
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.17",
|
||||
"main": "dist/swagger-ui.js",
|
||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||
"contributors": [
|
||||
@@ -35,7 +35,6 @@
|
||||
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs test/swagger-ui-dist-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"base64-js": "^1.2.0",
|
||||
"brace": "0.10.0",
|
||||
"deep-extend": "0.4.1",
|
||||
@@ -70,7 +69,7 @@
|
||||
"sanitize-html": "^1.14.1",
|
||||
"serialize-error": "2.1.0",
|
||||
"shallowequal": "1.0.1",
|
||||
"swagger-client": "~3.0.15",
|
||||
"swagger-client": "3.0.16",
|
||||
"url-parse": "^1.1.8",
|
||||
"whatwg-fetch": "2.0.3",
|
||||
"worker-loader": "^0.8.0",
|
||||
@@ -83,6 +82,7 @@
|
||||
"babel-eslint": "^7.1.1",
|
||||
"babel-loader": "^7.1.0",
|
||||
"babel-plugin-module-alias": "^1.6.0",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-preset-es2015": "^6.22.0",
|
||||
"babel-preset-es2015-ie": "^6.6.2",
|
||||
"babel-preset-react": "^6.23.0",
|
||||
@@ -133,7 +133,7 @@
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"IE 10"
|
||||
"IE 11"
|
||||
],
|
||||
"optionalDependencies": {
|
||||
"webpack-dev-server": "2.5.0"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import shallowCompare from "react-addons-shallow-compare"
|
||||
import React, { PureComponent, PropTypes } from "react"
|
||||
import { getList } from "core/utils"
|
||||
import * as CustomPropTypes from "core/proptypes"
|
||||
|
||||
//import "less/opblock"
|
||||
|
||||
export default class Operation extends React.Component {
|
||||
export default class Operation extends PureComponent {
|
||||
static propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
method: PropTypes.string.isRequired,
|
||||
@@ -70,10 +69,6 @@ export default class Operation extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate(props, state) {
|
||||
return shallowCompare(this, props, state)
|
||||
}
|
||||
|
||||
toggleShown =() => {
|
||||
let { layoutActions, isShownKey } = this.props
|
||||
layoutActions.show(isShownKey, !this.isShown())
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import shallowCompare from "react-addons-shallow-compare"
|
||||
import React, { PureComponent, PropTypes } from "react"
|
||||
import { fromJS, List } from "immutable"
|
||||
import { getSampleSchema } from "core/utils"
|
||||
|
||||
const NOOP = Function.prototype
|
||||
|
||||
export default class ParamBody extends Component {
|
||||
export default class ParamBody extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
param: PropTypes.object,
|
||||
@@ -41,10 +40,6 @@ export default class ParamBody extends Component {
|
||||
this.updateValues.call(this, this.props)
|
||||
}
|
||||
|
||||
shouldComponentUpdate(props, state) {
|
||||
return shallowCompare(this, props, state)
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.updateValues.call(this, nextProps)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,12 @@ const sanitizeOptions = {
|
||||
|
||||
function Markdown({ source }) {
|
||||
const sanitized = sanitize(source, sanitizeOptions)
|
||||
|
||||
// sometimes the sanitizer returns "undefined" as a string
|
||||
if(!source || !sanitized || sanitized === "undefined") {
|
||||
return null
|
||||
}
|
||||
|
||||
return <Remarkable
|
||||
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
|
||||
source={sanitized}
|
||||
|
||||
@@ -5,14 +5,16 @@ import { getSampleSchema } from "core/utils"
|
||||
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
|
||||
if ( examples && examples.size ) {
|
||||
return examples.entrySeq().map( ([ key, example ]) => {
|
||||
let exampleValue
|
||||
let exampleValue = example
|
||||
if ( example.toJS ) {
|
||||
try {
|
||||
exampleValue = example && example.toJS ? example.toJS() : example
|
||||
exampleValue = JSON.stringify(exampleValue, null, 2)
|
||||
exampleValue = JSON.stringify(example.toJS(), null, 2)
|
||||
}
|
||||
catch(e) {
|
||||
exampleValue = String(example)
|
||||
}
|
||||
}
|
||||
|
||||
return (<div key={ key }>
|
||||
<h5>{ key }</h5>
|
||||
<HighlightCode className="example" value={ exampleValue } />
|
||||
|
||||
@@ -6,7 +6,7 @@ import ApisPreset from "core/presets/apis"
|
||||
import * as AllPlugins from "core/plugins/all"
|
||||
import { parseSeach, filterConfigs } from "core/utils"
|
||||
|
||||
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||
const CONFIGS = [ "url", "urls", "urls.primaryName", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
|
||||
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ]
|
||||
|
||||
@@ -23,6 +23,7 @@ module.exports = function SwaggerUI(opts) {
|
||||
dom_id: null,
|
||||
spec: {},
|
||||
url: "",
|
||||
urls: null,
|
||||
layout: "BaseLayout",
|
||||
docExpansion: "list",
|
||||
validatorUrl: "https://online.swagger.io/validator",
|
||||
@@ -117,6 +118,7 @@ module.exports = function SwaggerUI(opts) {
|
||||
return downloadSpec()
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
|
||||
// Add presets
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { PropTypes, Component } from "react"
|
||||
import shallowCompare from "react-addons-shallow-compare"
|
||||
import React, { PropTypes, PureComponent, Component } from "react"
|
||||
import { List, fromJS } from "immutable"
|
||||
//import "less/json-schema-form"
|
||||
|
||||
@@ -74,7 +73,7 @@ export class JsonSchema_string extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export class JsonSchema_array extends Component {
|
||||
export class JsonSchema_array extends PureComponent {
|
||||
|
||||
static propTypes = JsonSchemaPropShape
|
||||
static defaultProps = JsonSchemaDefaultProps
|
||||
@@ -89,10 +88,6 @@ export class JsonSchema_array extends Component {
|
||||
this.setState({value: props.value})
|
||||
}
|
||||
|
||||
shouldComponentUpdate(props, state) {
|
||||
return shallowCompare(this, props, state)
|
||||
}
|
||||
|
||||
onChange = () => this.props.onChange(this.state.value)
|
||||
|
||||
onItemChange = (itemVal, i) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ const primitives = {
|
||||
"number": () => 0,
|
||||
"number_float": () => 0.0,
|
||||
"integer": () => 0,
|
||||
"boolean": () => true
|
||||
"boolean": (schema) => typeof schema.default === "boolean" ? schema.default : true
|
||||
}
|
||||
|
||||
const primitive = (schema) => {
|
||||
@@ -74,6 +74,10 @@ export const sampleFromSchema = (schema, config={}) => {
|
||||
return normalizeArray(schema["enum"])[0]
|
||||
}
|
||||
|
||||
if (type === "file") {
|
||||
return
|
||||
}
|
||||
|
||||
return primitive(schema)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
[UPDATE_PARAM]: ( state, {payload} ) => {
|
||||
let { path, paramName, value, isXml } = payload
|
||||
return state.updateIn( [ "resolved", "paths", ...path, "parameters" ], fromJS([]), parameters => {
|
||||
let index = parameters.findIndex( p => p.get( "name" ) === paramName )
|
||||
const index = parameters.findIndex(p => p.get( "name" ) === paramName )
|
||||
if (!(value instanceof win.File)) {
|
||||
value = fromJSOrdered( value )
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Im from "immutable"
|
||||
import shallowEqual from "shallowequal"
|
||||
|
||||
import camelCase from "lodash/camelCase"
|
||||
import upperFirst from "lodash/upperFirst"
|
||||
import _memoize from "lodash/memoize"
|
||||
import find from "lodash/find"
|
||||
import some from "lodash/some"
|
||||
import eq from "lodash/eq"
|
||||
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
|
||||
@@ -418,11 +418,6 @@ export function pascalCaseFilename(filename) {
|
||||
return pascalCase(filename.replace(/\.[^./]*$/, ""))
|
||||
}
|
||||
|
||||
// Only compare a set of props
|
||||
export function shallowEqualKeys(a,b, keys) {
|
||||
return !!keys.find(key => !shallowEqual(a[key], b[key]))
|
||||
}
|
||||
|
||||
// Check if ...
|
||||
// - new props
|
||||
// - If immutable, use .is()
|
||||
@@ -593,3 +588,10 @@ export const filterConfigs = (configs, allowed) => {
|
||||
|
||||
return filteredConfigs
|
||||
}
|
||||
|
||||
// Is this really required as a helper? Perhaps. TODO: expose the system of presets.apis in docs, so we know what is supported
|
||||
export const shallowEqualKeys = (a,b, keys) => {
|
||||
return !!find(keys, (key) => {
|
||||
return eq(a[key], b[key])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class Topbar extends React.Component {
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context)
|
||||
this.state = { url: props.specSelectors.url() }
|
||||
this.state = { url: props.specSelectors.url(), selectedIndex: 0 }
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
@@ -19,14 +19,68 @@ export default class Topbar extends React.Component {
|
||||
this.setState({url: value})
|
||||
}
|
||||
|
||||
downloadUrl = (e) => {
|
||||
this.props.specActions.updateUrl(this.state.url)
|
||||
this.props.specActions.download(this.state.url)
|
||||
loadSpec = (url) => {
|
||||
this.props.specActions.updateUrl(url)
|
||||
this.props.specActions.download(url)
|
||||
}
|
||||
|
||||
onUrlSelect =(e)=> {
|
||||
let url = e.target.value || e.target.href
|
||||
this.loadSpec(url)
|
||||
this.setSelectedUrl(url)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
downloadUrl = (e) => {
|
||||
this.loadSpec(this.state.url)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
setSelectedUrl = (selectedUrl) => {
|
||||
const configs = this.props.getConfigs()
|
||||
const urls = configs.urls || []
|
||||
|
||||
if(urls && urls.length) {
|
||||
if(selectedUrl)
|
||||
{
|
||||
urls.forEach((spec, i) => {
|
||||
if(spec.url === selectedUrl)
|
||||
{
|
||||
this.setState({selectedIndex: i})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const configs = this.props.getConfigs()
|
||||
const urls = configs.urls || []
|
||||
|
||||
if(urls && urls.length) {
|
||||
let primaryName = configs["urls.primaryName"]
|
||||
if(primaryName)
|
||||
{
|
||||
urls.forEach((spec, i) => {
|
||||
if(spec.name === primaryName)
|
||||
{
|
||||
this.setState({selectedIndex: i})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const urls = this.props.getConfigs().urls || []
|
||||
|
||||
if(urls && urls.length) {
|
||||
this.loadSpec(urls[this.state.selectedIndex].url)
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let { getComponent, specSelectors } = this.props
|
||||
let { getComponent, specSelectors, getConfigs } = this.props
|
||||
const Button = getComponent("Button")
|
||||
const Link = getComponent("Link")
|
||||
|
||||
@@ -36,6 +90,31 @@ export default class Topbar extends React.Component {
|
||||
let inputStyle = {}
|
||||
if(isFailed) inputStyle.color = "red"
|
||||
if(isLoading) inputStyle.color = "#aaa"
|
||||
|
||||
const { urls } = getConfigs()
|
||||
let control = []
|
||||
let formOnSubmit = null
|
||||
|
||||
if(urls) {
|
||||
let rows = []
|
||||
urls.forEach((link, i) => {
|
||||
rows.push(<option key={i} value={link.url}>{link.name}</option>)
|
||||
})
|
||||
|
||||
control.push(
|
||||
<label className="select-label" htmlFor="select"><span>Select a spec</span>
|
||||
<select id="select" disabled={isLoading} onChange={ this.onUrlSelect } value={urls[this.state.selectedIndex].url}>
|
||||
{rows}
|
||||
</select>
|
||||
</label>
|
||||
)
|
||||
}
|
||||
else {
|
||||
formOnSubmit = this.downloadUrl
|
||||
control.push(<input className="download-url-input" type="text" onChange={ this.onUrlChange } value={this.state.url} disabled={isLoading} style={inputStyle} />)
|
||||
control.push(<Button className="download-url-button" onClick={ this.downloadUrl }>Explore</Button>)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="topbar">
|
||||
<div className="wrapper">
|
||||
@@ -44,14 +123,12 @@ export default class Topbar extends React.Component {
|
||||
<img height="30" width="30" src={ Logo } alt="Swagger UX"/>
|
||||
<span>swagger</span>
|
||||
</Link>
|
||||
<form className="download-url-wrapper" onSubmit={this.downloadUrl}>
|
||||
<input className="download-url-input" type="text" onChange={ this.onUrlChange } value={this.state.url} disabled={isLoading} style={inputStyle} />
|
||||
<Button className="download-url-button" onClick={ this.downloadUrl }>Explore</Button>
|
||||
<form className="download-url-wrapper" onSubmit={formOnSubmit}>
|
||||
{control}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -59,5 +136,6 @@ export default class Topbar extends React.Component {
|
||||
Topbar.propTypes = {
|
||||
specSelectors: PropTypes.object.isRequired,
|
||||
specActions: PropTypes.object.isRequired,
|
||||
getComponent: PropTypes.func.isRequired
|
||||
getComponent: PropTypes.func.isRequired,
|
||||
getConfigs: PropTypes.func.isRequired
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
.swagger-ui {
|
||||
|
||||
.topbar {
|
||||
background-color: #89bf04;
|
||||
}
|
||||
|
||||
.topbar-wrapper {
|
||||
padding: 0.7em
|
||||
padding: 0.7em;
|
||||
}
|
||||
|
||||
.topbar-logo__img {
|
||||
|
||||
2
src/polyfills.js
Normal file
2
src/polyfills.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// Promise global, Used ( at least ) by 'whatwg-fetch'. And required by IE 11
|
||||
require("core-js/fn/promise")
|
||||
@@ -6,7 +6,6 @@
|
||||
.topbar-wrapper
|
||||
{
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
a
|
||||
@@ -15,13 +14,13 @@
|
||||
font-weight: bold;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
|
||||
max-width: 300px;
|
||||
|
||||
text-decoration: none;
|
||||
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
@include text_headline(#fff);
|
||||
|
||||
span
|
||||
@@ -34,8 +33,8 @@
|
||||
.download-url-wrapper
|
||||
{
|
||||
display: flex;
|
||||
|
||||
flex: 3;
|
||||
justify-content: flex-end;
|
||||
|
||||
input[type=text]
|
||||
{
|
||||
@@ -48,6 +47,38 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.select-label
|
||||
{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
margin: 0;
|
||||
span
|
||||
{
|
||||
font-size: 16px;
|
||||
|
||||
flex: 1;
|
||||
|
||||
padding: 0 10px 0 0;
|
||||
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
select
|
||||
{
|
||||
flex: 2;
|
||||
|
||||
width: 100%;
|
||||
|
||||
border: 2px solid #547f00;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.download-url-button
|
||||
{
|
||||
font-size: 16px;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
|
||||
* When run outside of NodeJS, will return an error message
|
||||
*/
|
||||
const getAbsoluteFSPath = () => {
|
||||
const getAbsoluteFSPath = function () {
|
||||
// detect whether we are running in a browser or nodejs
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
return require("path").resolve(__dirname)
|
||||
|
||||
37
test/bugs/3279-empty-markdown-source.js
Normal file
37
test/bugs/3279-empty-markdown-source.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/* eslint-env mocha */
|
||||
import React from "react"
|
||||
import expect from "expect"
|
||||
import { render } from "enzyme"
|
||||
import Markdown from "components/providers/markdown"
|
||||
|
||||
describe("UI-3279: Empty Markdown inputs causing bare `undefined` in output", function(){
|
||||
it("should return no text for `null` as source input", function(){
|
||||
let props = {
|
||||
source: null
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
|
||||
it("should return no text for `undefined` as source input", function(){
|
||||
let props = {
|
||||
source: undefined
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
|
||||
it("should return no text for empty string as source input", function(){
|
||||
let props = {
|
||||
source: ""
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
})
|
||||
@@ -57,7 +57,7 @@ module.exports = require('./make-webpack-config.js')(rules, {
|
||||
|
||||
entry: {
|
||||
'swagger-ui-bundle': [
|
||||
'babel-polyfill',
|
||||
'./src/polyfills',
|
||||
'./src/core/index.js'
|
||||
]
|
||||
},
|
||||
|
||||
@@ -58,6 +58,7 @@ module.exports = require('./make-webpack-config.js')(rules, {
|
||||
|
||||
entry: {
|
||||
'swagger-ui-standalone-preset': [
|
||||
'./src/polyfills',
|
||||
'./src/standalone/index.js'
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var node_modules = fs.readdirSync('node_modules').filter(function(x) { return x !== '.bin' })
|
||||
const nodeModules = fs.readdirSync("node_modules").filter(function(x) { return x !== ".bin" })
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
|
||||
var rules = [
|
||||
@@ -66,9 +66,9 @@ module.exports = require('./make-webpack-config.js')(rules, {
|
||||
|
||||
entry: {
|
||||
"swagger-ui": [
|
||||
'babel-polyfill',
|
||||
'./src/style/main.scss',
|
||||
'./src/core/index.js'
|
||||
"./src/style/main.scss",
|
||||
"./src/polyfills",
|
||||
"./src/core/index.js"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -76,11 +76,11 @@ module.exports = require('./make-webpack-config.js')(rules, {
|
||||
// webpack injects some stuff into the resulting file,
|
||||
// these libs need to be pulled in to keep that working.
|
||||
var exceptionsForWebpack = ["ieee754", "base64-js"]
|
||||
if(node_modules.indexOf(request) !== -1 || exceptionsForWebpack.indexOf(request) !== -1) {
|
||||
cb(null, 'commonjs ' + request)
|
||||
return;
|
||||
if(nodeModules.indexOf(request) !== -1 || exceptionsForWebpack.indexOf(request) !== -1) {
|
||||
cb(null, "commonjs " + request)
|
||||
return
|
||||
}
|
||||
cb();
|
||||
cb()
|
||||
},
|
||||
|
||||
output: {
|
||||
|
||||
@@ -61,10 +61,11 @@ module.exports = require("./make-webpack-config")(rules, {
|
||||
devtool: "eval",
|
||||
entry: {
|
||||
'swagger-ui-bundle': [
|
||||
'babel-polyfill',
|
||||
'./src/core/index.js',
|
||||
'./src/polyfills',
|
||||
'./src/core/index.js'
|
||||
],
|
||||
'swagger-ui-standalone-preset': [
|
||||
'./src/polyfills',
|
||||
'./src/standalone/index.js',
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user