Merge branch 'master' into master
This commit is contained in:
@@ -165,6 +165,7 @@ deepLinking | If set to `true`, enables dynamic deep linking for tags and operat
|
|||||||
requestInterceptor | MUST be a function. Function to intercept try-it-out requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request.
|
requestInterceptor | MUST be a function. Function to intercept try-it-out requests. Accepts one argument requestInterceptor(request) and must return the potentially modified request.
|
||||||
responseInterceptor | MUST be a function. Function to intercept try-it-out responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response.
|
responseInterceptor | MUST be a function. Function to intercept try-it-out responses. Accepts one argument responseInterceptor(response) and must return the potentially modified response.
|
||||||
showMutatedRequest | If set to `true` (the default), uses the mutated request returned from a rquestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
|
showMutatedRequest | If set to `true` (the default), uses the mutated request returned from a rquestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
|
||||||
|
showExtensions | Controls the display of vendor extension (`x-`) fields and values for Operations, Parameters, and Schema. The default is `false`.
|
||||||
|
|
||||||
### Plugins
|
### Plugins
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export default class ArrayModel extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
required: PropTypes.bool,
|
required: PropTypes.bool,
|
||||||
@@ -15,7 +16,7 @@ export default class ArrayModel extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { getComponent, schema, depth, expandDepth, name } = this.props
|
let { getComponent, getConfigs, schema, depth, expandDepth, name } = this.props
|
||||||
let description = schema.get("description")
|
let description = schema.get("description")
|
||||||
let items = schema.get("items")
|
let items = schema.get("items")
|
||||||
let title = schema.get("title") || name
|
let title = schema.get("title") || name
|
||||||
@@ -46,7 +47,7 @@ export default class ArrayModel extends Component {
|
|||||||
!description ? null :
|
!description ? null :
|
||||||
<Markdown source={ description } />
|
<Markdown source={ description } />
|
||||||
}
|
}
|
||||||
<span><Model { ...this.props } name={null} schema={ items } required={ false } depth={ depth + 1 } /></span>
|
<span><Model { ...this.props } getConfigs={ getConfigs } name={null} schema={ items } required={ false } depth={ depth + 1 } /></span>
|
||||||
]
|
]
|
||||||
</ModelCollapse>
|
</ModelCollapse>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -200,11 +200,11 @@ export default class Oauth2 extends React.Component {
|
|||||||
<Row key={ name }>
|
<Row key={ name }>
|
||||||
<div className="checkbox">
|
<div className="checkbox">
|
||||||
<Input data-value={ name }
|
<Input data-value={ name }
|
||||||
id={`${name}-checkbox-${this.state.name}`}
|
id={`${name}-${flow}-checkbox-${this.state.name}`}
|
||||||
disabled={ isAuthorized }
|
disabled={ isAuthorized }
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
onChange={ this.onScopeChange }/>
|
onChange={ this.onScopeChange }/>
|
||||||
<label htmlFor={`${name}-checkbox-${this.state.name}`}>
|
<label htmlFor={`${name}-${flow}-checkbox-${this.state.name}`}>
|
||||||
<span className="item"></span>
|
<span className="item"></span>
|
||||||
<div className="text">
|
<div className="text">
|
||||||
<p className="name">{name}</p>
|
<p className="name">{name}</p>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export default class ModelExample extends React.Component {
|
|||||||
{
|
{
|
||||||
!isExecute && this.state.activeTab === "model" && <ModelWrapper schema={ schema }
|
!isExecute && this.state.activeTab === "model" && <ModelWrapper schema={ schema }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
specSelectors={ specSelectors }
|
specSelectors={ specSelectors }
|
||||||
expandDepth={ defaultModelExpandDepth } />
|
expandDepth={ defaultModelExpandDepth } />
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,17 @@ export default class ModelComponent extends Component {
|
|||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
expandDepth: PropTypes.number
|
expandDepth: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { getComponent } = this.props
|
let { getComponent, getConfigs } = this.props
|
||||||
const Model = getComponent("Model")
|
const Model = getComponent("Model")
|
||||||
|
|
||||||
return <div className="model-box">
|
return <div className="model-box">
|
||||||
<Model { ...this.props } depth={ 1 } expandDepth={ this.props.expandDepth || 0 }/>
|
<Model { ...this.props } getConfigs={ getConfigs } depth={ 1 } expandDepth={ this.props.expandDepth || 0 }/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default class Model extends PureComponent {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
schema: ImPropTypes.orderedMap.isRequired,
|
schema: ImPropTypes.orderedMap.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
isRef: PropTypes.bool,
|
isRef: PropTypes.bool,
|
||||||
@@ -30,7 +31,7 @@ export default class Model extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let { getComponent, specSelectors, schema, required, name, isRef } = this.props
|
let { getComponent, getConfigs, specSelectors, schema, required, name, isRef } = this.props
|
||||||
const ObjectModel = getComponent("ObjectModel")
|
const ObjectModel = getComponent("ObjectModel")
|
||||||
const ArrayModel = getComponent("ArrayModel")
|
const ArrayModel = getComponent("ArrayModel")
|
||||||
const PrimitiveModel = getComponent("PrimitiveModel")
|
const PrimitiveModel = getComponent("PrimitiveModel")
|
||||||
@@ -54,6 +55,7 @@ export default class Model extends PureComponent {
|
|||||||
case "object":
|
case "object":
|
||||||
return <ObjectModel
|
return <ObjectModel
|
||||||
className="object" { ...this.props }
|
className="object" { ...this.props }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
name={ name }
|
name={ name }
|
||||||
deprecated={deprecated}
|
deprecated={deprecated}
|
||||||
@@ -61,6 +63,7 @@ export default class Model extends PureComponent {
|
|||||||
case "array":
|
case "array":
|
||||||
return <ArrayModel
|
return <ArrayModel
|
||||||
className="array" { ...this.props }
|
className="array" { ...this.props }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
name={ name }
|
name={ name }
|
||||||
deprecated={deprecated}
|
deprecated={deprecated}
|
||||||
@@ -73,6 +76,7 @@ export default class Model extends PureComponent {
|
|||||||
return <PrimitiveModel
|
return <PrimitiveModel
|
||||||
{ ...this.props }
|
{ ...this.props }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
name={ name }
|
name={ name }
|
||||||
deprecated={deprecated}
|
deprecated={deprecated}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export default class Models extends Component {
|
|||||||
expandDepth={ defaultModelExpandDepth }
|
expandDepth={ defaultModelExpandDepth }
|
||||||
schema={ model }
|
schema={ model }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
specSelectors={ specSelectors }/>
|
specSelectors={ specSelectors }/>
|
||||||
</div>
|
</div>
|
||||||
}).toArray()
|
}).toArray()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export default class ObjectModel extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
isRef: PropTypes.bool,
|
isRef: PropTypes.bool,
|
||||||
@@ -17,7 +18,7 @@ export default class ObjectModel extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { schema, name, isRef, getComponent, depth, expandDepth, ...otherProps } = this.props
|
let { schema, name, isRef, getComponent, getConfigs, depth, expandDepth, ...otherProps } = this.props
|
||||||
let { specSelectors } = otherProps
|
let { specSelectors } = otherProps
|
||||||
let { isOAS3 } = specSelectors
|
let { isOAS3 } = specSelectors
|
||||||
|
|
||||||
@@ -91,6 +92,7 @@ export default class ObjectModel extends Component {
|
|||||||
<Model key={ `object-${name}-${key}_${value}` } { ...otherProps }
|
<Model key={ `object-${name}-${key}_${value}` } { ...otherProps }
|
||||||
required={ isRequired }
|
required={ isRequired }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ value }
|
schema={ value }
|
||||||
depth={ depth + 1 } />
|
depth={ depth + 1 } />
|
||||||
</td>
|
</td>
|
||||||
@@ -104,6 +106,7 @@ export default class ObjectModel extends Component {
|
|||||||
<td>
|
<td>
|
||||||
<Model { ...otherProps } required={ false }
|
<Model { ...otherProps } required={ false }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ additionalProperties }
|
schema={ additionalProperties }
|
||||||
depth={ depth + 1 } />
|
depth={ depth + 1 } />
|
||||||
</td>
|
</td>
|
||||||
@@ -117,6 +120,7 @@ export default class ObjectModel extends Component {
|
|||||||
{anyOf.map((schema, k) => {
|
{anyOf.map((schema, k) => {
|
||||||
return <div key={k}><Model { ...otherProps } required={ false }
|
return <div key={k}><Model { ...otherProps } required={ false }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
depth={ depth + 1 } /></div>
|
depth={ depth + 1 } /></div>
|
||||||
})}
|
})}
|
||||||
@@ -131,6 +135,7 @@ export default class ObjectModel extends Component {
|
|||||||
{oneOf.map((schema, k) => {
|
{oneOf.map((schema, k) => {
|
||||||
return <div key={k}><Model { ...otherProps } required={ false }
|
return <div key={k}><Model { ...otherProps } required={ false }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ schema }
|
schema={ schema }
|
||||||
depth={ depth + 1 } /></div>
|
depth={ depth + 1 } /></div>
|
||||||
})}
|
})}
|
||||||
@@ -146,9 +151,10 @@ export default class ObjectModel extends Component {
|
|||||||
<Model { ...otherProps }
|
<Model { ...otherProps }
|
||||||
required={ false }
|
required={ false }
|
||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
schema={ not }
|
schema={ not }
|
||||||
depth={ depth + 1 } />
|
depth={ depth + 1 } />
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/core/components/operation-extension-row.jsx
Normal file
15
src/core/components/operation-extension-row.jsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import React from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
|
export const OperationExtRow = ({ xKey, xVal }) => {
|
||||||
|
return (<tr>
|
||||||
|
<td>{ xKey }</td>
|
||||||
|
<td>{ String(xVal) }</td>
|
||||||
|
</tr>)
|
||||||
|
}
|
||||||
|
OperationExtRow.propTypes = {
|
||||||
|
xKey: PropTypes.string,
|
||||||
|
xVal: PropTypes.any
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OperationExtRow
|
||||||
35
src/core/components/operation-extensions.jsx
Normal file
35
src/core/components/operation-extensions.jsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import React from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
|
export const OperationExt = ({ extensions, getComponent }) => {
|
||||||
|
let OperationExtRow = getComponent("OperationExtRow")
|
||||||
|
return (
|
||||||
|
<div className="opblock-section">
|
||||||
|
<div className="opblock-section-header">
|
||||||
|
<h4>Extensions</h4>
|
||||||
|
</div>
|
||||||
|
<div className="table-container">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td className="col col_header">Field</td>
|
||||||
|
<td className="col col_header">Value</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{
|
||||||
|
extensions.entrySeq().map(([k, v]) => <OperationExtRow key={`${k}-${v}`} xKey={k} xVal={v} />)
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
OperationExt.propTypes = {
|
||||||
|
extensions: PropTypes.object.isRequired,
|
||||||
|
getComponent: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OperationExt
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { PureComponent } from "react"
|
import React, { PureComponent } from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { getList } from "core/utils"
|
import { getList } from "core/utils"
|
||||||
import { sanitizeUrl } from "core/utils"
|
import { getExtensions, sanitizeUrl } from "core/utils"
|
||||||
import { Iterable } from "immutable"
|
import { Iterable } from "immutable"
|
||||||
|
|
||||||
export default class Operation extends PureComponent {
|
export default class Operation extends PureComponent {
|
||||||
@@ -85,6 +85,7 @@ export default class Operation extends PureComponent {
|
|||||||
let parameters = getList(operation, ["parameters"])
|
let parameters = getList(operation, ["parameters"])
|
||||||
let operationScheme = specSelectors.operationScheme(path, method)
|
let operationScheme = specSelectors.operationScheme(path, method)
|
||||||
let isShownKey = ["operations", tag, operationId]
|
let isShownKey = ["operations", tag, operationId]
|
||||||
|
let extensions = getExtensions(operation)
|
||||||
|
|
||||||
const Responses = getComponent("responses")
|
const Responses = getComponent("responses")
|
||||||
const Parameters = getComponent( "parameters" )
|
const Parameters = getComponent( "parameters" )
|
||||||
@@ -95,6 +96,9 @@ export default class Operation extends PureComponent {
|
|||||||
const Collapse = getComponent( "Collapse" )
|
const Collapse = getComponent( "Collapse" )
|
||||||
const Markdown = getComponent( "Markdown" )
|
const Markdown = getComponent( "Markdown" )
|
||||||
const Schemes = getComponent( "schemes" )
|
const Schemes = getComponent( "schemes" )
|
||||||
|
const OperationExt = getComponent( "OperationExt" )
|
||||||
|
|
||||||
|
const { showExtensions } = getConfigs()
|
||||||
|
|
||||||
// Merge in Live Response
|
// Merge in Live Response
|
||||||
if(responses && response && response.size > 0) {
|
if(responses && response && response.size > 0) {
|
||||||
@@ -149,17 +153,18 @@ export default class Operation extends PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
externalDocs && externalDocs.get("url") ?
|
externalDocs && externalDocs.url ?
|
||||||
<div className="opblock-external-docs-wrapper">
|
<div className="opblock-external-docs-wrapper">
|
||||||
<h4 className="opblock-title_normal">Find more details</h4>
|
<h4 className="opblock-title_normal">Find more details</h4>
|
||||||
<div className="opblock-external-docs">
|
<div className="opblock-external-docs">
|
||||||
<span className="opblock-external-docs__description">
|
<span className="opblock-external-docs__description">
|
||||||
<Markdown source={ externalDocs.get("description") } />
|
<Markdown source={ externalDocs.description } />
|
||||||
</span>
|
</span>
|
||||||
<a className="opblock-external-docs__link" href={ sanitizeUrl(externalDocs.get("url")) }>{ externalDocs.get("url") }</a>
|
<a target="_blank" className="opblock-external-docs__link" href={ sanitizeUrl(externalDocs.url) }>{ externalDocs.url }</a>
|
||||||
</div>
|
</div>
|
||||||
</div> : null
|
</div> : null
|
||||||
}
|
}
|
||||||
|
|
||||||
<Parameters
|
<Parameters
|
||||||
parameters={parameters}
|
parameters={parameters}
|
||||||
operation={operation}
|
operation={operation}
|
||||||
@@ -225,6 +230,10 @@ export default class Operation extends PureComponent {
|
|||||||
displayRequestDuration={ displayRequestDuration }
|
displayRequestDuration={ displayRequestDuration }
|
||||||
fn={fn} />
|
fn={fn} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ !showExtensions || !extensions.size ? null :
|
||||||
|
<OperationExt extensions={ extensions } getComponent={ getComponent } />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
12
src/core/components/parameter-extension.jsx
Normal file
12
src/core/components/parameter-extension.jsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
|
export const ParameterExt = ({ xKey, xVal }) => {
|
||||||
|
return <div className="parameter__extension">{ xKey }: { String(xVal) }</div>
|
||||||
|
}
|
||||||
|
ParameterExt.propTypes = {
|
||||||
|
xKey: PropTypes.string,
|
||||||
|
xVal: PropTypes.any
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ParameterExt
|
||||||
@@ -2,6 +2,7 @@ import React, { Component } from "react"
|
|||||||
import { Map } from "immutable"
|
import { Map } from "immutable"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import win from "core/window"
|
import win from "core/window"
|
||||||
|
import { getExtensions } from "core/utils"
|
||||||
|
|
||||||
export default class ParameterRow extends Component {
|
export default class ParameterRow extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -72,6 +73,8 @@ export default class ParameterRow extends Component {
|
|||||||
|
|
||||||
let { isOAS3 } = specSelectors
|
let { isOAS3 } = specSelectors
|
||||||
|
|
||||||
|
const { showExtensions } = getConfigs()
|
||||||
|
|
||||||
// const onChangeWrapper = (value) => onChange(param, value)
|
// const onChangeWrapper = (value) => onChange(param, value)
|
||||||
const JsonSchemaForm = getComponent("JsonSchemaForm")
|
const JsonSchemaForm = getComponent("JsonSchemaForm")
|
||||||
const ParamBody = getComponent("ParamBody")
|
const ParamBody = getComponent("ParamBody")
|
||||||
@@ -91,6 +94,7 @@ export default class ParameterRow extends Component {
|
|||||||
|
|
||||||
const ModelExample = getComponent("modelExample")
|
const ModelExample = getComponent("modelExample")
|
||||||
const Markdown = getComponent("Markdown")
|
const Markdown = getComponent("Markdown")
|
||||||
|
const ParameterExt = getComponent("ParameterExt")
|
||||||
|
|
||||||
let schema = param.get("schema")
|
let schema = param.get("schema")
|
||||||
let type = isOAS3 && isOAS3() ? param.getIn(["schema", "type"]) : param.get("type")
|
let type = isOAS3 && isOAS3() ? param.getIn(["schema", "type"]) : param.get("type")
|
||||||
@@ -100,6 +104,7 @@ export default class ParameterRow extends Component {
|
|||||||
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
|
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
|
||||||
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
|
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
|
||||||
let value = parameter ? parameter.get("value") : ""
|
let value = parameter ? parameter.get("value") : ""
|
||||||
|
let extensions = getExtensions(param)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
@@ -113,6 +118,7 @@ export default class ParameterRow extends Component {
|
|||||||
{ isOAS3 && isOAS3() && param.get("deprecated") ? "deprecated": null }
|
{ isOAS3 && isOAS3() && param.get("deprecated") ? "deprecated": null }
|
||||||
</div>
|
</div>
|
||||||
<div className="parameter__in">({ param.get("in") })</div>
|
<div className="parameter__in">({ param.get("in") })</div>
|
||||||
|
{ !showExtensions || !extensions.size ? null : extensions.map((v, key) => <ParameterExt key={`${key}-${v}`} xKey={key} xVal={v} /> )}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td className="col parameters-col_description">
|
<td className="col parameters-col_description">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { Component } from "react"
|
import React, { Component } from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
import { getExtensions } from "core/utils"
|
||||||
|
|
||||||
const propStyle = { color: "#999", fontStyle: "italic" }
|
const propStyle = { color: "#999", fontStyle: "italic" }
|
||||||
|
|
||||||
@@ -7,12 +8,15 @@ export default class Primitive extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
depth: PropTypes.number
|
depth: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { schema, getComponent, name, depth } = this.props
|
let { schema, getComponent, getConfigs, name, depth } = this.props
|
||||||
|
|
||||||
|
const { showExtensions } = getConfigs()
|
||||||
|
|
||||||
if(!schema || !schema.get) {
|
if(!schema || !schema.get) {
|
||||||
// don't render if schema isn't correctly formed
|
// don't render if schema isn't correctly formed
|
||||||
@@ -25,7 +29,10 @@ export default class Primitive extends Component {
|
|||||||
let enumArray = schema.get("enum")
|
let enumArray = schema.get("enum")
|
||||||
let title = schema.get("title") || name
|
let title = schema.get("title") || name
|
||||||
let description = schema.get("description")
|
let description = schema.get("description")
|
||||||
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
|
let extensions = getExtensions(schema)
|
||||||
|
let properties = schema
|
||||||
|
.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
|
||||||
|
.filterNot( (v, key) => extensions.has(key) )
|
||||||
const Markdown = getComponent("Markdown")
|
const Markdown = getComponent("Markdown")
|
||||||
const EnumModel = getComponent("EnumModel")
|
const EnumModel = getComponent("EnumModel")
|
||||||
const Property = getComponent("Property")
|
const Property = getComponent("Property")
|
||||||
@@ -38,6 +45,9 @@ export default class Primitive extends Component {
|
|||||||
{
|
{
|
||||||
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
|
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
showExtensions && extensions.size ? extensions.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
|
||||||
|
}
|
||||||
{
|
{
|
||||||
!description ? null :
|
!description ? null :
|
||||||
<Markdown source={ description } />
|
<Markdown source={ description } />
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
showMutatedRequest: true,
|
showMutatedRequest: true,
|
||||||
defaultModelRendering: "example",
|
defaultModelRendering: "example",
|
||||||
defaultModelExpandDepth: 1,
|
defaultModelExpandDepth: 1,
|
||||||
|
showExtensions: false,
|
||||||
|
|
||||||
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
// 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.
|
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ class ModelComponent extends Component {
|
|||||||
schema: PropTypes.object.isRequired,
|
schema: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
getConfigs: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
expandDepth: PropTypes.number
|
expandDepth: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { schema } = this.props
|
let { getConfigs, schema } = this.props
|
||||||
let classes = ["model-box"]
|
let classes = ["model-box"]
|
||||||
let isDeprecated = schema.get("deprecated") === true
|
let isDeprecated = schema.get("deprecated") === true
|
||||||
let message = null
|
let message = null
|
||||||
@@ -26,6 +27,7 @@ class ModelComponent extends Component {
|
|||||||
return <div className={classes.join(" ")}>
|
return <div className={classes.join(" ")}>
|
||||||
{message}
|
{message}
|
||||||
<Model { ...this.props }
|
<Model { ...this.props }
|
||||||
|
getConfigs={ getConfigs }
|
||||||
depth={ 1 }
|
depth={ 1 }
|
||||||
expandDepth={ this.props.expandDepth || 0 }
|
expandDepth={ this.props.expandDepth || 0 }
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -30,11 +30,14 @@ import LiveResponse from "core/components/live-response"
|
|||||||
import OnlineValidatorBadge from "core/components/online-validator-badge"
|
import OnlineValidatorBadge from "core/components/online-validator-badge"
|
||||||
import Operations from "core/components/operations"
|
import Operations from "core/components/operations"
|
||||||
import Operation from "core/components/operation"
|
import Operation from "core/components/operation"
|
||||||
|
import OperationExt from "core/components/operation-extensions"
|
||||||
|
import OperationExtRow from "core/components/operation-extension-row"
|
||||||
import HighlightCode from "core/components/highlight-code"
|
import HighlightCode from "core/components/highlight-code"
|
||||||
import Responses from "core/components/responses"
|
import Responses from "core/components/responses"
|
||||||
import Response from "core/components/response"
|
import Response from "core/components/response"
|
||||||
import ResponseBody from "core/components/response-body"
|
import ResponseBody from "core/components/response-body"
|
||||||
import Parameters from "core/components/parameters"
|
import Parameters from "core/components/parameters"
|
||||||
|
import ParameterExt from "core/components/parameter-extension"
|
||||||
import ParameterRow from "core/components/parameter-row"
|
import ParameterRow from "core/components/parameter-row"
|
||||||
import Execute from "core/components/execute"
|
import Execute from "core/components/execute"
|
||||||
import Headers from "core/components/headers"
|
import Headers from "core/components/headers"
|
||||||
@@ -115,6 +118,9 @@ export default function() {
|
|||||||
Markdown,
|
Markdown,
|
||||||
BaseLayout,
|
BaseLayout,
|
||||||
VersionStamp,
|
VersionStamp,
|
||||||
|
OperationExt,
|
||||||
|
OperationExtRow,
|
||||||
|
ParameterExt,
|
||||||
OperationContainer
|
OperationContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -692,3 +692,5 @@ export function getAcceptControllingResponse(responses) {
|
|||||||
|
|
||||||
export const createDeepLinkPath = (str) => typeof str == "string" || str instanceof String ? str.trim().replace(/\s/g, "_") : ""
|
export const createDeepLinkPath = (str) => typeof str == "string" || str instanceof String ? str.trim().replace(/\s/g, "_") : ""
|
||||||
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str) )
|
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str) )
|
||||||
|
|
||||||
|
export const getExtensions = (defObj) => defObj.filter((v, k) => /^x-/.test(k))
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ table
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.parameter__in
|
.parameter__in,
|
||||||
|
.parameter__extension
|
||||||
{
|
{
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ describe("<PrimitiveModel/>", function() {
|
|||||||
}
|
}
|
||||||
const props = {
|
const props = {
|
||||||
getComponent: c => components[c],
|
getComponent: c => components[c],
|
||||||
|
getConfigs: () => ({
|
||||||
|
showExtensions: false
|
||||||
|
}),
|
||||||
name: "Name from props",
|
name: "Name from props",
|
||||||
depth: 1,
|
depth: 1,
|
||||||
schema: fromJS({
|
schema: fromJS({
|
||||||
@@ -46,4 +49,4 @@ describe("<PrimitiveModel/>", function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
} )
|
} )
|
||||||
|
|||||||
Reference in New Issue
Block a user