# Conflicts:
#	dist/swagger-ui-bundle.js
#	dist/swagger-ui-bundle.js.map
#	dist/swagger-ui-standalone-preset.js
#	dist/swagger-ui.js
#	dist/swagger-ui.js.map
This commit is contained in:
Buu Nguyen
2017-03-24 10:59:11 -07:00
70 changed files with 348 additions and 551 deletions

View File

@@ -1,36 +0,0 @@
import React, { PropTypes } from "react"
export default function (system) {
return {
components: {
NoHostWarning,
},
statePlugins: {
spec: {
selectors: {
allowTryItOutFor,
}
}
}
}
}
// This is a quick style. How do we improve this?
const style = {
backgroundColor: "#e7f0f7",
padding: "1rem",
borderRadius: "3px",
}
function NoHostWarning() {
return (
<div style={style}>Note: The interactive forms are disabled, as no `host` property was found in the specification. Please see: <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object" target="_blank">OAI 2.0/#swagger-object</a></div>
)
}
// Only allow if, there is a host field
function allowTryItOutFor(state) {
return ({specSelectors}) => {
return specSelectors.hasHost(state)
}
}

View File

@@ -277,8 +277,6 @@ export let getLineNumberForPathAsync = promisifySyncFn(getLineNumberForPath)
function promisifySyncFn(fn) {
return function(...args) {
return new Promise(function(resolve, reject) {
resolve(fn(...args))
})
return new Promise((resolve) => resolve(fn(...args)))
}
}

View File

