feat: lazy resolver (#4249)
* default to empty `ImmutableMap` when grabbing op metadata
* pass `errors` into JsonSchema components
* Account for Immutable data structure in JavaScriptonSchema...
...and create empty Lists instead of Maps by default.
* Pass ImmutableList through to JsonSchema child components
* Add lazy resolving spec state extensions
* TEMPORARY: disable conventional resolved spec
* WIP
* Use resolveSubtree in Operation display
* Freebie: short-circuit Markdown component if it is given plaintext
* NEW DEFAULT BEHAVIOR: `defaultModelsExpandDepth: 1` does not expand individual models
* Render faked Model expander to trigger resolution
* Baseline support for Editor lifecycles
* Display operation summaries before the operation is resolved
* Test migrations
* WIP
* Swagger2 TIO Body params
* a bit of cleanup
* Debounce string param inputs
* Reach into unresolved operation for deprecated flag, if available
* Fire subtree request outside of render
* Remove debugging flags
* Fix logical errors in spec statePlugins
* TODOs become TODONEs!
* Migrate deeplinking feature to non-resolved spec action
* ESLint fixes
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { PureComponent } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import { helpers } from "swagger-client"
|
||||
import { Iterable, fromJS } from "immutable"
|
||||
import { Iterable, fromJS, Map } from "immutable"
|
||||
|
||||
const { opId } = helpers
|
||||
|
||||
@@ -82,13 +82,24 @@ export default class OperationContainer extends PureComponent {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if(nextProps.response !== this.props.response) {
|
||||
const { path, method, specActions, specSelectors, response, isShown } = nextProps
|
||||
const resolvedSubtree = specSelectors.specResolvedSubtree(["paths", path, method])
|
||||
|
||||
if(response !== this.props.response) {
|
||||
this.setState({ executeInProgress: false })
|
||||
}
|
||||
|
||||
if(isShown && resolvedSubtree === undefined) {
|
||||
specActions.requestResolvedSubtree(["paths", path, method])
|
||||
}
|
||||
}
|
||||
|
||||
toggleShown =() => {
|
||||
let { layoutActions, tag, operationId, isShown } = this.props
|
||||
let { layoutActions, specActions, tag, operationId, path, method, isShown } = this.props
|
||||
if(!isShown) {
|
||||
// transitioning from collapsed to expanded
|
||||
specActions.requestResolvedSubtree(["paths", path, method])
|
||||
}
|
||||
layoutActions.show(["operations", tag, operationId], !isShown)
|
||||
}
|
||||
|
||||
@@ -108,7 +119,7 @@ export default class OperationContainer extends PureComponent {
|
||||
|
||||
render() {
|
||||
let {
|
||||
op,
|
||||
op: unresolvedOp,
|
||||
tag,
|
||||
path,
|
||||
method,
|
||||
@@ -140,10 +151,14 @@ export default class OperationContainer extends PureComponent {
|
||||
|
||||
const Operation = getComponent( "operation" )
|
||||
|
||||
const resolvedSubtree = specSelectors.specResolvedSubtree(["paths", path, method]) || Map()
|
||||
|
||||
const operationProps = fromJS({
|
||||
op,
|
||||
op: resolvedSubtree || Map(),
|
||||
tag,
|
||||
path,
|
||||
summary: unresolvedOp.getIn(["operation", "summary"]) || "",
|
||||
deprecated: resolvedSubtree.get("deprecated") || unresolvedOp.getIn(["operation", "deprecated"]) || false,
|
||||
method,
|
||||
security,
|
||||
isAuthorized,
|
||||
|
||||
Reference in New Issue
Block a user