Merge branch 'master' into feature/apisSorter
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class App extends React.Component {
|
||||
|
||||
@@ -6,7 +7,7 @@ export default class App extends React.Component {
|
||||
let { getComponent, layoutSelectors } = this.props
|
||||
const layoutName = layoutSelectors.current()
|
||||
const Component = getComponent(layoutName, true)
|
||||
return Component ? Component : ()=> <h1> No layout defined for "{layoutName}" </h1>
|
||||
return Component ? Component : ()=> <h1> No layout defined for "{layoutName}" </h1>
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class ApiKeyAuth extends React.Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class AuthorizationPopup extends React.Component {
|
||||
close =() => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class AuthorizeBtn extends React.Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
export default class AuthorizeOperationBtn extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
export default class Auths extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
export default class BasicAuth extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class AuthError extends React.Component {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import oauth2Authorize from "core/oauth2-authorize"
|
||||
|
||||
const IMPLICIT = "implicit"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class Clear extends Component {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import { fromJS } from "immutable"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import curlify from "core/curlify"
|
||||
|
||||
export default class Curl extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import Collapse from "react-collapse"
|
||||
import { presets } from "react-motion"
|
||||
import ObjectInspector from "react-object-inspector"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { List } from "immutable"
|
||||
import Collapse from "react-collapse"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class Execute extends Component {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import Im from "immutable"
|
||||
|
||||
export default class Headers extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { highlight } from "core/utils"
|
||||
|
||||
export default class HighlightCode extends Component {
|
||||
@@ -8,17 +9,21 @@ export default class HighlightCode extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
highlight(this.refs.el)
|
||||
highlight(this.el)
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
highlight(this.refs.el)
|
||||
highlight(this.el)
|
||||
}
|
||||
|
||||
initializeComponent = (c) => {
|
||||
this.el = c
|
||||
}
|
||||
|
||||
render () {
|
||||
let { value, className } = this.props
|
||||
className = className || ""
|
||||
|
||||
return <pre ref="el" className={className + " microlight"}>{ value }</pre>
|
||||
return <pre ref={this.initializeComponent} className={className + " microlight"}>{ value }</pre>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { fromJS } from "immutable"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import OriCollapse from "react-collapse"
|
||||
|
||||
function xclass(...args) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class BaseLayout extends React.Component {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class XPane extends React.Component {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
const Headers = ( { headers } )=>{
|
||||
@@ -8,28 +9,40 @@ const Headers = ( { headers } )=>{
|
||||
<pre>{headers}</pre>
|
||||
</div>)
|
||||
}
|
||||
|
||||
Headers.propTypes = {
|
||||
headers: PropTypes.array.isRequired
|
||||
}
|
||||
|
||||
const Duration = ( { duration } ) => {
|
||||
return (
|
||||
<div>
|
||||
<h5>Request duration</h5>
|
||||
<pre>{duration} ms</pre>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Duration.propTypes = {
|
||||
duration: PropTypes.number.isRequired
|
||||
}
|
||||
|
||||
|
||||
export default class LiveResponse extends React.Component {
|
||||
static propTypes = {
|
||||
response: PropTypes.object.isRequired,
|
||||
getComponent: PropTypes.func.isRequired
|
||||
getComponent: PropTypes.func.isRequired,
|
||||
displayRequestDuration: PropTypes.bool.isRequired
|
||||
}
|
||||
|
||||
render() {
|
||||
const { request, response, getComponent } = this.props
|
||||
const { request, response, getComponent, displayRequestDuration } = this.props
|
||||
|
||||
const status = response.get("status")
|
||||
const url = response.get("url")
|
||||
const headers = response.get("headers").toJS()
|
||||
const notDocumented = response.get("notDocumented")
|
||||
const isError = response.get("error")
|
||||
|
||||
const body = isError ? response.get("response").get("text") : response.get("text")
|
||||
|
||||
const body = response.get("text")
|
||||
const duration = response.get("duration")
|
||||
const headersKeys = Object.keys(headers)
|
||||
const contentType = headers["content-type"]
|
||||
|
||||
@@ -80,6 +93,9 @@ export default class LiveResponse extends React.Component {
|
||||
{
|
||||
hasHeaders ? <Headers headers={ returnObject }/> : null
|
||||
}
|
||||
{
|
||||
displayRequestDuration && duration ? <Duration duration={ duration } /> : null
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class ModelExample extends React.Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import { List } from "immutable"
|
||||
const braceOpen = "{"
|
||||
@@ -117,12 +118,13 @@ class ObjectModel extends Component {
|
||||
class Primitive extends Component {
|
||||
static propTypes = {
|
||||
schema: PropTypes.object.isRequired,
|
||||
name: PropTypes.string,
|
||||
getComponent: PropTypes.func.isRequired,
|
||||
required: PropTypes.bool
|
||||
}
|
||||
|
||||
render(){
|
||||
let { schema, getComponent, required } = this.props
|
||||
let { schema, getComponent, name, required } = this.props
|
||||
|
||||
if(!schema || !schema.get) {
|
||||
// don't render if schema isn't correctly formed
|
||||
@@ -133,12 +135,18 @@ class Primitive extends Component {
|
||||
let format = schema.get("format")
|
||||
let xml = schema.get("xml")
|
||||
let enumArray = schema.get("enum")
|
||||
let title = schema.get("title") || name
|
||||
let description = schema.get("description")
|
||||
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
|
||||
let style = required ? { fontWeight: "bold" } : {}
|
||||
const Markdown = getComponent("Markdown")
|
||||
|
||||
return <span className="prop">
|
||||
return <span className="model">
|
||||
{
|
||||
title && <span className="model-title" style={{ marginRight: "2em" }}>
|
||||
<span className="model-title__text">{ title }</span>
|
||||
</span>
|
||||
}
|
||||
<span className="prop-type" style={ style }>{ type }</span> { required && <span style={{ color: "red" }}>*</span>}
|
||||
{ format && <span className="prop-format">(${format})</span>}
|
||||
{
|
||||
@@ -176,17 +184,20 @@ class ArrayModel extends Component {
|
||||
}
|
||||
|
||||
render(){
|
||||
let { required, schema, depth, expandDepth } = this.props
|
||||
let { required, schema, depth, name, expandDepth } = 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 )
|
||||
|
||||
|
||||
return <span className="model">
|
||||
<span className="model-title">
|
||||
<span className="model-title__text">{ schema.get("title") }</span>
|
||||
</span>
|
||||
{
|
||||
title && <span className="model-title">
|
||||
<span className="model-title__text">{ title }</span>
|
||||
</span>
|
||||
}
|
||||
<Collapse collapsed={ depth > expandDepth } collapsedContent="[...]">
|
||||
[
|
||||
<span><Model { ...this.props } schema={ items } required={ false }/></span>
|
||||
<span><Model { ...this.props } name="" schema={ items } required={ false }/></span>
|
||||
]
|
||||
{
|
||||
properties.size ? <span>
|
||||
@@ -249,13 +260,13 @@ class Model extends Component {
|
||||
name={ name || modelName }
|
||||
isRef={ isRef!== undefined ? isRef : !!$$ref }/>
|
||||
case "array":
|
||||
return <ArrayModel className="array" { ...this.props } schema={ modelSchema } required={ required } />
|
||||
return <ArrayModel className="array" { ...this.props } schema={ modelSchema } name={ name || modelName } required={ required } />
|
||||
case "string":
|
||||
case "number":
|
||||
case "integer":
|
||||
case "boolean":
|
||||
default:
|
||||
return <Primitive getComponent={ getComponent } schema={ modelSchema } required={ required }/>
|
||||
return <Primitive { ...this.props } getComponent={ getComponent } schema={ modelSchema } name={ name || modelName } required={ required }/>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class Models extends Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class OnlineValidatorBadge extends React.Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PureComponent, PropTypes } from "react"
|
||||
import React, { PureComponent } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { getList } from "core/utils"
|
||||
import * as CustomPropTypes from "core/proptypes"
|
||||
|
||||
@@ -17,6 +18,7 @@ export default class Operation extends PureComponent {
|
||||
allowTryItOut: PropTypes.bool,
|
||||
|
||||
displayOperationId: PropTypes.bool,
|
||||
displayRequestDuration: PropTypes.bool,
|
||||
|
||||
response: PropTypes.object,
|
||||
request: PropTypes.object,
|
||||
@@ -37,6 +39,7 @@ export default class Operation extends PureComponent {
|
||||
response: null,
|
||||
allowTryItOut: true,
|
||||
displayOperationId: false,
|
||||
displayRequestDuration: false
|
||||
}
|
||||
|
||||
constructor(props, context) {
|
||||
@@ -107,7 +110,7 @@ export default class Operation extends PureComponent {
|
||||
request,
|
||||
allowTryItOut,
|
||||
displayOperationId,
|
||||
|
||||
displayRequestDuration,
|
||||
fn,
|
||||
getComponent,
|
||||
specActions,
|
||||
@@ -126,6 +129,7 @@ export default class Operation extends PureComponent {
|
||||
let schemes = operation.get("schemes")
|
||||
let parameters = getList(operation, ["parameters"])
|
||||
let operationId = operation.get("__originalOperationId")
|
||||
let operationScheme = specSelectors.operationScheme(path, method)
|
||||
|
||||
const Responses = getComponent("responses")
|
||||
const Parameters = getComponent( "parameters" )
|
||||
@@ -211,7 +215,8 @@ export default class Operation extends PureComponent {
|
||||
<Schemes schemes={ schemes }
|
||||
path={ path }
|
||||
method={ method }
|
||||
specActions={ specActions }/>
|
||||
specActions={ specActions }
|
||||
operationScheme={ operationScheme } />
|
||||
</div> : null
|
||||
}
|
||||
|
||||
@@ -250,6 +255,7 @@ export default class Operation extends PureComponent {
|
||||
produces={ produces }
|
||||
producesValue={ operation.get("produces_value") }
|
||||
pathMethod={ [path, method] }
|
||||
displayRequestDuration={ displayRequestDuration }
|
||||
fn={fn} />
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class Operations extends React.Component {
|
||||
|
||||
@@ -32,7 +33,7 @@ export default class Operations extends React.Component {
|
||||
const Collapse = getComponent("Collapse")
|
||||
|
||||
let showSummary = layoutSelectors.showSummary()
|
||||
let { docExpansion, displayOperationId } = getConfigs()
|
||||
let { docExpansion, displayOperationId, displayRequestDuration } = getConfigs()
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -87,6 +88,7 @@ export default class Operations extends React.Component {
|
||||
allowTryItOut={allowTryItOut}
|
||||
|
||||
displayOperationId={displayOperationId}
|
||||
displayRequestDuration={displayRequestDuration}
|
||||
|
||||
specActions={ specActions }
|
||||
specSelectors={ specSelectors }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { Link } from "core/components/layout-utils"
|
||||
|
||||
export default class Overview extends React.Component {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PureComponent, PropTypes } from "react"
|
||||
import React, { PureComponent } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { fromJS, List } from "immutable"
|
||||
import { getSampleSchema } from "core/utils"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import win from "core/window"
|
||||
|
||||
|
||||
export default class ParameterRow extends Component {
|
||||
static propTypes = {
|
||||
onChange: PropTypes.func.isRequired,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { Component, PropTypes } from "react"
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import Im from "immutable"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import Remarkable from "react-remarkable"
|
||||
import sanitize from "sanitize-html"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { formatXml } from "core/utils"
|
||||
import lowerCase from "lodash/lowerCase"
|
||||
|
||||
@@ -6,7 +7,7 @@ export default class ResponseBody extends React.Component {
|
||||
|
||||
static propTypes = {
|
||||
content: PropTypes.any.isRequired,
|
||||
contentType: PropTypes.string.isRequired,
|
||||
contentType: PropTypes.string,
|
||||
getComponent: PropTypes.func.isRequired,
|
||||
headers: PropTypes.object,
|
||||
url: PropTypes.string
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { fromJS } from "immutable"
|
||||
import { getSampleSchema } from "core/utils"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { fromJS } from "immutable"
|
||||
import { defaultStatusCode } from "core/utils"
|
||||
|
||||
@@ -14,19 +15,21 @@ export default class Responses extends React.Component {
|
||||
specSelectors: PropTypes.object.isRequired,
|
||||
specActions: PropTypes.object.isRequired,
|
||||
pathMethod: PropTypes.array.isRequired,
|
||||
displayRequestDuration: PropTypes.bool.isRequired,
|
||||
fn: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
request: null,
|
||||
tryItOutResponse: null,
|
||||
produces: fromJS(["application/json"])
|
||||
produces: fromJS(["application/json"]),
|
||||
displayRequestDuration: false
|
||||
}
|
||||
|
||||
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue(this.props.pathMethod, val)
|
||||
|
||||
render() {
|
||||
let { responses, request, tryItOutResponse, getComponent, specSelectors, fn, producesValue } = this.props
|
||||
let { responses, request, tryItOutResponse, getComponent, specSelectors, fn, producesValue, displayRequestDuration } = this.props
|
||||
let defaultCode = defaultStatusCode( responses )
|
||||
|
||||
const ContentType = getComponent( "contentType" )
|
||||
@@ -53,7 +56,8 @@ export default class Responses extends React.Component {
|
||||
: <div>
|
||||
<LiveResponse request={ request }
|
||||
response={ tryItOutResponse }
|
||||
getComponent={ getComponent } />
|
||||
getComponent={ getComponent }
|
||||
displayRequestDuration={ displayRequestDuration } />
|
||||
<h4>Responses</h4>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class Schemes extends React.Component {
|
||||
|
||||
@@ -6,7 +7,8 @@ export default class Schemes extends React.Component {
|
||||
specActions: PropTypes.object.isRequired,
|
||||
schemes: PropTypes.object.isRequired,
|
||||
path: PropTypes.string,
|
||||
method: PropTypes.string
|
||||
method: PropTypes.string,
|
||||
operationScheme: PropTypes.string
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
@@ -16,11 +18,18 @@ export default class Schemes extends React.Component {
|
||||
this.setScheme(schemes.first())
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if ( this.props.operationScheme && !nextProps.schemes.has(this.props.operationScheme) ) {
|
||||
//fire 'change' event if our selected scheme is no longer an option
|
||||
this.setScheme(nextProps.schemes.first())
|
||||
}
|
||||
}
|
||||
|
||||
onChange =( e ) => {
|
||||
this.setScheme( e.target.value )
|
||||
}
|
||||
|
||||
setScheme =( value ) => {
|
||||
setScheme = ( value ) => {
|
||||
let { path, method, specActions } = this.props
|
||||
|
||||
specActions.setScheme( value, path, method )
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
export default class TryItOutButton extends React.Component {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { parseSeach, filterConfigs } from "core/utils"
|
||||
|
||||
const CONFIGS = [ "url", "urls", "urls.primaryName", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
|
||||
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
|
||||
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ]
|
||||
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" , "displayRequestDuration"]
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
||||
@@ -30,6 +30,7 @@ module.exports = function SwaggerUI(opts) {
|
||||
configs: {},
|
||||
custom: {},
|
||||
displayOperationId: false,
|
||||
displayRequestDuration: false,
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes, PureComponent, Component } from "react"
|
||||
import React, { PureComponent, Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { List, fromJS } from "immutable"
|
||||
//import "less/json-schema-form"
|
||||
|
||||
|
||||
@@ -92,28 +92,28 @@ export const resolveSpec = (json, url) => ({specActions, specSelectors, errActio
|
||||
let specStr = specSelectors.specStr()
|
||||
|
||||
return resolve({fetch, spec: json, baseDoc: url, modelPropertyMacro, parameterMacro })
|
||||
.then( ({spec, errors}) => {
|
||||
errActions.clear({
|
||||
type: "thrown"
|
||||
})
|
||||
.then( ({spec, errors}) => {
|
||||
errActions.clear({
|
||||
type: "thrown"
|
||||
})
|
||||
|
||||
if(errors.length > 0) {
|
||||
let preparedErrors = errors
|
||||
.map(err => {
|
||||
console.error(err)
|
||||
err.line = err.fullPath ? getLineNumberForPath(specStr, err.fullPath) : null
|
||||
err.path = err.fullPath ? err.fullPath.join(".") : null
|
||||
err.level = "error"
|
||||
err.type = "thrown"
|
||||
err.source = "resolver"
|
||||
Object.defineProperty(err, "message", { enumerable: true, value: err.message })
|
||||
return err
|
||||
})
|
||||
errActions.newThrownErrBatch(preparedErrors)
|
||||
}
|
||||
if(errors.length > 0) {
|
||||
let preparedErrors = errors
|
||||
.map(err => {
|
||||
console.error(err)
|
||||
err.line = err.fullPath ? getLineNumberForPath(specStr, err.fullPath) : null
|
||||
err.path = err.fullPath ? err.fullPath.join(".") : null
|
||||
err.level = "error"
|
||||
err.type = "thrown"
|
||||
err.source = "resolver"
|
||||
Object.defineProperty(err, "message", { enumerable: true, value: err.message })
|
||||
return err
|
||||
})
|
||||
errActions.newThrownErrBatch(preparedErrors)
|
||||
}
|
||||
|
||||
return specActions.updateResolved(spec)
|
||||
})
|
||||
return specActions.updateResolved(spec)
|
||||
})
|
||||
}
|
||||
|
||||
export const formatIntoYaml = () => ({specActions, specSelectors}) => {
|
||||
@@ -207,8 +207,14 @@ export const executeRequest = (req) => ({fn, specActions, specSelectors}) => {
|
||||
|
||||
specActions.setRequest(req.pathName, req.method, parsedRequest)
|
||||
|
||||
// track duration of request
|
||||
const startTime = Date.now()
|
||||
|
||||
return fn.execute(req)
|
||||
.then( res => specActions.setResponse(req.pathName, req.method, res))
|
||||
.then( res => {
|
||||
res.duration = Date.now() - startTime
|
||||
specActions.setResponse(req.pathName, req.method, res)
|
||||
} )
|
||||
.catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) )
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,12 @@ export default {
|
||||
[SET_RESPONSE]: (state, { payload: { res, path, method } } ) =>{
|
||||
let result
|
||||
if ( res.error ) {
|
||||
result = Object.assign({error: true}, res.err)
|
||||
result = Object.assign({
|
||||
error: true,
|
||||
name: res.err.name,
|
||||
message: res.err.message,
|
||||
statusCode: res.err.statusCode
|
||||
}, res.err.response)
|
||||
} else {
|
||||
result = res
|
||||
}
|
||||
@@ -86,7 +91,7 @@ export default {
|
||||
let newState = state.setIn( [ "responses", path, method ], fromJSOrdered(result) )
|
||||
|
||||
// ImmutableJS messes up Blob. Needs to reset its value.
|
||||
if (res.data instanceof win.Blob) {
|
||||
if (win.Blob && res.data instanceof win.Blob) {
|
||||
newState = newState.setIn( [ "responses", path, method, "text" ], res.data)
|
||||
}
|
||||
return newState
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { PropTypes } from "react"
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import SplitPane from "react-split-pane"
|
||||
import "./split-pane-mode.less"
|
||||
|
||||
@@ -23,9 +24,13 @@ export default class SplitPaneMode extends React.Component {
|
||||
children: [],
|
||||
};
|
||||
|
||||
initializeComponent = (c) => {
|
||||
this.splitPane = c
|
||||
}
|
||||
|
||||
onDragFinished = () => {
|
||||
let { threshold, layoutActions } = this.props
|
||||
let { position, draggedSize } = this.refs.splitPane.state
|
||||
let { position, draggedSize } = this.splitPane.state
|
||||
this.draggedSize = draggedSize
|
||||
|
||||
let nearLeftEdge = position <= threshold
|
||||
@@ -62,7 +67,7 @@ export default class SplitPaneMode extends React.Component {
|
||||
return (
|
||||
<SplitPane
|
||||
disabledClass={""}
|
||||
ref={"splitPane"}
|
||||
ref={this.initializeComponent}
|
||||
split='vertical'
|
||||
defaultSize={"50%"}
|
||||
primary="second"
|
||||
|
||||
@@ -65,11 +65,11 @@ export const render = (getSystem, getStore, getComponent, getComponents, dom) =>
|
||||
}
|
||||
|
||||
// Render try/catch wrapper
|
||||
const createClass = component => React.createClass({
|
||||
const createClass = component => class extends Component {
|
||||
render() {
|
||||
return component(this.props)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const Fallback = ({ name }) => <div style={{ // eslint-disable-line react/prop-types
|
||||
padding: "1em",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PropTypes } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
|
||||
// Takes a list and proptype, and returns a PropType.shape({ [item]: propType })
|
||||
const mapListToPropTypeShape = (list, propType) => PropTypes.shape(
|
||||
|
||||
@@ -240,7 +240,7 @@ export default class Store {
|
||||
action = {type: NEW_THROWN_ERR, error: true, payload: serializeError(e) }
|
||||
}
|
||||
finally{
|
||||
return action
|
||||
return action // eslint-disable-line no-unsafe-finally
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ export function highlight (el) {
|
||||
while (![
|
||||
1, // 0: whitespace
|
||||
// 1: operator or braces
|
||||
/[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr),
|
||||
/[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr), // eslint-disable-line no-useless-escape
|
||||
/[\])]/[test](chr), // 2: closing brace
|
||||
/[$\w]/[test](chr), // 3: (key)word
|
||||
chr == "/" && // 4: regex
|
||||
@@ -450,15 +450,15 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => {
|
||||
|| objectList.some( objectPropName => !eq(props[objectPropName], nextProps[objectPropName])))
|
||||
}
|
||||
|
||||
const validateNumber = ( val ) => {
|
||||
if ( !/^-?\d+(.?\d+)?$/.test(val)) {
|
||||
export const validateNumber = ( val ) => {
|
||||
if ( !/^-?\d+(\.?\d+)?$/.test(val)) {
|
||||
return "Value must be a number"
|
||||
}
|
||||
}
|
||||
|
||||
const validateInteger = ( val ) => {
|
||||
export const validateInteger = ( val ) => {
|
||||
if ( !/^-?\d+$/.test(val)) {
|
||||
return "Value must be integer"
|
||||
return "Value must be an integer"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,13 +469,14 @@ export const validateParam = (param, isXml) => {
|
||||
let required = param.get("required")
|
||||
let type = param.get("type")
|
||||
|
||||
if ( required && (!value || (type==="array" && Array.isArray(value) && !value.length ))) {
|
||||
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) ) {
|
||||
errors.push("Required field is not provided")
|
||||
return errors
|
||||
}
|
||||
|
||||
if ( !value ) return errors
|
||||
|
||||
if ( type === "number" ) {
|
||||
let err = validateNumber(value)
|
||||
if (!err) return errors
|
||||
|
||||
Reference in New Issue
Block a user