Merge branch 'master' into feature/request-url
This commit is contained in:
2
.github/issue_template.md
vendored
2
.github/issue_template.md
vendored
@@ -25,7 +25,7 @@ or anything that violates the specifications.
|
|||||||
| Which Swagger/OpenAPI version? |
|
| Which Swagger/OpenAPI version? |
|
||||||
| Which Swagger-UI version? |
|
| Which Swagger-UI version? |
|
||||||
| How did you install Swagger-UI? |
|
| How did you install Swagger-UI? |
|
||||||
| Which broswer & version? |
|
| Which browser & version? |
|
||||||
| Which operating system? |
|
| Which operating system? |
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ The OpenAPI Specification has undergone 5 revisions since initial creation in 20
|
|||||||
|
|
||||||
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
|
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||||
------------------ | ------------ | -------------------------- | -----
|
------------------ | ------------ | -------------------------- | -----
|
||||||
3.1.6 | 2017-08-18 | 2.0, 3.0 | [tag v3.1.6](https://github.com/swagger-api/swagger-ui/tree/v3.1.6)
|
3.2.0 | 2017-09-08 | 2.0, 3.0 | [tag v3.2.0](https://github.com/swagger-api/swagger-ui/tree/v3.2.0)
|
||||||
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
|
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.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.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)
|
||||||
|
|||||||
@@ -11,7 +11,11 @@
|
|||||||
var redirectUrl = oauth2.redirectUrl;
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
var isValid, qp, arr;
|
var isValid, qp, arr;
|
||||||
|
|
||||||
qp = (window.location.hash || location.search).substring(1);
|
if (/code|token|error/.test(window.location.hash)) {
|
||||||
|
qp = window.location.hash.substring(1);
|
||||||
|
} else {
|
||||||
|
qp = location.search.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
arr = qp.split("&")
|
arr = qp.split("&")
|
||||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
||||||
|
|||||||
6
dist/oauth2-redirect.html
vendored
6
dist/oauth2-redirect.html
vendored
@@ -11,7 +11,11 @@
|
|||||||
var redirectUrl = oauth2.redirectUrl;
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
var isValid, qp, arr;
|
var isValid, qp, arr;
|
||||||
|
|
||||||
qp = (window.location.hash || location.search).substring(1);
|
if (/code|token|error/.test(window.location.hash)) {
|
||||||
|
qp = window.location.hash.substring(1);
|
||||||
|
} else {
|
||||||
|
qp = location.search.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
arr = qp.split("&")
|
arr = qp.split("&")
|
||||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
||||||
|
|||||||
22
dist/swagger-ui-bundle.js
vendored
22
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;;;;;AAoyKA;;;;;;AAm/EA;;;;;;;;;;;;;;;;;;;;;;;;;;AAy7TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AAwhpBA;;;;;AA41QA;AAm4DA;;;;;;AAo4YA;;;;;;AA8jaA;AAumvBA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAu7LA;;;;;;AA65DA;;;;;;;;;;;;;;;;;;;;;;;;;;AA68TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AA69pBA;;;;;AA81QA;AAm4DA;;;;;;AAo4YA;;;;;;AA0iaA;AA4lvBA","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;;;;;AA21CA;;;;;;AAspFA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA80CA;;;;;;AAqpFA","sourceRoot":""}
|
||||||
2
dist/swagger-ui.css
vendored
2
dist/swagger-ui.css
vendored
File diff suppressed because one or more lines are too long
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;;;;;;AA2idA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAokeA","sourceRoot":""}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui",
|
"name": "swagger-ui",
|
||||||
"version": "3.1.6",
|
"version": "3.2.0",
|
||||||
"main": "dist/swagger-ui.js",
|
"main": "dist/swagger-ui.js",
|
||||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
"scroll-to-element": "^2.0.0",
|
"scroll-to-element": "^2.0.0",
|
||||||
"serialize-error": "2.0.0",
|
"serialize-error": "2.0.0",
|
||||||
"shallowequal": "0.2.2",
|
"shallowequal": "0.2.2",
|
||||||
"swagger-client": "3.0.20",
|
"swagger-client": "3.1.0",
|
||||||
"url-parse": "^1.1.8",
|
"url-parse": "^1.1.8",
|
||||||
"whatwg-fetch": "0.11.1",
|
"whatwg-fetch": "0.11.1",
|
||||||
"worker-loader": "^0.7.1",
|
"worker-loader": "^0.7.1",
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export default class BaseLayout extends React.Component {
|
|||||||
errActions: PropTypes.object.isRequired,
|
errActions: PropTypes.object.isRequired,
|
||||||
specActions: PropTypes.object.isRequired,
|
specActions: PropTypes.object.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
|
oas3Selectors: PropTypes.object.isRequired,
|
||||||
|
oas3Actions: PropTypes.object.isRequired,
|
||||||
layoutSelectors: PropTypes.object.isRequired,
|
layoutSelectors: PropTypes.object.isRequired,
|
||||||
layoutActions: PropTypes.object.isRequired,
|
layoutActions: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired
|
getComponent: PropTypes.func.isRequired
|
||||||
@@ -19,7 +21,14 @@ export default class BaseLayout extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { specSelectors, specActions, getComponent, layoutSelectors } = this.props
|
let {
|
||||||
|
specSelectors,
|
||||||
|
specActions,
|
||||||
|
getComponent,
|
||||||
|
layoutSelectors,
|
||||||
|
oas3Selectors,
|
||||||
|
oas3Actions
|
||||||
|
} = this.props
|
||||||
|
|
||||||
let info = specSelectors.info()
|
let info = specSelectors.info()
|
||||||
let url = specSelectors.url()
|
let url = specSelectors.url()
|
||||||
@@ -28,6 +37,7 @@ export default class BaseLayout extends React.Component {
|
|||||||
let securityDefinitions = specSelectors.securityDefinitions()
|
let securityDefinitions = specSelectors.securityDefinitions()
|
||||||
let externalDocs = specSelectors.externalDocs()
|
let externalDocs = specSelectors.externalDocs()
|
||||||
let schemes = specSelectors.schemes()
|
let schemes = specSelectors.schemes()
|
||||||
|
let servers = specSelectors.servers()
|
||||||
|
|
||||||
let Info = getComponent("info")
|
let Info = getComponent("info")
|
||||||
let Operations = getComponent("operations", true)
|
let Operations = getComponent("operations", true)
|
||||||
@@ -35,6 +45,7 @@ export default class BaseLayout extends React.Component {
|
|||||||
let AuthorizeBtn = getComponent("authorizeBtn", true)
|
let AuthorizeBtn = getComponent("authorizeBtn", true)
|
||||||
let Row = getComponent("Row")
|
let Row = getComponent("Row")
|
||||||
let Col = getComponent("Col")
|
let Col = getComponent("Col")
|
||||||
|
let Servers = getComponent("Servers")
|
||||||
let Errors = getComponent("errors", true)
|
let Errors = getComponent("errors", true)
|
||||||
|
|
||||||
let isLoading = specSelectors.loadingStatus() === "loading"
|
let isLoading = specSelectors.loadingStatus() === "loading"
|
||||||
@@ -82,6 +93,22 @@ export default class BaseLayout extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
) : null }
|
) : null }
|
||||||
|
|
||||||
|
{ servers && servers.size ? (
|
||||||
|
<div className="server-container">
|
||||||
|
<Col className="servers wrapper" mobile={12}>
|
||||||
|
<Servers
|
||||||
|
servers={servers}
|
||||||
|
currentServer={oas3Selectors.selectedServer()}
|
||||||
|
setSelectedServer={oas3Actions.setSelectedServer}
|
||||||
|
setServerVariableValue={oas3Actions.setServerVariableValue}
|
||||||
|
getServerVariable={oas3Selectors.serverVariableValue}
|
||||||
|
getEffectiveServerValue={oas3Selectors.serverEffectiveValue}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
) : null}
|
||||||
|
|
||||||
{
|
{
|
||||||
filter === null || filter === false ? null :
|
filter === null || filter === false ? null :
|
||||||
<div className="filter-container">
|
<div className="filter-container">
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ export default class Operation extends PureComponent {
|
|||||||
<span className={ deprecated ? "opblock-summary-path__deprecated" : "opblock-summary-path" } >
|
<span className={ deprecated ? "opblock-summary-path__deprecated" : "opblock-summary-path" } >
|
||||||
<a
|
<a
|
||||||
className="nostyle"
|
className="nostyle"
|
||||||
onClick={(e) => e.preventDefault()}
|
onClick={isDeepLinkingEnabled ? (e) => e.preventDefault() : null}
|
||||||
href={ isDeepLinkingEnabled ? `#/${isShownKey[1]}/${isShownKey[2]}` : ""} >
|
href={isDeepLinkingEnabled ? `#/${isShownKey[1]}/${isShownKey[2]}` : null}>
|
||||||
<span>{path}</span>
|
<span>{path}</span>
|
||||||
</a>
|
</a>
|
||||||
<JumpToPath path={jumpToKey} />
|
<JumpToPath path={jumpToKey} />
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ export default class Operations extends React.Component {
|
|||||||
id={isShownKey.join("-")}>
|
id={isShownKey.join("-")}>
|
||||||
<a
|
<a
|
||||||
className="nostyle"
|
className="nostyle"
|
||||||
onClick={(e) => e.preventDefault()}
|
onClick={isDeepLinkingEnabled ? (e) => e.preventDefault() : null}
|
||||||
href={ isDeepLinkingEnabled ? `#/${tag}` : ""}>
|
href= {isDeepLinkingEnabled ? `#/${tag}` : null}>
|
||||||
<span>{tag}</span>
|
<span>{tag}</span>
|
||||||
</a>
|
</a>
|
||||||
{ !tagDescription ? null :
|
{ !tagDescription ? null :
|
||||||
|
|||||||
35
src/core/plugins/oas3/actions.js
Normal file
35
src/core/plugins/oas3/actions.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// Actions conform to FSA (flux-standard-actions)
|
||||||
|
// {type: string,payload: Any|Error, meta: obj, error: bool}
|
||||||
|
|
||||||
|
export const UPDATE_SELECTED_SERVER = "oas3_set_servers"
|
||||||
|
export const UPDATE_REQUEST_BODY_VALUE = "oas3_set_request_body_value"
|
||||||
|
export const UPDATE_REQUEST_CONTENT_TYPE = "oas3_set_request_content_type"
|
||||||
|
export const UPDATE_SERVER_VARIABLE_VALUE = "oas3_set_server_variable_value"
|
||||||
|
|
||||||
|
export function setSelectedServer (selectedServerUrl) {
|
||||||
|
return {
|
||||||
|
type: UPDATE_SELECTED_SERVER,
|
||||||
|
payload: selectedServerUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setRequestBodyValue ({ value, pathMethod }) {
|
||||||
|
return {
|
||||||
|
type: UPDATE_REQUEST_BODY_VALUE,
|
||||||
|
payload: { value, pathMethod }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setRequestContentType ({ value, pathMethod }) {
|
||||||
|
return {
|
||||||
|
type: UPDATE_REQUEST_CONTENT_TYPE,
|
||||||
|
payload: { value, pathMethod }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setServerVariableValue ({ server, key, val }) {
|
||||||
|
return {
|
||||||
|
type: UPDATE_SERVER_VARIABLE_VALUE,
|
||||||
|
payload: { server, key, val }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import Callbacks from "./callbacks"
|
import Callbacks from "./callbacks"
|
||||||
import RequestBody from "./request-body"
|
import RequestBody from "./request-body"
|
||||||
import OperationLink from "./operation-link.jsx"
|
import OperationLink from "./operation-link.jsx"
|
||||||
|
import Servers from "./servers"
|
||||||
|
import RequestBodyEditor from "./request-body-editor"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Callbacks,
|
Callbacks,
|
||||||
RequestBody,
|
RequestBody,
|
||||||
|
Servers,
|
||||||
|
RequestBodyEditor,
|
||||||
operationLink: OperationLink
|
operationLink: OperationLink
|
||||||
}
|
}
|
||||||
|
|||||||
114
src/core/plugins/oas3/components/request-body-editor.jsx
Normal file
114
src/core/plugins/oas3/components/request-body-editor.jsx
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
import React, { PureComponent } from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
import { fromJS } from "immutable"
|
||||||
|
import { getSampleSchema } from "core/utils"
|
||||||
|
|
||||||
|
const NOOP = Function.prototype
|
||||||
|
|
||||||
|
export default class RequestBodyEditor extends PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
requestBody: PropTypes.object.isRequired,
|
||||||
|
mediaType: PropTypes.string.isRequired,
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
getComponent: PropTypes.func.isRequired,
|
||||||
|
isExecute: PropTypes.bool,
|
||||||
|
specSelectors: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
mediaType: "application/json",
|
||||||
|
requestBody: fromJS({}),
|
||||||
|
onChange: NOOP,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
isEditBox: false,
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.setValueToSample.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if(this.props.mediaType !== nextProps.mediaType) {
|
||||||
|
// media type was changed
|
||||||
|
this.setValueToSample(nextProps.mediaType)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.props.isExecute && nextProps.isExecute) {
|
||||||
|
// we just entered execute mode,
|
||||||
|
// so enable editing for convenience
|
||||||
|
this.setState({ isEditBox: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setValueToSample = (explicitMediaType) => {
|
||||||
|
this.onChange(this.sample(explicitMediaType))
|
||||||
|
}
|
||||||
|
|
||||||
|
sample = (explicitMediaType) => {
|
||||||
|
let { requestBody, mediaType } = this.props
|
||||||
|
let schema = requestBody.getIn(["content", explicitMediaType || mediaType, "schema"]).toJS()
|
||||||
|
|
||||||
|
return getSampleSchema(schema, explicitMediaType || mediaType, {
|
||||||
|
includeWriteOnly: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onChange = (value) => {
|
||||||
|
this.setState({value})
|
||||||
|
this.props.onChange(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOnChange = e => {
|
||||||
|
const { mediaType } = this.props
|
||||||
|
const isJson = /json/i.test(mediaType)
|
||||||
|
const inputValue = isJson ? e.target.value.trim() : e.target.value
|
||||||
|
|
||||||
|
this.onChange(inputValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleIsEditBox = () => this.setState( state => ({isEditBox: !state.isEditBox}))
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let {
|
||||||
|
isExecute,
|
||||||
|
getComponent,
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
const Button = getComponent("Button")
|
||||||
|
const TextArea = getComponent("TextArea")
|
||||||
|
const HighlightCode = getComponent("highlightCode")
|
||||||
|
|
||||||
|
let { value, isEditBox } = this.state
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="body-param">
|
||||||
|
{
|
||||||
|
isEditBox && isExecute
|
||||||
|
? <TextArea className={"body-param__text"} value={value} onChange={ this.handleOnChange }/>
|
||||||
|
: (value && <HighlightCode className="body-param__example"
|
||||||
|
value={ value }/>)
|
||||||
|
}
|
||||||
|
<div className="body-param-options">
|
||||||
|
{
|
||||||
|
!isExecute ? null
|
||||||
|
: <div className="body-param-edit">
|
||||||
|
<Button className={isEditBox ? "btn cancel body-param__example-edit" : "btn edit body-param__example-edit"}
|
||||||
|
onClick={this.toggleIsEditBox}>{ isEditBox ? "Cancel" : "Edit"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,18 @@ import React from "react"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import ImPropTypes from "react-immutable-proptypes"
|
import ImPropTypes from "react-immutable-proptypes"
|
||||||
import { OrderedMap } from "immutable"
|
import { OrderedMap } from "immutable"
|
||||||
import { getSampleSchema } from "core/utils"
|
|
||||||
|
|
||||||
|
const RequestBody = ({
|
||||||
const RequestBody = ({ requestBody, getComponent, specSelectors, contentType }) => {
|
requestBody,
|
||||||
|
getComponent,
|
||||||
|
specSelectors,
|
||||||
|
contentType,
|
||||||
|
isExecute,
|
||||||
|
onChange
|
||||||
|
}) => {
|
||||||
const Markdown = getComponent("Markdown")
|
const Markdown = getComponent("Markdown")
|
||||||
const ModelExample = getComponent("modelExample")
|
const ModelExample = getComponent("modelExample")
|
||||||
const HighlightCode = getComponent("highlightCode")
|
const RequestBodyEditor = getComponent("RequestBodyEditor")
|
||||||
|
|
||||||
const requestBodyDescription = (requestBody && requestBody.get("description")) || null
|
const requestBodyDescription = (requestBody && requestBody.get("description")) || null
|
||||||
const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap()
|
const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap()
|
||||||
@@ -16,10 +21,6 @@ const RequestBody = ({ requestBody, getComponent, specSelectors, contentType })
|
|||||||
|
|
||||||
const mediaTypeValue = requestBodyContent.get(contentType)
|
const mediaTypeValue = requestBodyContent.get(contentType)
|
||||||
|
|
||||||
const sampleSchema = getSampleSchema(mediaTypeValue.get("schema").toJS(), contentType, {
|
|
||||||
includeWriteOnly: true
|
|
||||||
})
|
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
{ requestBodyDescription &&
|
{ requestBodyDescription &&
|
||||||
<Markdown source={requestBodyDescription} />
|
<Markdown source={requestBodyDescription} />
|
||||||
@@ -28,8 +29,16 @@ const RequestBody = ({ requestBody, getComponent, specSelectors, contentType })
|
|||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
specSelectors={ specSelectors }
|
specSelectors={ specSelectors }
|
||||||
expandDepth={1}
|
expandDepth={1}
|
||||||
|
isExecute={isExecute}
|
||||||
schema={mediaTypeValue.get("schema")}
|
schema={mediaTypeValue.get("schema")}
|
||||||
example={<HighlightCode value={sampleSchema} />}
|
example={<RequestBodyEditor
|
||||||
|
requestBody={requestBody}
|
||||||
|
onChange={onChange}
|
||||||
|
mediaType={contentType}
|
||||||
|
getComponent={getComponent}
|
||||||
|
isExecute={isExecute}
|
||||||
|
specSelectors={specSelectors}
|
||||||
|
/>}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -38,7 +47,9 @@ RequestBody.propTypes = {
|
|||||||
requestBody: ImPropTypes.orderedMap.isRequired,
|
requestBody: ImPropTypes.orderedMap.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
contentType: PropTypes.string.isRequired
|
contentType: PropTypes.string.isRequired,
|
||||||
|
isExecute: PropTypes.bool.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RequestBody
|
export default RequestBody
|
||||||
|
|||||||
155
src/core/plugins/oas3/components/servers.jsx
Normal file
155
src/core/plugins/oas3/components/servers.jsx
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
import React from "react"
|
||||||
|
import { OrderedMap } from "immutable"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
import ImPropTypes from "react-immutable-proptypes"
|
||||||
|
|
||||||
|
export default class Servers extends React.Component {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
servers: ImPropTypes.list.isRequired,
|
||||||
|
currentServer: PropTypes.string.isRequired,
|
||||||
|
setSelectedServer: PropTypes.func.isRequired,
|
||||||
|
setServerVariableValue: PropTypes.func.isRequired,
|
||||||
|
getServerVariable: PropTypes.func.isRequired,
|
||||||
|
getEffectiveServerValue: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
let { servers } = this.props
|
||||||
|
|
||||||
|
//fire 'change' event to set default 'value' of select
|
||||||
|
this.setServer(servers.first().get("url"))
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
let {
|
||||||
|
servers,
|
||||||
|
setServerVariableValue,
|
||||||
|
getServerVariable
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
if(this.props.currentServer !== nextProps.currentServer) {
|
||||||
|
// Server has changed, we may need to set default values
|
||||||
|
let currentServerDefinition = servers
|
||||||
|
.find(v => v.get("url") === nextProps.currentServer) || OrderedMap()
|
||||||
|
|
||||||
|
let currentServerVariableDefs = currentServerDefinition.get("variables") || OrderedMap()
|
||||||
|
|
||||||
|
currentServerVariableDefs.map((val, key) => {
|
||||||
|
let currentValue = getServerVariable(nextProps.currentServer, key)
|
||||||
|
// only set the default value if the user hasn't set one yet
|
||||||
|
if(!currentValue) {
|
||||||
|
setServerVariableValue({
|
||||||
|
server: nextProps.currentServer,
|
||||||
|
key,
|
||||||
|
val: val.get("default") || ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onServerChange =( e ) => {
|
||||||
|
this.setServer( e.target.value )
|
||||||
|
|
||||||
|
// set default variable values
|
||||||
|
}
|
||||||
|
|
||||||
|
onServerVariableValueChange = ( e ) => {
|
||||||
|
let {
|
||||||
|
setServerVariableValue,
|
||||||
|
currentServer
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
let variableName = e.target.getAttribute("data-variable")
|
||||||
|
let newVariableValue = e.target.value
|
||||||
|
|
||||||
|
if(typeof setServerVariableValue === "function") {
|
||||||
|
setServerVariableValue({
|
||||||
|
server: currentServer,
|
||||||
|
key: variableName,
|
||||||
|
val: newVariableValue
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setServer = ( value ) => {
|
||||||
|
let { setSelectedServer } = this.props
|
||||||
|
|
||||||
|
setSelectedServer(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let { servers,
|
||||||
|
currentServer,
|
||||||
|
getServerVariable,
|
||||||
|
getEffectiveServerValue
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
let currentServerDefinition = servers.find(v => v.get("url") === currentServer) || OrderedMap()
|
||||||
|
|
||||||
|
let currentServerVariableDefs = currentServerDefinition.get("variables") || OrderedMap()
|
||||||
|
|
||||||
|
let shouldShowVariableUI = currentServerVariableDefs.size !== 0
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<label htmlFor="servers">
|
||||||
|
<span className="servers-title">Servers</span>
|
||||||
|
<select onChange={ this.onServerChange }>
|
||||||
|
{ servers.valueSeq().map(
|
||||||
|
( server ) =>
|
||||||
|
<option
|
||||||
|
value={ server.get("url") }
|
||||||
|
key={ server.get("url") }>
|
||||||
|
{ server.get("url") }
|
||||||
|
</option>
|
||||||
|
).toArray()}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{ shouldShowVariableUI ?
|
||||||
|
<div>
|
||||||
|
<h4>Server variables</h4>
|
||||||
|
<div className={"computed-url"}>
|
||||||
|
Computed URL:
|
||||||
|
<code>
|
||||||
|
{getEffectiveServerValue(currentServer)}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
{
|
||||||
|
currentServerVariableDefs.map((val, name) => {
|
||||||
|
return <tr key={name}>
|
||||||
|
<td>{name}</td>
|
||||||
|
<td>
|
||||||
|
{ val.get("enum") ?
|
||||||
|
<select data-variable={name} onChange={this.onServerVariableValueChange}>
|
||||||
|
{val.get("enum").map(enumValue => {
|
||||||
|
return <option
|
||||||
|
selected={enumValue === getServerVariable(currentServer, name)}
|
||||||
|
key={enumValue}
|
||||||
|
value={enumValue}>
|
||||||
|
{enumValue}
|
||||||
|
</option>
|
||||||
|
})}
|
||||||
|
</select> :
|
||||||
|
<input
|
||||||
|
type={"text"}
|
||||||
|
value={getServerVariable(currentServer, name) || ""}
|
||||||
|
onChange={this.onServerVariableValueChange}
|
||||||
|
data-variable={name}
|
||||||
|
></input>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>: null
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
// import reducers from "./reducers"
|
// import reducers from "./reducers"
|
||||||
// import * as actions from "./actions"
|
// import * as actions from "./actions"
|
||||||
import * as wrapSelectors from "./wrap-selectors"
|
import * as specWrapSelectors from "./spec-extensions/wrap-selectors"
|
||||||
|
import * as specSelectors from "./spec-extensions/selectors"
|
||||||
import components from "./components"
|
import components from "./components"
|
||||||
import wrapComponents from "./wrap-components"
|
import wrapComponents from "./wrap-components"
|
||||||
|
import * as oas3Actions from "./actions"
|
||||||
|
import * as oas3Selectors from "./selectors"
|
||||||
|
import oas3Reducers from "./reducers"
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
return {
|
return {
|
||||||
@@ -10,7 +14,13 @@ export default function() {
|
|||||||
wrapComponents,
|
wrapComponents,
|
||||||
statePlugins: {
|
statePlugins: {
|
||||||
spec: {
|
spec: {
|
||||||
wrapSelectors
|
wrapSelectors: specWrapSelectors,
|
||||||
|
selectors: specSelectors
|
||||||
|
},
|
||||||
|
oas3: {
|
||||||
|
actions: oas3Actions,
|
||||||
|
reducers: oas3Reducers,
|
||||||
|
selectors: oas3Selectors,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/core/plugins/oas3/reducers.js
Normal file
23
src/core/plugins/oas3/reducers.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import {
|
||||||
|
UPDATE_SELECTED_SERVER,
|
||||||
|
UPDATE_REQUEST_BODY_VALUE,
|
||||||
|
UPDATE_REQUEST_CONTENT_TYPE,
|
||||||
|
UPDATE_SERVER_VARIABLE_VALUE
|
||||||
|
} from "./actions"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
[UPDATE_SELECTED_SERVER]: (state, { payload: selectedServerUrl } ) =>{
|
||||||
|
return state.setIn( [ "selectedServer" ], selectedServerUrl)
|
||||||
|
},
|
||||||
|
[UPDATE_REQUEST_BODY_VALUE]: (state, { payload: { value, pathMethod } } ) =>{
|
||||||
|
let [path, method] = pathMethod
|
||||||
|
return state.setIn( [ "requestData", path, method, "bodyValue" ], value)
|
||||||
|
},
|
||||||
|
[UPDATE_REQUEST_CONTENT_TYPE]: (state, { payload: { value, pathMethod } } ) =>{
|
||||||
|
let [path, method] = pathMethod
|
||||||
|
return state.setIn( [ "requestData", path, method, "requestContentType" ], value)
|
||||||
|
},
|
||||||
|
[UPDATE_SERVER_VARIABLE_VALUE]: (state, { payload: { server, key, val } } ) =>{
|
||||||
|
return state.setIn( [ "serverVariableValues", server, key ], val)
|
||||||
|
},
|
||||||
|
}
|
||||||
53
src/core/plugins/oas3/selectors.js
Normal file
53
src/core/plugins/oas3/selectors.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { OrderedMap } from "immutable"
|
||||||
|
import { isOAS3 as isOAS3Helper } from "./helpers"
|
||||||
|
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
|
function onlyOAS3(selector) {
|
||||||
|
return (...args) => (system) => {
|
||||||
|
const spec = system.getSystem().specSelectors.specJson()
|
||||||
|
if(isOAS3Helper(spec)) {
|
||||||
|
return selector(...args)
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const selectedServer = onlyOAS3(state => {
|
||||||
|
return state.getIn(["selectedServer"]) || ""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const requestBodyValue = onlyOAS3((state, path, method) => {
|
||||||
|
return state.getIn(["requestData", path, method, "bodyValue"]) || null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const requestContentType = onlyOAS3((state, path, method) => {
|
||||||
|
return state.getIn(["requestData", path, method, "requestContentType"]) || null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const serverVariableValue = onlyOAS3((state, server, key) => {
|
||||||
|
return state.getIn(["serverVariableValues", server, key]) || null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const serverVariables = onlyOAS3((state, server) => {
|
||||||
|
return state.getIn(["serverVariableValues", server]) || OrderedMap()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const serverEffectiveValue = onlyOAS3((state, server) => {
|
||||||
|
let varValues = state.getIn(["serverVariableValues", server]) || OrderedMap()
|
||||||
|
let str = server
|
||||||
|
|
||||||
|
varValues.map((val, key) => {
|
||||||
|
str = str.replace(new RegExp(`{${key}}`, "g"), val)
|
||||||
|
})
|
||||||
|
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
)
|
||||||
50
src/core/plugins/oas3/spec-extensions/selectors.js
Normal file
50
src/core/plugins/oas3/spec-extensions/selectors.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { createSelector } from "reselect"
|
||||||
|
import { Map } from "immutable"
|
||||||
|
import { isOAS3 as isOAS3Helper, isSwagger2 as isSwagger2Helper } from "../helpers"
|
||||||
|
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
|
function onlyOAS3(selector) {
|
||||||
|
return () => (system, ...args) => {
|
||||||
|
const spec = system.getSystem().specSelectors.specJson()
|
||||||
|
if(isOAS3Helper(spec)) {
|
||||||
|
return selector(...args)
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = state => {
|
||||||
|
return state || Map()
|
||||||
|
}
|
||||||
|
|
||||||
|
const specJson = createSelector(
|
||||||
|
state,
|
||||||
|
spec => spec.get("json", Map())
|
||||||
|
)
|
||||||
|
|
||||||
|
const specResolved = createSelector(
|
||||||
|
state,
|
||||||
|
spec => spec.get("resolved", Map())
|
||||||
|
)
|
||||||
|
|
||||||
|
const spec = state => {
|
||||||
|
let res = specResolved(state)
|
||||||
|
if(res.count() < 1)
|
||||||
|
res = specJson(state)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// New selectors
|
||||||
|
|
||||||
|
export const servers = onlyOAS3(createSelector(
|
||||||
|
spec,
|
||||||
|
spec => spec.getIn(["servers"]) || Map()
|
||||||
|
))
|
||||||
|
|
||||||
|
export const isSwagger2 = (ori, system) => () => {
|
||||||
|
const spec = system.getSystem().specSelectors.specJson()
|
||||||
|
return isSwagger2Helper(spec)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createSelector } from "reselect"
|
import { createSelector } from "reselect"
|
||||||
import { Map } from "immutable"
|
import { Map } from "immutable"
|
||||||
import { isOAS3 as isOAS3Helper, isSwagger2 as isSwagger2Helper } from "./helpers"
|
import { isOAS3 as isOAS3Helper, isSwagger2 as isSwagger2Helper } from "../helpers"
|
||||||
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
@@ -56,6 +56,11 @@ export const schemes = OAS3NullSelector
|
|||||||
|
|
||||||
// New selectors
|
// New selectors
|
||||||
|
|
||||||
|
export const servers = onlyOAS3(createSelector(
|
||||||
|
spec,
|
||||||
|
spec => spec.getIn(["servers"]) || Map()
|
||||||
|
))
|
||||||
|
|
||||||
export const isOAS3 = (ori, system) => () => {
|
export const isOAS3 = (ori, system) => () => {
|
||||||
const spec = system.getSystem().specSelectors.specJson()
|
const spec = system.getSystem().specSelectors.specJson()
|
||||||
return isOAS3Helper(spec)
|
return isOAS3Helper(spec)
|
||||||
@@ -3,7 +3,6 @@ import parameters from "./parameters"
|
|||||||
import VersionStamp from "./version-stamp"
|
import VersionStamp from "./version-stamp"
|
||||||
import OnlineValidatorBadge from "./online-validator-badge"
|
import OnlineValidatorBadge from "./online-validator-badge"
|
||||||
import Model from "./model"
|
import Model from "./model"
|
||||||
import TryItOutButton from "./try-it-out-button"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Markdown,
|
Markdown,
|
||||||
@@ -11,5 +10,4 @@ export default {
|
|||||||
VersionStamp,
|
VersionStamp,
|
||||||
model: Model,
|
model: Model,
|
||||||
onlineValidatorBadge: OnlineValidatorBadge,
|
onlineValidatorBadge: OnlineValidatorBadge,
|
||||||
TryItOutButton
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ class Parameters extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
callbackVisible: false,
|
callbackVisible: false,
|
||||||
parametersVisible: true,
|
parametersVisible: true
|
||||||
requestBodyContentType: ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +23,8 @@ class Parameters extends Component {
|
|||||||
operation: PropTypes.object.isRequired,
|
operation: PropTypes.object.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
|
oas3Actions: PropTypes.object.isRequired,
|
||||||
|
oas3Selectors: PropTypes.object.isRequired,
|
||||||
fn: PropTypes.object.isRequired,
|
fn: PropTypes.object.isRequired,
|
||||||
tryItOutEnabled: PropTypes.bool,
|
tryItOutEnabled: PropTypes.bool,
|
||||||
allowTryItOut: PropTypes.bool,
|
allowTryItOut: PropTypes.bool,
|
||||||
@@ -86,6 +87,8 @@ class Parameters extends Component {
|
|||||||
fn,
|
fn,
|
||||||
getComponent,
|
getComponent,
|
||||||
specSelectors,
|
specSelectors,
|
||||||
|
oas3Actions,
|
||||||
|
oas3Selectors,
|
||||||
pathMethod,
|
pathMethod,
|
||||||
operation
|
operation
|
||||||
} = this.props
|
} = this.props
|
||||||
@@ -159,16 +162,22 @@ class Parameters extends Component {
|
|||||||
<h4 className={`opblock-title parameter__name ${requestBody.get("required") && "required"}`}>Request body</h4>
|
<h4 className={`opblock-title parameter__name ${requestBody.get("required") && "required"}`}>Request body</h4>
|
||||||
<label>
|
<label>
|
||||||
<ContentType
|
<ContentType
|
||||||
value={this.state.requestBodyContentType}
|
value={oas3Selectors.requestContentType(...pathMethod)}
|
||||||
contentTypes={ requestBody.get("content").keySeq() }
|
contentTypes={ requestBody.get("content").keySeq() }
|
||||||
onChange={(val) => this.setState({ requestBodyContentType: val })}
|
onChange={(value) => {
|
||||||
|
oas3Actions.setRequestContentType({ value, pathMethod })
|
||||||
|
}}
|
||||||
className="body-param-content-type" />
|
className="body-param-content-type" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="opblock-description-wrapper">
|
<div className="opblock-description-wrapper">
|
||||||
<RequestBody
|
<RequestBody
|
||||||
requestBody={requestBody}
|
requestBody={requestBody}
|
||||||
contentType={this.state.requestBodyContentType}/>
|
isExecute={isExecute}
|
||||||
|
onChange={(value) => {
|
||||||
|
oas3Actions.setRequestBodyValue({ value, pathMethod })
|
||||||
|
}}
|
||||||
|
contentType={oas3Selectors.requestContentType(...pathMethod)}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import { OAS3ComponentWrapFactory } from "../helpers"
|
|
||||||
|
|
||||||
export default OAS3ComponentWrapFactory(() => {
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import YAML from "js-yaml"
|
import YAML from "js-yaml"
|
||||||
import parseUrl from "url-parse"
|
import parseUrl from "url-parse"
|
||||||
import serializeError from "serialize-error"
|
import serializeError from "serialize-error"
|
||||||
|
import { isJSONObject } from "core/utils"
|
||||||
|
|
||||||
// Actions conform to FSA (flux-standard-actions)
|
// Actions conform to FSA (flux-standard-actions)
|
||||||
// {type: string,payload: Any|Error, meta: obj, error: bool}
|
// {type: string,payload: Any|Error, meta: obj, error: bool}
|
||||||
@@ -195,7 +196,8 @@ export const logRequest = (req) => {
|
|||||||
|
|
||||||
// Actually fire the request via fn.execute
|
// Actually fire the request via fn.execute
|
||||||
// (For debugging) and ease of testing
|
// (For debugging) and ease of testing
|
||||||
export const executeRequest = (req) => ({fn, specActions, specSelectors, getConfigs}) => {
|
export const executeRequest = (req) =>
|
||||||
|
({fn, specActions, specSelectors, getConfigs, oas3Selectors}) => {
|
||||||
let { pathName, method, operation } = req
|
let { pathName, method, operation } = req
|
||||||
let { requestInterceptor, responseInterceptor } = getConfigs()
|
let { requestInterceptor, responseInterceptor } = getConfigs()
|
||||||
|
|
||||||
@@ -211,6 +213,20 @@ export const executeRequest = (req) => ({fn, specActions, specSelectors, getConf
|
|||||||
req.operationId = fn.opId(op, pathName, method)
|
req.operationId = fn.opId(op, pathName, method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(specSelectors.isOAS3()) {
|
||||||
|
// OAS3 request feature support
|
||||||
|
req.server = oas3Selectors.selectedServer()
|
||||||
|
req.serverVariables = oas3Selectors.serverVariables(req.server).toJS()
|
||||||
|
req.requestContentType = oas3Selectors.requestContentType(pathName, method)
|
||||||
|
const requestBody = oas3Selectors.requestBodyValue(pathName, method)
|
||||||
|
|
||||||
|
if(isJSONObject(requestBody)) {
|
||||||
|
req.requestBody = JSON.parse(requestBody)
|
||||||
|
} else {
|
||||||
|
req.requestBody = requestBody
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let parsedRequest = Object.assign({}, req)
|
let parsedRequest = Object.assign({}, req)
|
||||||
parsedRequest = fn.buildRequest(parsedRequest)
|
parsedRequest = fn.buildRequest(parsedRequest)
|
||||||
|
|
||||||
@@ -234,8 +250,12 @@ export const executeRequest = (req) => ({fn, specActions, specSelectors, getConf
|
|||||||
res.duration = Date.now() - startTime
|
res.duration = Date.now() - startTime
|
||||||
specActions.setResponse(req.pathName, req.method, res)
|
specActions.setResponse(req.pathName, req.method, res)
|
||||||
} )
|
} )
|
||||||
.catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) )
|
.catch(
|
||||||
}
|
err => specActions.setResponse(req.pathName, req.method, {
|
||||||
|
error: true, err: serializeError(err)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// I'm using extras as a way to inject properties into the final, `execute` method - It's not great. Anyone have a better idea? @ponelat
|
// I'm using extras as a way to inject properties into the final, `execute` method - It's not great. Anyone have a better idea? @ponelat
|
||||||
|
|||||||
@@ -13,6 +13,25 @@ const DEFAULT_REPONSE_KEY = "default"
|
|||||||
|
|
||||||
export const isImmutable = (maybe) => Im.Iterable.isIterable(maybe)
|
export const isImmutable = (maybe) => Im.Iterable.isIterable(maybe)
|
||||||
|
|
||||||
|
export function isJSONObject (str) {
|
||||||
|
try {
|
||||||
|
var o = JSON.parse(str)
|
||||||
|
|
||||||
|
// Handle non-exception-throwing cases:
|
||||||
|
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
|
||||||
|
// but... JSON.parse(null) returns null, and typeof null === "object",
|
||||||
|
// so we must check for that, too. Thankfully, null is falsey, so this suffices:
|
||||||
|
if (o && typeof o === "object") {
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
export function objectify (thing) {
|
export function objectify (thing) {
|
||||||
if(!isObject(thing))
|
if(!isObject(thing))
|
||||||
return {}
|
return {}
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
// Promise global, Used ( at least ) by 'whatwg-fetch'. And required by IE 11
|
// Promise global, Used ( at least ) by 'whatwg-fetch'. And required by IE 11
|
||||||
require("core-js/fn/promise")
|
|
||||||
|
if(!window.Promise) {
|
||||||
|
require("core-js/fn/promise")
|
||||||
|
}
|
||||||
|
|||||||
@@ -636,6 +636,77 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server-container
|
||||||
|
{
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
padding: 30px 0;
|
||||||
|
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0,0,0,.15);
|
||||||
|
|
||||||
|
.computed-url {
|
||||||
|
margin: 2em 0;
|
||||||
|
|
||||||
|
code {
|
||||||
|
color: grey;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 0 1em;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.servers
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.servers-title {
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
> label
|
||||||
|
{
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
margin: -20px 15px 0 0;
|
||||||
|
|
||||||
|
@include text_headline();
|
||||||
|
|
||||||
|
select
|
||||||
|
{
|
||||||
|
min-width: 130px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
tr {
|
||||||
|
width: 30em;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 15em;
|
||||||
|
vertical-align: middle;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
|
||||||
|
&:first-of-type {
|
||||||
|
padding-right: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.loading-container
|
.loading-container
|
||||||
{
|
{
|
||||||
@@ -726,12 +797,12 @@ section
|
|||||||
a.nostyle {
|
a.nostyle {
|
||||||
text-decoration: inherit;
|
text-decoration: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
cursor: auto;
|
cursor: pointer;
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|
||||||
&:visited {
|
&:visited {
|
||||||
text-decoration: inherit;
|
text-decoration: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
cursor: auto;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ describe("spec plugin - actions", function(){
|
|||||||
spec: () => fromJS({}),
|
spec: () => fromJS({}),
|
||||||
parameterValues: () => fromJS({}),
|
parameterValues: () => fromJS({}),
|
||||||
contentTypeValues: () => fromJS({}),
|
contentTypeValues: () => fromJS({}),
|
||||||
url: () => fromJS({})
|
url: () => fromJS({}),
|
||||||
|
isOAS3: () => false
|
||||||
},
|
},
|
||||||
getConfigs: () => configs
|
getConfigs: () => configs
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user