diff --git a/src/core/components/errors.jsx b/src/core/components/errors.jsx index c72dd2fd..c3d6cf93 100644 --- a/src/core/components/errors.jsx +++ b/src/core/components/errors.jsx @@ -113,7 +113,7 @@ const SpecErrorItem = ( { error, jumpToLine } ) => { } function toTitleCase(str) { - return str + return (str || "") .split(" ") .map(substr => substr[0].toUpperCase() + substr.slice(1)) .join(" ") diff --git a/src/core/components/object-model.jsx b/src/core/components/object-model.jsx index 9ab4e99a..db8adfd5 100644 --- a/src/core/components/object-model.jsx +++ b/src/core/components/object-model.jsx @@ -21,6 +21,10 @@ export default class ObjectModel extends Component { let { specSelectors } = otherProps let { isOAS3 } = specSelectors + if(!schema) { + return null + } + let description = schema.get("description") let properties = schema.get("properties") let additionalProperties = schema.get("additionalProperties") diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index d1cc6786..457ee863 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -12,8 +12,10 @@ export default class Operation extends PureComponent { method: PropTypes.string.isRequired, operation: PropTypes.object.isRequired, showSummary: PropTypes.bool, + isShown: PropTypes.bool.isRequired, - isShownKey: CustomPropTypes.arrayOrString.isRequired, + tagKey: PropTypes.string, + operationKey: PropTypes.string, jumpToKey: CustomPropTypes.arrayOrString.isRequired, allowTryItOut: PropTypes.bool, @@ -52,38 +54,16 @@ export default class Operation extends PureComponent { } componentWillReceiveProps(nextProps) { - const defaultContentType = "application/json" - let { specActions, path, method, operation } = nextProps - let producesValue = operation.get("produces_value") - let produces = operation.get("produces") - let consumes = operation.get("consumes") - let consumesValue = operation.get("consumes_value") - if(nextProps.response !== this.props.response) { this.setState({ executeInProgress: false }) } - - if (producesValue === undefined) { - producesValue = produces && produces.size ? produces.first() : defaultContentType - specActions.changeProducesValue([path, method], producesValue) - } - - if (consumesValue === undefined) { - consumesValue = consumes && consumes.size ? consumes.first() : defaultContentType - specActions.changeConsumesValue([path, method], consumesValue) - } } toggleShown =() => { - let { layoutActions, isShownKey } = this.props - layoutActions.show(isShownKey, !this.isShown()) - } + let { layoutActions, tagKey, operationKey, isShown } = this.props + const isShownKey = ["operations", tagKey, operationKey] - isShown =() => { - let { layoutSelectors, isShownKey, getConfigs } = this.props - let { docExpansion } = getConfigs() - - return layoutSelectors.isShown(isShownKey, docExpansion === "full" ) // Here is where we set the default + layoutActions.show(isShownKey, !isShown) } onTryoutClick =() => { @@ -102,7 +82,9 @@ export default class Operation extends PureComponent { render() { let { - isShownKey, + operationKey, + tagKey, + isShown, jumpToKey, path, method, @@ -156,18 +138,17 @@ export default class Operation extends PureComponent { } let { tryItOutEnabled } = this.state - let shown = this.isShown() let onChangeKey = [ path, method ] // Used to add values to _this_ operation ( indexed by path and method ) return ( -
+
{method.toUpperCase()} e.preventDefault() : null} - href={isDeepLinkingEnabled ? `#/${isShownKey[1]}/${isShownKey[2]}` : null}> + href={isDeepLinkingEnabled ? `#/${tagKey}/${operationKey}` : null}> {path} @@ -193,7 +174,7 @@ export default class Operation extends PureComponent { }
- +
{ deprecated &&

Warning: Deprecated

} { description && diff --git a/src/core/components/operations.jsx b/src/core/components/operations.jsx index 6d760d53..b4958884 100644 --- a/src/core/components/operations.jsx +++ b/src/core/components/operations.jsx @@ -127,7 +127,8 @@ export default class Operations extends React.Component { const operationId = op.getIn(["operation", "operationId"]) || op.getIn(["operation", "__originalOperationId"]) || opId(op.get("operation"), path, method) || op.get("id") - const isShownKey = ["operations", createDeepLinkPath(tag), createDeepLinkPath(operationId)] + const tagKey = createDeepLinkPath(tag) + const operationKey = createDeepLinkPath(operationId) const allowTryItOut = specSelectors.allowTryItOutFor(op.get("path"), op.get("method")) const response = specSelectors.responseFor(op.get("path"), op.get("method")) @@ -135,11 +136,12 @@ export default class Operations extends React.Component { return transformErrors(errors, system.getSystem())) }, + [NEW_SPEC_ERR_BATCH]: (state, { payload }) => { + payload = payload.map(err => { + return fromJS(Object.assign(DEFAULT_ERROR_STRUCTURE, err, { type: "spec" })) + }) + return state + .update("errors", errors => (errors || List()).concat( fromJS( payload )) ) + .update("errors", errors => transformErrors(errors, system.getSystem())) + }, + [NEW_AUTH_ERR]: (state, { payload }) => { let error = fromJS(Object.assign({}, payload))