@@ -4,7 +4,6 @@ import btoa from "btoa"
import {
SHOW_AUTH_POPUP,
AUTHORIZE,
PRE_AUTHORIZE_OAUTH2,
AUTHORIZE_OAUTH2,
LOGOUT
} from "./actions"
@@ -21,7 +20,6 @@ export default {
// refactor withMutations
securities.entrySeq().forEach( ([ key, security ]) => {
let type = security.getIn(["schema", "type"])
let name = security.get("name")
if ( type === "apiKey" ) {
map = map.set(key, security)

View File

@@ -10,7 +10,7 @@ export const shownDefinitions = createSelector(
export const definitionsToAuthorize = createSelector(
state,
auth =>( { specSelectors } ) => {
() =>( { specSelectors } ) => {
let definitions = specSelectors.securityDefinitions()
let list = List()
@@ -66,7 +66,6 @@ export const authorized = createSelector(
export const isAuthorized = ( state, securities ) =>( { authSelectors } ) => {
let authorized = authSelectors.authorized()
let isAuth = false
return !!securities.toJS().filter( ( security ) => {
let isAuthorized = true

View File

@@ -1,5 +1,3 @@
import { Map } from "immutable"
// Add security to the final `execute` call ( via `extras` )
export const execute = ( oriAction, { authSelectors, specSelectors }) => ({ path, method, operation, extras }) => {
let securities = {
@@ -10,4 +8,3 @@ export const execute = ( oriAction, { authSelectors, specSelectors }) => ({ path
return oriAction({ path, method, operation, securities, ...extras })
}

View File

@@ -4,7 +4,7 @@ import { createSelector } from "reselect"
import { Map } from "immutable"
export default function downloadUrlPlugin (toolbox) {
let { fn, Im } = toolbox
let { fn } = toolbox
const actions = {
download: (url)=> ({ errActions, specSelectors, specActions }) => {

View File

@@ -20,14 +20,14 @@ export function newThrownErrBatch(errors) {
}
}
export function newSpecErr(err, action) {
export function newSpecErr(err) {
return {
type: NEW_SPEC_ERR,
payload: err
}
}
export function newAuthErr(err, action) {
export function newAuthErr(err) {
return {
type: NEW_AUTH_ERR,
payload: err

View File

@@ -1,4 +1,3 @@
import concat from "lodash/concat"
import reduce from "lodash/reduce"
let request = require.context("./transformers/", true, /\.js$/)
let errorTransformers = []

View File

@@ -1,6 +1,5 @@
import get from "lodash/get"
import last from "lodash/get"
import { fromJS, List } from "immutable"
import { fromJS } from "immutable"
export function transform(errors, { jsSpec }) {
// LOOK HERE THIS TRANSFORMER IS CURRENTLY DISABLED 😃

View File

@@ -127,8 +127,12 @@ export const sampleXmlFromSchema = (schema, config={}) => {
if (xml.wrapped) {
res[displayName] = []
if (Array.isArray(defaultValue)) {
if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
res[displayName].push(sampleXmlFromSchema(items, config))
})
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
res[displayName].push(sampleXmlFromSchema(items, config))
@@ -145,14 +149,20 @@ export const sampleXmlFromSchema = (schema, config={}) => {
let _res = []
if (Array.isArray(defaultValue)) {
if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res
}
return sampleXmlFromSchema(items, config)
}
}
@@ -176,7 +186,13 @@ export const sampleXmlFromSchema = (schema, config={}) => {
} else {
props[propName].xml.name = props[propName].xml.name || propName
props[propName].example = props[propName].example !== undefined ? props[propName].example : example[propName]
res[displayName].push(sampleXmlFromSchema(props[propName]))
let t = sampleXmlFromSchema(props[propName])
if (Array.isArray(t)) {
res[displayName] = res[displayName].concat(t)
} else {
res[displayName].push(t)
}
}
}
}

View File

@@ -184,7 +184,7 @@ export const logRequest = (req) => {
// Actually fire the request via fn.execute
// (For debugging) and ease of testing
export const executeRequest = (req) => ({fn, specActions, errActions}) => {
export const executeRequest = (req) => ({fn, specActions}) => {
let { pathName, method } = req
let parsedRequest = Object.assign({}, req)
if ( pathName && method ) {

View File

@@ -51,7 +51,6 @@ export default {
[VALIDATE_PARAMS]: ( state, { payload: { pathMethod } } ) => {
let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] )
let parameters = operation.get("parameters")
let isXml = /xml/i.test(operation.get("consumes_value"))
return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => {
@@ -64,9 +63,6 @@ export default {
})
},
[ClEAR_VALIDATE_PARAMS]: ( state, { payload: { pathMethod } } ) => {
let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] )
let parameters = operation.get("parameters")
return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => {
return parameters.withMutations( parameters => {
for ( let i = 0, len = parameters.count(); i < len; i++ ) {

View File

@@ -224,7 +224,7 @@ export const requestFor = (state, path, method) => {
return requests(state).getIn([path, method], null)
}
export const allowTryItOutFor = (state, path, method ) => {
export const allowTryItOutFor = () => {
// This is just a hook for now.
return true
}

View File

@@ -57,14 +57,14 @@ export default class SplitPaneMode extends React.Component {
const mode = layoutSelectors.whatMode(MODE_KEY)
const left = mode === MODE_RIGHT ? <noscript/> : children[0]
const right = mode === MODE_LEFT ? <noscript/> : children[1]
const size = this.sizeFromMode(mode, '50%')
const size = this.sizeFromMode(mode, "50%")
return (
<SplitPane
disabledClass={''}
ref={'splitPane'}
disabledClass={""}
ref={"splitPane"}
split='vertical'
defaultSize={'50%'}
defaultSize={"50%"}
primary="second"
minSize={0}
size={size}

View File

@@ -3,10 +3,6 @@ import ReactDOM from "react-dom"
import { connect, Provider } from "react-redux"
import omit from "lodash/omit"
const NotFoundComponent = name => ()=> <span style={{color: "red"}}> "{name}" component not found </span>
const SystemWrapper = (getSystem, ComponentToWrap ) => class extends Component {
render() {
return <ComponentToWrap {...getSystem() } {...this.props} {...this.context} />
@@ -75,10 +71,10 @@ const createClass = component => React.createClass({
}
})
const Fallback = ({ error, name }) => <div style={{ // eslint-disable-line react/prop-types
const Fallback = ({ name }) => <div style={{ // eslint-disable-line react/prop-types
padding: "1em",
"color": "#aaa"
}}>😱 <i>Could not render { name ? name : "this component" }, see console.</i></div>
}}>😱 <i>Could not render { name || name === "t" ? name : "this component" }, see the console.</i></div>
const wrapRender = (component) => {
const isStateless = component => !(component.prototype && component.prototype.isReactComponent)