diff --git a/src/core/components/model.jsx b/src/core/components/model.jsx index ca5b23c3..3fa88116 100644 --- a/src/core/components/model.jsx +++ b/src/core/components/model.jsx @@ -49,6 +49,17 @@ export default class Model extends ImmutablePureComponent { schema = this.getRefSchema( name ) } + if(!schema) { + return + { name } + + + } + const deprecated = specSelectors.isOAS3() && schema.get("deprecated") isRef = isRef !== undefined ? isRef : !!$$ref type = schema && schema.get("type") || type diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index 35829182..e47b19c5 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -5,6 +5,7 @@ import { getExtensions, sanitizeUrl } from "core/utils" import { Iterable, List } from "immutable" import ImPropTypes from "react-immutable-proptypes" + export default class Operation extends PureComponent { static propTypes = { specPath: ImPropTypes.list.isRequired, @@ -155,6 +156,9 @@ export default class Operation extends PureComponent {
+ { operation && operation.size ? null : + + } { deprecated &&

Warning: Deprecated

} { description &&
@@ -176,23 +180,25 @@ export default class Operation extends PureComponent {
: null } - + fn={fn} + getComponent={ getComponent } + specActions={ specActions } + specSelectors={ specSelectors } + pathMethod={ [path, method] } + getConfigs={ getConfigs } + /> + } { !tryItOutEnabled ? null : ({specActions, specSelectors, errActio }) } -export const requestResolvedSubtree = path => system => { - const { - errActions, - fn: { - resolveSubtree, - AST: { getLineNumberForPath } - }, - specSelectors, - specActions, - } = system +let requestBatch = [] - const specStr = specSelectors.specStr() +const debResolveSubtrees = debounce(async () => { + const system = requestBatch.system // Just a reference to the "latest" system + + if(!system) { + console.error("debResolveSubtrees: don't have a system to operate on, aborting.") + return + } + const { + errActions, + errSelectors, + fn: { + resolveSubtree, + AST: { getLineNumberForPath } + }, + specSelectors, + specActions, + } = system if(!resolveSubtree) { console.error("Error: Swagger-Client did not provide a `resolveSubtree` method, doing nothing.") return } - const currentValue = specSelectors.specResolvedSubtree(path) + const specStr = specSelectors.specStr() - if(currentValue) { - return - } + try { + var batchResult = await requestBatch.reduce(async (prev, path) => { + const { resultMap, specWithCurrentSubtrees } = await prev + + const { errors, spec } = await resolveSubtree(specWithCurrentSubtrees, path) + + if(errSelectors.allErrors().size) { + errActions.clear({ + type: "thrown" + }) + } - return resolveSubtree(specSelectors.specJson().toJS(), path) - .then(({ spec, errors }) => { - errActions.clear({ - type: "thrown" - }) if(Array.isArray(errors) && 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" @@ -177,9 +188,31 @@ export const requestResolvedSubtree = path => system => { errActions.newThrownErrBatch(preparedErrors) } - return specActions.updateResolvedSubtree(path, spec) - }) - .catch(e => console.error(e)) + set(resultMap, path, spec) + set(specWithCurrentSubtrees, path, spec) + + return { + resultMap, + specWithCurrentSubtrees + } + }, Promise.resolve({ + resultMap: (specSelectors.specResolvedSubtree([]) || Map()).toJS(), + specWithCurrentSubtrees: specSelectors.specJson().toJS() + })) + + delete requestBatch.system + requestBatch = [] // Clear stack + } catch(e) { + console.error(e) + } + + specActions.updateResolvedSubtree([], batchResult.resultMap) +}, 35) + +export const requestResolvedSubtree = path => system => { + requestBatch.push(path) + requestBatch.system = system + debResolveSubtrees() } export function changeParam( path, paramName, paramIn, value, isXml ){ diff --git a/src/img/rolling-load.svg b/src/img/rolling-load.svg new file mode 100644 index 00000000..86ead2e4 --- /dev/null +++ b/src/img/rolling-load.svg @@ -0,0 +1 @@ + diff --git a/src/style/_layout.scss b/src/style/_layout.scss index 7bb218dc..4a117e5a 100644 --- a/src/style/_layout.scss +++ b/src/style/_layout.scss @@ -586,6 +586,16 @@ } } +.opblock-body +{ + .opblock-loading-animation + { + display: block; + margin: 3em; + margin-left: auto; + margin-right: auto; + } +} .opblock-body pre {